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

Re: testing for position of an element and displaying

Subject: Re: testing for position of an element and displaying it accordingly
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 19 Jan 2007 15:43:47 GMT
Re:  testing for position of an element and displaying
  <xsl:if test child::a>
  <xsl:apply-templates select="a" mode="test"/>

This seems to be the same problem as the  "Axis specifers" list posted
earlier, as explained there, teh xsl:if is not doing anything, the above
three lines are equivalent to

  <xsl:apply-templates select="a" mode="test"/>

and these have teh effect of processing all a elements, you don't want
to do that you want to process all elements in order, both a and b. so
just have

<xsl:template match="r1">
<xsl:apply-templates />

a elements appear to be paragraphs

<xsl:template match="a">
<p><xsl:apply-templates /></p>

and you want elements to be numbered

<xsl:template match="b">
<p><xsl:number/><xsl:apply-templates /></p>

this is again equivalent to the code posted in the earlier thread.

> How do I check that if there are <a> elements before
> <b> element inside <r1>, then they should be displayed
> before the <b> element. And if there are <a> elements
> after the <b> element, they should be displayed after
> the <b> element? 

you could check with test="b/preceding-sibling::a" but there is no need
to check as the behaviour that you want is the defualt behaviour, the
only reason that the a and b elements are being processed out of order
is that elsewhere in your code you explictly select all the a elements
so they are being processed first.


Current Thread


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.
First Name
Last Name
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-2013 All Rights Reserved.