[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Re: XSL-List Digest V3 #915

Subject: Re: Re: XSL-List Digest V3 #915
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Sun, 15 Jul 2001 08:48:32 +0100
xsl div name
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.