Lisa,
thanks for that. I think that's the path I'll need to take (Pun
intended).w
Cheers,
Nick
On 21/12/2005, at 6:19 AM, Xia Li wrote:
I think you need a way to select the sequence of <Step> nodes under
each
<StepList> so that you can get the position of a <Step> node in the
sequence via position() function, and then call the template on the
node
<Field>.
Something like this,
<xsl:for-each select=".//StepList">
<xsl:for-each select="./Step">
<xsl:variable name="pos"><xsl:value-of
select="position()"/></xsl:variable>
<xsl:apply-templates
select=".//Chunk[(_at_)type='FieldRef']/Field">
<xsl:with-param name="pos"><xsl:value-of
select="$pos"/></xsl:with-param>
</xsl:apply-templates>
</xsl:for-each>
</xsl:for-each>
<xsl:template match="Field">
<xsl:param name="pos"></xsl:param>
<xsl:value-of select="ancestor::Step[1]/@name" />
<xsl:value-of select="$pos"/>
</xsl:template>
In this instruction,
<xsl:value-of select="ancestor::Step[1]/
@name" />
the right side expression of the "ancestor::Step[1]/@name" produces
the
attribute node of the nodes selected by the "ancestor::Step[1]", while
the right side expression of the expression
"ancestor::Step[1]/position()" yields the integers instead of nodes. I
think that's why the processor throws exception on the instruction
<xsl:value-of select="ancestor::Step[1]/position()"/>
Lisa
-----Original Message-----
From: Nicholas Orr [mailto:nick(_at_)goya(_dot_)com(_dot_)au]
Sent: Monday, December 19, 2005 6:40 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Finding the position of an ancestor
I was wondering if someone can help me work out a position issue I'm
struggling with.
I've got some XML that has is in it :
<FMPReport>
<File>
<ScriptCatalog>
<Script>
<StepList>
<Step>
...
</Step>
<Step>
...
</Step>
<Step>
...
</Step>
<Step id="1" name="Perform Script" enable="True">
<Value>
<DisplayCalculation>
<Chunk type="FieldRef">
<Field id="32867" name="cPref
Server Temp Folder" table="gPrefs" />
Then in the xslt I run a for each loop
<xsl:for-each select="/FMPReport/File/
descendant::Chunk[(_at_)type='FieldRef']/Field">
<xsl:call-template name="RESULTSET" />
</xsl:for-each>
which works fine, and I can get the data I need. I grab the name
from the Step using :
<xsl:value-of select="ancestor::Step[1]/@name" />
But how do I grab the step number? For example I want to know that
this is step 4 in this script, by counting how many <Step> elements
there are in the current <Script> element. I thought it would just
be :
<xsl:value-of select="ancestor::Step[1]/position
()"/>
But that doesn't work, and gives me a parsing error. Am I maybe
going about the whole thing wrong?
Thanks,
Nick
--~------------------------------------------------------------------
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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
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(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--