This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Re: XSL-List Digest V3 #915
- To: Alexey Skoblikov <leshakk at pochtamt dot ru>
- Subject: Re: [xsl] Re: XSL-List Digest V3 #915
- From: Jeni Tennison <mail at jenitennison dot com>
- Date: Sun, 15 Jul 2001 08:48:32 +0100
- CC: XSL-List Digest <xsl-list at lists dot mulberrytech dot com>
- Organization: Jeni Tennison Consulting Ltd
- References: <200107140630.CAA14418@biglist.com><414450389.20010714115220@pochtamt.ru>
- Reply-To: xsl-list at lists dot mulberrytech dot com
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