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

RE: can't conditionally format first occurence of a no

Subject: RE: can't conditionally format first occurence of a node
From: jeremy <jeremy_march@xxxxxxxxxxx>
Date: Sat, 25 Jun 2005 20:12:18 -0400
jeremy orth
Thanks for your reply.  Here's an input sample and two stylesheets which
don't quite work.

Sample xml:
<?xml version="1.0" encoding="utf-8"?>
<TEI.2>
<text>
<body>
<entryFree>
<otherstuff1>stuff1</otherstuff1>
<otherstuff2>stuff2</otherstuff2>
<otherstuff3>stuff3</otherstuff3>
<sense n="1">blah1</sense>
<sense n="2">blah2</sense>
<sense n="3">blah3</sense>
</entryFree>
</body>
</text>
</TEI.2>


This stylesheet puts the <br />'s in the wrong place (not before the
first <sense>.

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="sense">
<xsl:if test="position()=1">
<br /><br /><br />
</xsl:if>
<br /><div><b><xsl:value-of select="@n"/></b>.
<xsl:apply-templates /></div>
</xsl:template>
</xsl:stylesheet>

This stylsheet puts the <br />'s in the right place but doesn't include
the "otherstuff" content.

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="entryFree">
<xsl:apply-templates select="orth" />
<xsl:for-each select="sense">
<xsl:if test="position()=1">
<br /><br /><br />
</xsl:if>
<br /><div><b><xsl:value-of select="@n"/></b>.
<xsl:apply-templates /></div>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>


On Sun, 2005-06-26 at 02:57 +0000, Aron Bock wrote:
> Jeremy,
> 
> You had the right idea with position() -- the first <sense> in the doc would 
> be position() = 1.  If you mean something else, please post a small input 
> sample.
> 
> >
> ><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>
> >
> 
> This doesn't work in XSL -- variables can't change their value once set.  
> They're "variables" in the sense of mathematical variables which have a 
> specific, non-changing value throughout a computation, rather being 
> variables in the sense of imperative laguage variables that can have a 
> different value at different points of a computation.
> 
> --A
> 
> _________________________________________________________________
> Dont just search. Find. Check out the new MSN Search! 
> http://search.msn.click-url.com/go/onm00200636ave/direct/01/

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.