|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Re: XSL-List Digest V3 #915
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








