|
Subject: Re: [xsl] Re: XSL-List Digest V3 #915 From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Sun, 15 Jul 2001 08:48:32 +0100 |
Hi Alexey,
> I need to restructure the document, i.e. the file
>
> <div name="1">
> <div name="1.1">
> </div>
> <div name="1.2">
> <div name="1.3">
> </div>
> </div>
> </div>
>
> to the normal form
>
> <div name="1">
> <div name="1.1">
> </div>
> <div name="1.2">
> </div>
> <div name="1.3">
> </div>
> </div>
I guess that you're using the name of the div to give the depth that
it should be at? You can find out the level of a div by looking at the
length of the name once you extract all the numbers (i.e. how many .s
there are in it):
string-length(translate(@name, '1234567890', ''))
Within a template that matches a div, I think you want to apply
templates to those descendant div elements whose name contains one
more . than this div element:
<xsl:variable name="digits" select="'1234567890'" />
<xsl:template match="div">
<xsl:variable name="level"
select="string-length(translate(@name, $digits, ''))" />
<div name="{@name}">
<xsl:apply-templates
select="div[string-length(translate(@name, $digits, '')) =
$level + 1]" />
</div>
</xsl:template>
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 -> |
|---|---|---|
| [xsl] Re: XSL-List Digest V3 #915, Alexey Skoblikov | Thread | [xsl] Re: Re: recursive template gr, Dimitre Novatchev |
| Re: [xsl] Nestled <xsl:choose>, Trevor Nash | Date | Re: [xsl] recursive template grabbi, Jeni Tennison |
| Month |