[xsl] Finding position of a node relative to the root instead of the parent node

Subject: [xsl] Finding position of a node relative to the root instead of the parent node
From: "Cynthia DeLaria" <cdelaria@xxxxxxxxx>
Date: Mon, 22 Dec 2003 14:12:27 -0700
Good Day,
I have searched the xsl list unsuccessfully for an answer to this
question, although I'm sure something like this has been addressed. I
think I'm just not sure what to search on to find it.
I have the following xml snippet:
        <movie title="Charlie's Angles: Full
        <movie title="28 Days Later">Description</movie>
        <movie title="The Santa Clause 2">Description</movie>
        <movie title="Northfork" />
        <movie title="Rudy: The Rudy Giuliani Story" />
        <movie title="Russian Ark" />
Basically, in the fully-flushed out version of the XML, the <featured>
movies have images and full descriptions, while the <also_new> movies
have only a title and rating. What I need to do is find a way to find
the position of each <movie> node relative to the root, as I need to
create a "print the new releases" page that lists all new releases in
two columns. This is what I tried, but it gives me the position based on
the parent (i.e. <also_new> or <featured>) not relative to the root.
<xsl:stylesheet version="1.0"
<xsl:output method="html" encoding="ISO-8859-1" />
<xsl:template match="/nr">
<title>New Releases E-Newsletter</title>
<body bgcolor="#ffffff" text="#000000" link="#023f7e" alink="#ff0000"
Just print out this list.<br />
    <table width="100%">
    <xsl:variable name="thisMany"><xsl:value-of
select="(count(//*[name()='movie']) div 2)" /></xsl:variable>
      <td valign="top" width="50%" class="body2">
      <br />
      <xsl:for-each select="//movie[position() &lt;=
      <b><i><xsl:value-of select="./@title" /></i></b><br />
      <br />
      <td valign="top" width="50%" class="body2">
      <br />
      <xsl:for-each select="//*[name()='movie'][position() &gt;
      <b><i><xsl:value-of select="./@title" /></i></b><br />
      <br />
Is it possible to get the position relative to the root node? It seems
like this should be very simple, but all of the things I have tried have
not worked to produce the intended outcome.
Thank you!


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

Current Thread