xsl-list
[Top] [All Lists]

Re: Converting Flat XML to Hierarchical structure using xsl.

2005-11-14 03:34:54
Thanks for the suggestion..

I want to get the output in Hierarchical order using
the text().

I have modified the XSL, it follows:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="xml"/>
<xsl:template match="office">
<layout>
 <xsl:apply-templates
select="ordered-list/list-item"/>
</layout>                               
</xsl:template>

<xsl:template match="list-item">
 <xsl:choose>
   <xsl:when test="./h">
       <xsl:element name="{./h}">
         <xsl:apply-templates
select="ordered-list/list-item"/>
        </xsl:element>
   </xsl:when>
   <xsl:otherwise>
        <xsl:apply-templates
select="ordered-list/list-item"/>
   </xsl:otherwise>
  </xsl:choose> 
</xsl:template>
</xsl:stylesheet>

I got the following XML:
<?xml version="1.0" encoding="UTF-8"?>
<layout>
        <Application/>
        <Processgroup/>
        <Process/>
        <PanelName/>
</layout>

But my expected output is:
<layout>
        <Application/>
          <Processgroup>
            <Process>
              <PanelName/>
            </Process>
         </Processgroup>
        </Application>
</layout>

Regards,
Raj
--- Ragulf Pickaxe <ragulf(_dot_)pickaxe(_at_)gmail(_dot_)com> wrote:

Raj,

   <xsl:apply-templates
select="ordered-list/list-item/"/>

If you want to select list-item elements, the above
should be:
<xsl:apply-templates
select="ordered-list/list-item"/> (that is,
without the trailing /).

From the output I expect that you get the default
templates. That
would then be why you get the text() elements in the
output.

The match="ordered-list/list-item/" should be
match="ordered-list/list-item".
And in this example, you could as well have
match="list-item".

Ragulf Pickaxe :-)


--~------------------------------------------------------------------
XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





                
__________________________________ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--