This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Next node name
- From: "Casadome, Francisco Javier" <Francisco dot Casadome at bowneglobal dot es>
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Date: Wed, 3 Apr 2002 13:41:02 +0200
- Subject: [xsl] RE: Next node name
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi all,
I have an xml like this (actually is a TMX):
<tu>
<tuv>
<seg>Use <ut>{\cs6\f1\cf6\lang1024
</ut><b><ut>}</ut>Set<ut>{\cs6\f1\cf6\lang1024
</ut></b><ut>}</ut> when you want to assign an object reference</seg>
</tuv>
</tu>
with a lot of "tu".
I want to replace all the formatted text (the word "Set" in the example
above) and the format nodes by a string, lets say "(%TERM%)".
The result would be:
<tu>
<tuv>
<seg>Use (%TERM%) when you want to assign an object reference</seg>
</tuv>
</tu>
I use this template to walk through the nodes inside "seg" nodes (note that
it's not working right now):
<xsl:template match="seg">
<xsl:for-each select="node()">
<xsl:choose>
<xsl:when test="not(name()) and not(following-sibling::*[1][name()])">
<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise>
<!-- <xsl:text>(%TERM%)</xsl:text>-->
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
What I do is: when the node has no name, it means we are in a text node, so
there's nothing to do with it unless it's between two nodes with name (the
"ut" nodes), then is when I have to replace.
For the nodes with name (the "ut" nodes) I just do nothing so they are
removed.
What I need to know is how to reference the next and previous node names to
check if they are "ut" nodes.
Thanks in advance,
Frank.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list