xml - Create hyperlink with concat in XSLT --> HTML -
hi , happy year !
once again, need transformation in xslt.
i have xml-tei file lot of pb elements. instance :
<pb ed="bnf" id="f77.image.r"/> i have in same file 1 link element :
<link id="bnf" target="http://test.com:/12148/btv1b90621925/"/> my transformation in xslt should not transform <pb> element in html : [77r] [77r] should hyperlink.
now, first stuff :
<xsl:template match="pb[@ed='bnf']"><span class="pb"> <xsl:text> [</xsl:text> <xsl:value-of select="substring-after(substring-before(@id, '.image.'), 'f')"/><xsl:value-of select="substring-after(@id, '.image.')"> </xsl:value-of> <xsl:text></xsl:text> <xsl:apply-templates/> <xsl:text>] </xsl:text> </span> </xsl:template> how can reach link element , [f77r] takes value of link , concat id of pb element ? every pb should hyperlink (with end changing each pb) :
http://test.com:/12148/btv1b90621925/f77.image.r
thank :)
best wishes, micha
it looks use key here, link elements there id attribute.
<xsl:key name="links" match="link" use="@id" /> then can use key target of link when construct href hyperlink
<a href="{key('links', @ed)/@target}{@id}"> note double-use of attribute value templates create attribute. write if wanted
<a href="{concat(key('links', @ed)/@target, @id)}"> try xslt template
<xsl:template match="pb[@ed='bnf']"> <span class="pb"> <a href="{concat(key('links', @ed)/@target, @id)}"> <xsl:text> [</xsl:text> <xsl:value-of select="substring-after(substring-before(@id, '.image.'), 'f')"/><xsl:value-of select="substring-after(@id, '.image.')"> </xsl:value-of> <xsl:apply-templates/> <xsl:text>] </xsl:text> </a> </span> </xsl:template> this should output following:
<span class="pb"> <a href="http://test.com:/12148/btv1b90621925/f77.image.r"> [77r] </a> </span>
Comments
Post a Comment