[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: RE: Next node name

Subject: Re: RE: Next node name
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 3 Apr 2002 18:44:55 +0100
xsl next node
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>&lt;b&gt;<ut>}</ut>Set<ut>{\cs6\f1\cf6\lang1024</ut>&lt;/b&gt;<ut>}
</ut> when you want to assign an object reference</seg>
  </tuv>
</tu>

There are three text nodes that are between ut elements:

  "&lt;b&gt;"
  "Set"
  "&lt;/b&gt;"

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 "&lt;b&gt;" and "&lt;/b&gt;" 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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.