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

can't conditionally format first occurence of a node

Subject: can't conditionally format first occurence of a node
From: jeremy <jeremy_march@xxxxxxxxxxx>
Date: Sat, 25 Jun 2005 19:22:42 -0400
xslt first occurence of
Dear list,

I need to add "<br />" before the first occurance of a node "<sense>".
What I would like to work is this:

<xsl:template match="sense">
<xsl:if test="position()=1">
<br />
</xsl:if>
<div><xsl:apply-templates /></div>
</xsl:template>

but as I've now discovered position() doesn't mean the first <sense>
node here like it does if it were a <xsl:for-each...> loop.

I don't think I can use a <xsl:for-each...> because outside of the
<sense> nodes the structure is very free form--i.e. I need to "push
process" rather than "pull process".  I also tried using a global
variable which I would want to change after the first <sense> node:

<xsl:variable name="first" select="1" />
<xsl:template match="sense">
<xsl:if test"$first=1">
<br />
<xsl:variable name="first" select="0" />
</xsl:if>
<div><xsl:apply-templates /></div>
</template>

but this just creates a local $first variable which won't be used for
the next <sense> node.  Is there another way to change the value of
$first after the first time it is used?

Any ideas.

Thanks,
Jeremy

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