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

Re: getting position of tag

Subject: Re: getting position of tag
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 15 Sep 2004 11:55:16 -0400
get tag position
Hi Dusan,

You don't really want "position()", which returns the position of the current node in the current node list. You haven't shown us what your template is matching here, so we don't know what either of those are, but it's not really a relevant question, since your XPath, which traverses from the root, suggests you want this number irrespective of the processing context.

Accordingly, you can do one of two things:

1. Count the columns preceding the column you want, and add 1:

xsl:value-of
 select="count(/columns/column[source='B']/preceding-sibling::column) + 1"

2. Change context to the column you want, and use the xsl:number instruction

<xsl:for-each select="/columns/column[source='B']">
  <xsl:number/>
</xsl:for-each>

(If you are in a template that has matched this node, the for-each instruction is unnecessary.)

Look up xsl:number to learn about its many powerful and useful features.

I hope that helps,
Wendell

At 09:55 AM 9/15/2004, you wrote:
Hi.

I have this problem:

XML:
<columns>
        <column>
                <source>A</source>
        </column>
        <column>
                <source>B</source>
        </column>
</xolumns>

I want to get position() of tag column, where source='B'.

I have tried
xsl:value-of select="/columns/column[source='B']/position()"
but it is bad.

Anyone help me?


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================


--+------------------------------------------------------------------ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/ or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx> --+--

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.