Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

XSLT position() not returning sequential values

843834Sep 10 2002 — edited Sep 10 2002
I'm having trouble with the XSLT position() function. I have the following snippet of XML:
<categories>
  <category id="6">
    <title>Alumni</title>
  </category>
  <category id="10">
    <title>Built Environment</title>
  </category>
  <category id="9">
    <title>Business</title>
  </category>
  <category id="81">
    <title>Caboolture</title>
  </category>
  <category id="41">
    <title>Corporate</title>
  </category>
  <category id="2">
    <title>Creative Industries</title>
  </category>
  <category id="61">
    <title>Cultural Precinct</title>
  </category>
  <category id="5">
    <title>Education</title>
  </category>
  <category id="7">
    <title>Engineering</title>
  </category>
  <category id="44">
    <title>Feature</title>
  </category>
  <category id="4">
    <title>Health</title>
  </category>
  <category id="43">
    <title>Humanities & Human Services</title>
  </category>
  <category id="42">
    <title>Information Technology</title>
  </category>
  <category id="8">
    <title>Law</title>
  </category>
  <category id="45">
    <title>Profile</title>
  </category>
  <category id="101">
    <title>Public</title>
  </category>
  <category id="21">
    <title>QUT Carseldine</title>
  </category>
  <category id="1">
    <title>Science</title>
  </category>
  <category id="3">
    <title>What's On</title>
  </category>
</categories>
and the following template to match each category element:
<xsl:template match="category">
  <tr>
    <td width="10" valign="top" background="graphics/mid_bracket.gif">&nbsp;</td>
    <td width="10" valign="top"><img alt="" width="10" height="15" border="0" src="/graphics/blank.gif" name="rollitem0_{position()}"/></td>
    <td width="160"><a href="/general/news-event-list.jsp?news-category-id={@id}" class="level3menu"  onMouseOut="MM_swapImgRestore()"  onMouseOver="MM_swapImage('rollitem0_{position()}','','graphics/arrow.gif',1)"><xsl:apply-templates/></a></td>
  </tr>
</xsl:template>
I would expect the position() function to return 1, 2, 3, 4...19 but it doesn't. It is returning 2, 4, 6, 8...36. Does anyone have any idea why this might be happening? Surely the position should return the position of the current element within its siblings. I can only think that it is counting blank text nodes between each category element. Sorry for the complex markup, I wanted to be sure I was giving a real-world example.

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 8 2002
Added on Sep 10 2002
5 comments
622 views