This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: RE: Next node name
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: "Casadome, Francisco Javier" <Francisco dot Casadome at bowneglobal dot es>
- Cc: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Date: Wed, 3 Apr 2002 18:44:55 +0100
- Subject: Re: [xsl] RE: Next node name
- Organization: Jeni Tennison Consulting Ltd
- References: <CF9ECD50D7CFD5118366009027E5A23C097B26@MADRID-MAIL01>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Francisco,
> 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.
The easiest way to check that you are on a text node is with:
self::text()
Or you could apply templates to the child nodes of the seg element in
'seg' mode:
<xsl:template match="seg">
<xsl:apply-templates select="node()" mode="seg" />
</xsl:template>
and have separate templates for text nodes and elements:
<xsl:template match="*" mode="seg" />
<xsl:template match="text()" mode="seg">
...
</xsl:template>
To check the immediately preceding node, locate it with the
preceding-sibling:: axis:
preceding-sibling::node()[1]
And test whether it's a ut element with the self:: axis:
preceding-sibling::node()[1][self::ut]
Similarly, you can test whether the immediately following node is a ut
element with:
following-sibling::node()[1][self::ut]
Having said that, I'm not sure whether this is going to help you do
what you need to do. In your example:
<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>
There are three text nodes that are between ut elements:
"<b>"
"Set"
"</b>"
So what you'd actually get would be:
<tu>
<tuv>
<seg>Use (%TERM%)(%TERM%)(%TERM%) when you want to assign an object reference</seg>
</tuv>
</tu>
I'm not sure what you should do about this because it's not clear to
me how you can tell that the "<b>" and "</b>" text nodes
shouldn't be replaced...
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list