I’m basically looking for the opposite of this
An example of the XML I’m dealing with:
<profiledesc>
<creation>
Finding Aid encoded by Some Guy, <date normal="2011-09-21">21 September 2011</date>
</creation>
<langusage encodinganalog="546">
Finding aid written in
<language langcode="eng" scriptcode="latn" encodinganalog="041">
English
</language>
</langusage>
</profiledesc>
An example of the XSLT I’m writting (only the relevant parts):
<xsl:template priority="3" match="descgrp|eadheader|filedesc|titlestmt|profiledesc|archdesc|langusage|did">
<xsl:apply-templates select="./child::node()"/>
</xsl:template>
<xsl:template priority="2" match="language">
<atom name="EADLanguageOfFindingAid" type="text" size="short">
<xsl:value-of select="."/>
</atom>
<atom name="EADLanguageCodeOfFindingAid" type="text" size="short">
<xsl:value-of select="normalize-space(@langcode)"/>
</atom>
</xsl:template>
... Other templates, for nodes like 'creation' ....
An example of the (bad) output I’m getting:
... Some other tags ...
<atom name="EADCreation" type="text" size="short">Finding Aid encoded by Some Guy, 21 September 2011</atom>
Finding aid written in
<atom name="EADLanguageOfFindingAid" type="text" size="short"> English </atom>
<atom name="EADLanguageCodeOfFindingAid" type="text" size="short">eng</atom>
... Some other tags ...
An example of the (good) output I want:
... Some other tags ...
<atom name="EADCreation" type="text" size="short">Finding Aid encoded by Some Guy, 21 September 2011</atom>
<atom name="EADLanguageOfFindingAid" type="text" size="short"> English </atom>
<atom name="EADLanguageCodeOfFindingAid" type="text" size="short">eng</atom>
... Some other tags ...
Note that in the second output the “Finding aid written in” line is missing.
So, as you can see, I designed templates to output just the “language” portion of the “langusage” tag, but the whole tag, including the “Finding aid written in” text node, is being output instead. I can’t be sure that the text node will exist or that it will be first (or last, or in any particular position). I also can’t be sure that there will only be one text node or one child node. So, I can’t make use of any solution that relies on simply choosing the “[xth]” node (child or text).
I’d appreciate any advice at this point, even some keywords that would help me find the solution via Google (I’ve had no luck there so far).
It sounds like you want to select only the child elements of
langusageinstead of all child nodes (of any type, which is whatnode()selects (excluding attribute nodes and the root node)).For example, this stylesheet:
Applied to this simplified input:
Produces the following output:
The unwanted text — Finding aid written in — does not appear in the output.
Note that the
*in:…is just a shorter way to say
child::*. Both select all element children of the current node.