XML/XSL help

Posted:
in Genius Bar edited January 2014
Any XML/XSL gurus out there?



I have this XML file comprised of "packages". Each package contains a Company Name, Company Address and the Components of the package. However, some of those components are made up of their own components (basically they are packages themselves). Each sub-component will also have a company name, address and its own components. Some of THOSE can have sub-components as well!



So my problem is, I need to create an XSL template to transform this into an HTML table.



Here is a sample of the XML:

Code:




<package>

<company>Company Name</company>

<address>Company Address</address>

<component>Component Name 1</component>

<component>Component Name 2</component>

<component>Component Name 3</component>

<component>Component Name

<company>Company Name</company>

<address>Company Address</address>

<component> Sub Component 1 </component>

<component> Sub Component 2 </component>

</component>

<component>Component Name 4</component>

<component>Component Name 5</component>

</package>







Here is how I want the HTML table to look:

Code:




Package - Company Name, Company Address

Component 1

Component 2

Component 3 - Company Name, Company Address

Sub Component 1

Sub Component 2

Component 4

Component 5







The biggest problem is to somehow do this recursively. Because I don't know how many levels deep the sub components can go. I'm thinking I need to do something with:



<xsl: for-each select="component">



But I think I keep getting the syntax wrong.



Anyone have any ideas?



THanks!
Sign In or Register to comment.