 |
 |
 |
Hello everyone,
can anyone please help me with the following problem?
My XML is like:
<root>
<series>
~~<entry>
~~~~<field1>AA1</field1>
~~~~<field2>
~~~~~~<blah1>BBB1</blah1>
~~~~~~<blah2>BBB2</blah2>
~~~~~~<blah3>
~~~~~~~~<other1>GGGR1</other1>
~~~~~~~~<other2>GGGR2</other1>
~~~~~~</blah3>
~~~~</field2>
~~~~<field3>
~~~~~~<blah1>CCC1</blah1>
~~~~~~<blah2>CCC2</blah2>
~~~~~~<blah3>
~~~~~~~~<other1>GGGR11</other1>
~~~~~~~~<other2>GGGR22</other2>
~~~~~~</blah3>
~~~~</field3>
~~</entry>
~~<entry>
~~~~<field1>AA2</field1>
~~~~<field2>BB2</field2>
~~~~<field3>CC2</field3>
~~</entry>
~~<entry>
~~~~<field1>AA3</field1>
~~~~<field2>BB3</field2>
~~~~<field3>CC3</field3>
~~</entry>
</series>
<series>
...
</series>
<series>
...
</series>
</root>
No now I'd like to have a HTML page so that:
- a series becomes a <table>
- an entry becomes a <tr>
- field1, field2, field3 become <th> and the values of those tags
become the <td>
---> so far so good, I've got coding which does that (listed below)
however only up to this level.
Now I need to find a way to handle the nested structures inside (and I
was thinking of <table> inside the <table>), so that (again) the tags
become table-headers (<th>) and the values besome <td>.
Do you have any idea of how to do that?
Most of all, it must be generic -> I do not have to know the names of
the tags.
<xsl:for-each select="/root/*">
<table>
<tr><xsl:for-each select="./*/*"> <!-- one loop for the first roe of
the table (names of tags) -->
<xsl:if test="count(parent::*/preceding-sibling::*) = 1"> <!--
print the names only once for the first row only -->
<td><xsl:value-of select="name()"/></td>
</xsl:if>
</xsl:for-each></tr>
<xsl:for-each select="./*"> <!-- another loop for the data in the
table (tags values) -->
<tr><xsl:for-each select="node()">
<td><xsl:value-of select="."/></td>
</xsl:for-each></tr>
</xsl:for-each>
</table>
</xsl:for-each>
Help is appreciated!
Hristo
|
 | 

|  |
These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.
|  |
| |
 |
 |
 |