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

RE: postion gives me 2 instead of 1

Subject: RE: postion gives me 2 instead of 1
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 20 Jun 2003 11:58:42 +0100
xml2txt
FAQ: the first child is the whitespace text node that precedes the
element.

But match = "listitem/para[1]" should work, because the [1] here means
"the first para child of a listitem". The position() function tests the
number of the element within the sequence of nodes being processed by
the calling xsl:apply-templates call.

Michael Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Paul Tremblay
> Sent: 20 June 2003 06:25
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  postion gives me 2 instead of 1
> 
> 
> I am having problems trying to do something with just the 
> first element.
> 
> Here is a fragment from my XML document:
> 
> 
>     
> 
>     <orderedlist>
>         <listitem number="1">
>             <para>
> Install python (www.python.org).
>             </para>
> 	    
>         </listitem>
> 	<listitem number="2">
>             <para>
> Download the xml2txt from (?).
>             </para>
> 	    <para>
> You can find the latest working versions from ...
> 	    </para>
>         </listitem>
> 	</orderedlist>
> 
> I want to put a number just in front of the first paragraphs 
> in each listitem.  
> 
> Here is a try from my xslt stylesheet:
> 
> 
>     <xsl:template match = "listitem/para[1]">
>         <block>
>             <xsl:value-of select = "../@number"/>
>             <xsl:apply-templates/>
>         </block>
>     </xsl:template>
> 
> This doesn't work. For some reason, xslt gives the position 
> number as 2 for the first paragraph. For example, this 
> styelsheet works, but I don't know
> why:
> 
> <xsl:template match = "listitem/para">
>        <xsl:if test = "position() = 2">
>         <block>
>             <xsl:value-of select = "../@number"/>
>             <xsl:apply-templates/>
>         </block>
>        </xsl:if>
> </xsl:template>
> 
> Thanks
> 
> Paul
> 
> 
> -- 
> 
> ************************
> *Paul Tremblay         *
> *phthenry@xxxxxxxxxxxxx*
> ************************
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.