Reputation: 491
I have the following piece of XML that I need to transform into an image tag:
<surface xml:id="EETS.T.68">
<label>Verse 68<note place="bottom" anchored="true" xml:id="informational">In
Bodleian Laud 683, BL Harley 218, and BL Harley 2255 this verse is prefaced
with the Latin "dic anime mee salus tua ego sum" [“Say to my soul, you are
my salvation”], from Psalm 34:3. It is part of a five-stanza sequence
treated in this manner in those texts, but only three of the verses appear
at Long Melford.</note>
</label>
<graphic url="ww_test_5.jpg"/>
</surface>
Using the following template:
<xsl:template match="tei:graphic" mode="list">
<a class="nav_link">
<img class="thumbnail">
<xsl:attribute name="alt">
<xsl:value-of select="../tei:label"/>
</xsl:attribute>
</img>
</a>
</span>
</xsl:template>
I use the label elsewhere in my transform, so I can't really move elements around, but what I'd like to have happen is that it forms something like this:
<img class="thumbnail" src="../../Testament/Clopton/Thumbnails/ww_test_5-thumbnail.jpg" alt="Verse 68"/>
(note:I have deleted the thumbnail and src attributes above as it was confusing people)
Instead, the note contents are also included so I get this:
<img class="thumbnail"
src="../../Testament/Clopton/Thumbnails/ww_test_5-thumbnail.jpg"
alt="Verse 68In
 Bodleian Laud 683, BL Harley 218, and BL Harley 2255 this verse is prefaced
 with the Latin "dic anime mee salus tua ego sum" [“Say to my soul, you are
 my salvation”], from Psalm 34:3. It is part of a five-stanza sequence
 treated in this manner in those texts, but only three of the verses appear
 at Long Melford."
/>
I looked at some of the similar questions but they don't seem to really work for my use case. I've tried using text(not[*])
, but that suppresses everything when there's a note element rather than just the note element itself. I'm also not sure xsl:copy-of is a viable option since I'm trying to get the content of a sibling node (and thus move up a level before selecting tei:label rather than selecting it directly.). When I've tried to use it it hasn't returned a result at all. Is there a way to get the result I'm looking for?
Upvotes: 0
Views: 317
Reputation: 167491
If you want to select only the first text child node use <xsl:value-of select="../tei:label/text()[1]"/>
or for the first child node <xsl:value-of select="../tei:label/node()[1]"/>
.
Upvotes: 1
Reputation: 116982
This is very confusing. I think (!) you are trying to get only the text node that is a direct child of label
? That could be done by changing:
<xsl:attribute name="alt">
<xsl:value-of select="../tei:label"/>
</xsl:attribute>
to:
<xsl:attribute name="alt">
<xsl:value-of select="../tei:label/text()"/>
</xsl:attribute>
Upvotes: 0