Sir Pickaxe,
What you want is not
ancestor-or-self::node
but rather
ancestor-or-self::node()
You are presently asking for element nodes named node. Apparently you have
none of those. An easy error, but hard to catch.
Cheers,
Wendell
At 06:38 PM 4/22/2004, you wrote:
During a transformation, I want different Colours on some elemets
according to their position in the hierachy. Instead of a choose-when, I
have tried following:
<!-- Top of XSL document -->
<xsl:variable name="Colours" select="document('Colours.xml')/colours/colour"/>
<xsl:template match="/">
<xsl:copy-of select="$Colours"/> <!-- Gives back the whole -->
<xsl:value-of select="$Colours[2]"/> <!-- Gives back the value of the
second colour element -->
<xsl:apply-templates select="node"/>
</xsl:template>
<xsl:template match="node">
<xsl:value-of select="$Colours[count(ancestor-or-self::node)]"/> <!--
Gives nothing at all -->
<xsl:apply-template select="node"/>
</xsl:template>
In the template node, I have tried various things in the predicate, such
as [position()=count(ansestor-or-self::node)] and the like, but nothing
seems to work, except when I hardcode the value, which I obviously do not want.
What am I doing wrong here? I have absolutely no idea why this is not working.
======================================================================
Wendell Piez
mailto:wapiez(_at_)mulberrytech(_dot_)com
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
======================================================================