Re: Need test for preceding-sibling
I have a structure like this:
This description is a bit imprecise ... do you need them paired, or will any <a1> before an <a2> suffice?
I ask because in the example you have every <a2> has a preceding <a1>, some with intervening tags and some without.
But it isn't true that every <a2> has a preceding <a1> that follows any preceding <a2>.
I know that
You shouldn't be working with name() because that deals with strings and not expanded node names in a namespace-safe fashion.
The test that there is any <a1> before the current node being <a2> is:
The test that there is an <a1> correspondingly before every <a2> is approached more easily with XSLT 2 grouping from the parent of those siblings:
<xsl:for-each-group select="*" group-ending-with="a2"> <xsl:if test="not(current-group()/self::a1)"> Error! No corresponding a1 for the given a2 </xsl:if> </xsl:for-each-group>
I hope this helps.
. . . . . . . . . . . . Ken
-- XSLT/XSL-FO/XQuery hands-on training - Los Angeles, USA 2009-06-08 Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format