xsl-list
[Top] [All Lists]

RE: Testing for a following sibling node type that occurs a t a varied position

2004-06-30 00:20:51
Hi Michael,

I changed your test a little, so I detect all the last 'B' by testing if the
name of the actual node differs from the name of the following node.
I hope this will help you

-----------------------------------------
<xsl:template match="root">
 <xsl:for-each select="B">
  <xsl:if test="not(name() = name(following-sibling::*))">
   <xsl:value-of select="." />
  </xsl:if>
 </xsl:for-each>
</xsl:template>
-----------------------------------------

Tobias Nies

Hi Brian,
There aren't multiple A's after a given B, but here is an example of how
I'm
trying to implement this in the XSL:

-----------------------------
<xsl:template match="root">
 <xsl:for-each select="B">
  <xsl:if test="../A/preceding-sibling::B[1]/following-sibling::A[1]">
   Hello
  </xsl:if>
 </xsl:for-each>
</xsl:template>
-----------------------------

..and it seems to be indicating that the test is true for each instance of
the B node, instead of just testing true for the last one which is what I
need. 

Does this implementation look like what you had intended?

Thanks again,
Steve

-----Original Message-----
From: Brian Chrisman [mailto:brian(_dot_)chrisman(_at_)hp(_dot_)com] 
Sent: Tuesday, June 29, 2004 4:18 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Testing for a following sibling node type that occurs a
t
a varied position

Wright, Steve wrote:

Hi Michael,
Thanks for your suggestion. I tried implementing it, but since I am
actually
operating from w/in a for-each loop of the 'B' node, I need to test for
the
following 'A' node from the last 'B' node in each sequence somehow, and I
didn't have any luck using the preceding-sibling function. 

Any other ideas?

 



root/A/preceding-sibling::B[1]/following-sibling::A[1]

This will output duplicates A's if there are multiple A's after a 
particular B...
Are there multiple A's after a particular B?  There aren't in the sample 
doc.

Brian

Thanks again,
Steve

-----Original Message-----
From: Michael Kay [mailto:mhk(_at_)mhk(_dot_)me(_dot_)uk] 
Sent: Tuesday, June 29, 2004 3:54 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] Testing for a following sibling node type that occurs
at
a varied position

Starting with <root> as the context node, you can select the marked B
nodes
using

A/preceding-sibling::B[1]

Michael Kay 

 

-----Original Message-----
From: Wright, Steve [mailto:Steve(_dot_)Wright(_at_)aw(_dot_)com] 
Sent: 29 June 2004 23:40
To: XSL-List(_at_)lists(_dot_) mulberrytech. com 
(XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com)
Subject: [xsl] Testing for a following sibling node type that 
occurs at a varied position

I wasn't sure on how else to phrase the subject, but here is 
what I need
help in figuring out:



I need to detect when a specific sibling node follows the 
context node in
the document order, the catch is that it is not always 
located the same
number of positions after the context node, if it were, 
something like this
would work: 

--------------------------------------------------------------

following-sibling::node()[1][self::A]

--------------------------------------------------------------



Here is an XML example to illustrate my situation:

--------------------------------------------

<root>

           <A>text</A>

           <B>text</B>

           <B>text</B>

           <B>text</B> (indicate this node based on 
following sibling 'A')

           <C>text</C>

           <C>text</C>

           <C>text</C>

           <A>text</A> 

           <B>text</B>

           <B>text</B>

           <B>text</B>

           <B>text</B> (indicate this node based on 
following sibling 'A')

           <D>text</D>

           <D>text</D>

           <A>text</A>

           <B>text</B>

           <B>text</B> (indicate this node based on 
following sibling 'A')

           <C>text</C>

           <A>text</A>

           <B>text</B>

           <B>text</B>

           <B>text</B>

           <B>text</B> (indicate this node based on 
following sibling 'A')

           <C>text</C>

           <D>text</D>

           <D>text</D>

           <D>text</D>

           <C>text</C>

           <A>text</A>

</root>

--------------------------------------------



I want to implement a feature that corresponds w/ the last 
'B' node that
occurs before the next 'A' node.



Thanks in advance for any help.



Steve

-- 
"Sie haben neue Mails!" - Die GMX Toolbar informiert Sie beim Surfen!
Jetzt aktivieren unter http://www.gmx.net/info



<Prev in Thread] Current Thread [Next in Thread>