|
Subject: Re: [xsl] building hierarchy from path string From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Thu, 6 Dec 2001 00:29:47 +0000 |
Hi John-Mason,
> <xsl:key name="children" match="node" use="substring(@path, 1,
> @depth * $tierChars)" />
Unfortunately you can't use variables in keys :( [It's supposed to
avoid circular definitions - variables defined using keys using
variables - but actually it's just a pain in the neck.]
But since that value's coming from the source document, you can do:
<xsl:key name="children" match="node"
use="substring(@path, 1, @depth *
/tree/descriptor/@chars-per-tier)" />
And you can use the variable later on in the document as you are
doing.
If you were passing it in as a parameter it would be more difficult -
the way out would be to substitute the uses of the key for the full
horror of the paths:
<xsl:template match="tree">
<tree>
<xsl:apply-templates
select="node[not(substring(@path, 1, @depth * $tierChars))]" />
</tree>
</xsl:template>
<xsl:template match="node">
<node name="{@name}">
<xsl:apply-templates
select="../node[substring(@path, 1, @depth * $tierChars) =
substring(current()/@path, 1,
(@depth + 1) * $tierChars))">
<xsl:sort select="@path" />
</xsl:apply-templates>
</node>
</xsl:template>
But this is a lot less efficient than using the key and should be
avoided if possible.
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] building hierarchy from p, John-Mason P. Shacke | Thread | Re: [xsl] building hierarchy from p, John-Mason P. Shacke |
| [xsl] Prining Hex04 character using, Avula, Raj | Date | Re: [xsl] building hierarchy from p, John-Mason P. Shacke |
| Month |