|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Converting Flat XML to Hierarchical structure using xs
Hello,
I want to convert the some Flat XML content to
hierachical structure..
I have the following xml file:
<?xml version="1.0" encoding="UTF-8"?>
<office>
<ordered-list style-name="L1">
<list-item>
<h style-name="P1" level="1">Application</h>
</list-item>
</ordered-list>
<ordered-list style-name="L2">
<list-item>
<ordered-list>
<list-item>
<h style-name="P3" level="2">Processgroup</h>
</list-item>
</ordered-list>
</list-item>
</ordered-list>
<ordered-list style-name="L3">
<list-item>
<ordered-list>
<list-item>
<ordered-list>
<list-item>
<h style-name="P4" level="3">Process</h>
</list-item>
</ordered-list>
</list-item>
</ordered-list>
</list-item>
</ordered-list>
<ordered-list style-name="L3"
continue-numbering="true">
<list-item>
<ordered-list continue-numbering="true">
<list-item>
<ordered-list continue-numbering="true">
<list-item>
<ordered-list continue-numbering="true">
<list-item>
<h style-name="P5" level="4">PanelName</h>
</list-item>
</ordered-list>
</list-item>
</ordered-list>
</list-item>
</ordered-list>
</list-item>
</ordered-list>
</office>
My expected output structure is
---------------------------------
<layout>
<Application>
<Processgroup>
<Process>
<PanelName>
</PanelName>
</Process>
</Processgroup>
</Application>
</layout>
I am using the following XSL to get the above output:
<?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="ordered-list/list-item/">
<xsl:if test="h">
<xsl:element name="h">
<xsl:apply-templates
select="ordered-list/list-item"/>
</xsl:element>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
It gives the following output:
<?xml version="1.0" encoding="UTF-8"?>
<layout>
Application
Processgroup
Process
PanelName
</layout>
How to solve this.. any help?
Thanks
Regards,
Raj
__________________________________
Start your day with Yahoo! - Make it your home page!
http://www.yahoo.com/r/hs
|
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








