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

Re: Add a level of structure?

Subject: Re: Add a level of structure?
From: "Sam D. Chuparkoff" <sdc@xxxxxxxxxx>
Date: Mon, 20 Jun 2005 03:39:42 -0700
specificcontent
On Mon, 2005-06-20 at 09:32 +0300, George Cristian Bina wrote:
> Hi Edmund,
> 
> You can use something like below:
> 
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
> version="2.0">
>    <xsl:output indent="yes"/>
>    <xsl:template match="a">
>      <foo>
>        <xsl:apply-templates/>
>      </foo>
>    </xsl:template>
>    <xsl:template match="b">
>      <bar>
>        <xsl:variable name="sortedCs">
>          <xsl:for-each select="c">
>            <xsl:sort select="c1" data-type="number"/>
>            <xsl:copy-of select="."/>
>          </xsl:for-each>
>        </xsl:variable>

George is right, you'll want to take two passes at those <c> s. After
that, you just need to go with:

       <baz>
         <x att="val" att2="val2"/>
         <y att="val" att2="val2"/>
         <xsl:apply-templates select="subsequence($sortedCs/*, 1, 3)"/>
       </baz>
       <baz>
         <q att="val" att2="val2"/>
         <r att="val" att2="val2"/>
         <xsl:apply-templates select="subsequence($sortedCs/*, 4, 3)"/>
       </baz>
       <baz>
         <g att="val" att2="val2"/>
         <h att="val" att2="val2"/>
         <xsl:apply-templates select="subsequence($sortedCs/*, 7, 3)"/>
       </baz>

>        <xsl:for-each select="$sortedCs/*">
>          <xsl:if test="position() mod 3 =1">
>            <baz>
>              <xsl:call-template name="specificContent">
>                <xsl:with-param name="pos" select="(position()-1) div 3"/>
>              </xsl:call-template>
>              <xsl:apply-templates select="."/>
>              <xsl:apply-templates select="following-sibling::c[1]"/>
>              <xsl:apply-templates select="following-sibling::c[2]"/>
>            </baz>
>          </xsl:if>
>        </xsl:for-each>
>      </bar>
>    </xsl:template>

But you'll probably want to do something like the above someday soon.

sdc

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.