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

Re: nested XML using xslt

Subject: Re: nested XML using xslt
From: Michael Dykman <mdykman@xxxxxxxxx>
Date: Thu, 23 Jul 2009 18:56:37 -0400
Re:  nested XML using xslt
It would be helpful if you shared your input XML, along with the
stylesheet and the output example, but I think I see what you are
going for..  Here is a fragment demonstrating the pattern I think you
need.

<xsl:template match="list1">
  <list1>
    <text>
       <xsl:value-of select="text"/>
    </text>
    <xsl:apply-templates select="list2/text"/>

  </list1>
</xsl:template>

 - michael dykman

On Thu, Jul 23, 2009 at 6:38 PM, kurps s<kurpss@xxxxxxxxx> wrote:
> Hi
>
> I am trying to create a nested XML list using xslt.The XL should have 4
levels.
>
> <list1>
> <text></text>
> <list2>
> <text></text>
> <list3>
> <text></text>
>
> <list4>
> <text></text>
>
> </list4>
>
> </list3>
> <list3>
> <text></text>
> </list3>
> <list3>
> <text></text>
> </list3>
> </list2>
> <list2>
> <text></text>
> </list2>
> </list1>
>
> Now there can be any number of list elements within each other. Like
> in the example abbove, there can be multiple <list3> within <list2>.
> The trick is to make sure that the first list3 gets closed after
> <list4> , and a new <list3> opens after the first closes.
>
> My XSLT program is just creating a continuous list instead of counting
> the levels.
> <xsl:template match="list1/text">
>                <list1>
>                        <text>
>                                                                      
 <xsl:value-of select="."/>
>                                                        </text>
>                        <xsl:choose>
>
>                        <xsl:apply-templates select="list2/text"/>
>
>                </list1>
>        </xsl:template>
>        <xsl:template match="list2/text">
>                <list2>
>                        <text>
>
>                                        <xsl:value-of select="."/>
>
>                        </text>
> <xsl:apply-templates select=list3/text/>
>                </list2>
>
>        </xsl:template>
>        <xsl:template match="list3/text">
>                <list3>
>                        <text>
>
>                                        <xsl:value-of select="."/>
>
>                        </text>
> <xsl:apply-templates select=list4/text/>
>
>                </list3>
>        </xsl:template>
>        <xsl:template match="list4/text">
>                <list4>
>                        <text>
>
>                                        <xsl:value-of select="."/>
>
>                        </text>
>                </list4>
>        </xsl:template>
>
>
> Can anyone help me here?
>
> Thanks in advance for your help.
>
>



--
 - michael dykman
 - mdykman@xxxxxxxxx

 - All models are wrong.  Some models are useful.

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.