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

Finding the position of a node within a subset of node

Subject: Finding the position of a node within a subset of nodes
From: John Sands <WonkoWatson@xxxxxxxxx>
Date: Thu, 27 Feb 2003 09:22:51 -0500
xsl subset
I have an XML document representing an evaluation form containing
three types of sections that can appear any number of times in any
order (the three types of sections are comment sections, instruction
sections, and question sections). Here's a fragment:

  <sections>
    <instructions>
      <instruction_text>A whole bunch of bogus instructions are here</instruction_text>
    </instructions>
    <questions name="Bogus Section">
      <question name="Bogus question" answer_scheme_id="1" />
    </questions>
    <comments>
      <comment_text>one line of bogus comments here</comment_text>
    </comments>
    <questions name="Another Bogus Section">
      <question name="Bogus question" answer_scheme_id="1" />
    </questions>
  </sections>

I'm processing them in the order they appear in the document with
this:

 <xsl:apply-templates select="//sections/questions | //sections/instructions | //sections/comments"/>

The problem is that in the 'questions' template, I want to output the
position of that section without regard to other types of sections. In
other words, the first 'questions' section must be 'Section 1', even
if it is preceded by comments and instructions sections. Before I
added the comments and instructions, I was just doing this:

<xsl:template match="questions">
 <xsl:variable name="section" select="position()"/>

But in the above example, I'm outputting 'Section 2: Bogus Section'
where I want it to be Section 1. Is there a way to find the position
within the subset without changing the processing order?

Thanks,
John Sands



 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.