Sylvia (archive)
Usenet Archive
- Joined
- Jan 8, 2004
- Messages
- 10
- Reaction score
- 0
Hi,
I'm trying to render a XML structure to HTML using XSLT. My XML describe the header of a table with a complex and not linear structure. The first row of the header table always contains the ServiceName (attribute name), under I have to show all the other fields with correct structure. Can you help me to write XSLT document?
My XML doc:
<?xml version="1.0" encoding="UTF-8"?>
<data>
<Service depth="6" name="service1" totalDepth="2">
<Field depth="0" name="1.1"/>
<Field depth="0" name="1.2"/>
<Field depth="0" name="1.3"/>
<Field depth="0" name="1.4"/>
<Field depth="0" name="1.5"/>
<Field depth="0" name="1.6"/>
</Service>
<Service depth="8" name="service2" totalDepth="4">
<Field depth="4" name="2.1">
<Field depth="4" name="2.1.1">
<Field depth="0" name="2.1.1.1"/>
<Field depth="0" name="2.1.1.2"/>
<Field depth="0" name="2.1.1.3"/>
<Field depth="0" name="2.1.1.4"/>
</Field>
<Field depth="4" name="2.1.2">
<Field depth="0" name="2.1.2.1"/>
<Field depth="0" name="2.1.2.2"/>
<Field depth="0" name="2.1.2.3."/>
<Field depth="0" name="2.1.2.4"/>
</Field>
<Field depth="4" name="2.1.3.">
<Field depth="0" name="2.1.3.1"/>
<Field depth="0" name="2.1.3.2"/>
<Field depth="0" name="2.1.3.3"/>
<Field depth="0" name="2.1.2.4"/>
</Field>
<Field depth="4" name="2.1.4">
<Field depth="0" name="2.1.4.1"/>
<Field depth="0" name="2.1.4.2"/>
<Field depth="0" name="2.1.4.3"/>
<Field depth="0" name="2.1.4.4"/>
</Field>
</Field>
<Field depth="4" name="2.2">
<Field depth="0" name="2.2.1"/>
<Field depth="0" name="2.2.2"/>
<Field depth="0" name="2.2.3"/>
<Field depth="0" name="2.2.4"/>
</Field>
</Service>
</data>
This is what I want to obtain:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>My Doc</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <table border="1" cellpadding="0" cellspacing="0"> <tr align="center"> <td colspan="6">service1</td> <td colspan="20">service2</td> </tr> <tr> <td rowspan="3">1.1</td> <td rowspan="3">1.2</td> <td rowspan="3">1.3</td> <td rowspan="3">1.4</td> <td rowspan="3">1.5</td> <td rowspan="3">1.6</td> <td colspan="16">2.1</td> <td colspan="4" rowspan="2">2.2</td> </tr> <tr> <td colspan="4">2.1.1</td> <td colspan="4">2.1.2</td> <td colspan="4">2.1.3</td> <td colspan="4">2.1.4</td> </tr> <tr> <td>2.1.1.1</td> <td>2.1.1.2</td> <td>2.1.1.3</td> <td>2.1.1.4</td> <td>2.1.2.1</td> <td>2.1.2.2</td> <td>2.1.2.3.</td> <td>2.1.2.4</td> <td>2.1.3.1</td> <td>2.1.3.2</td> <td>2.1.3.3</td> <td>2.1.2.4</td> <td>2.1.4.1</td> <td>2.1.4.2</td> <td>2.1.4.3</td> <td>2.1.4.4</td> <td>2.2.1</td> <td>2.2.2</td> <td>2.2.3</td> <td>2.2.4</td> </tr> </table> </body> </html>
Thanks.
I'm trying to render a XML structure to HTML using XSLT. My XML describe the header of a table with a complex and not linear structure. The first row of the header table always contains the ServiceName (attribute name), under I have to show all the other fields with correct structure. Can you help me to write XSLT document?
My XML doc:
<?xml version="1.0" encoding="UTF-8"?>
<data>
<Service depth="6" name="service1" totalDepth="2">
<Field depth="0" name="1.1"/>
<Field depth="0" name="1.2"/>
<Field depth="0" name="1.3"/>
<Field depth="0" name="1.4"/>
<Field depth="0" name="1.5"/>
<Field depth="0" name="1.6"/>
</Service>
<Service depth="8" name="service2" totalDepth="4">
<Field depth="4" name="2.1">
<Field depth="4" name="2.1.1">
<Field depth="0" name="2.1.1.1"/>
<Field depth="0" name="2.1.1.2"/>
<Field depth="0" name="2.1.1.3"/>
<Field depth="0" name="2.1.1.4"/>
</Field>
<Field depth="4" name="2.1.2">
<Field depth="0" name="2.1.2.1"/>
<Field depth="0" name="2.1.2.2"/>
<Field depth="0" name="2.1.2.3."/>
<Field depth="0" name="2.1.2.4"/>
</Field>
<Field depth="4" name="2.1.3.">
<Field depth="0" name="2.1.3.1"/>
<Field depth="0" name="2.1.3.2"/>
<Field depth="0" name="2.1.3.3"/>
<Field depth="0" name="2.1.2.4"/>
</Field>
<Field depth="4" name="2.1.4">
<Field depth="0" name="2.1.4.1"/>
<Field depth="0" name="2.1.4.2"/>
<Field depth="0" name="2.1.4.3"/>
<Field depth="0" name="2.1.4.4"/>
</Field>
</Field>
<Field depth="4" name="2.2">
<Field depth="0" name="2.2.1"/>
<Field depth="0" name="2.2.2"/>
<Field depth="0" name="2.2.3"/>
<Field depth="0" name="2.2.4"/>
</Field>
</Service>
</data>
This is what I want to obtain:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>My Doc</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <table border="1" cellpadding="0" cellspacing="0"> <tr align="center"> <td colspan="6">service1</td> <td colspan="20">service2</td> </tr> <tr> <td rowspan="3">1.1</td> <td rowspan="3">1.2</td> <td rowspan="3">1.3</td> <td rowspan="3">1.4</td> <td rowspan="3">1.5</td> <td rowspan="3">1.6</td> <td colspan="16">2.1</td> <td colspan="4" rowspan="2">2.2</td> </tr> <tr> <td colspan="4">2.1.1</td> <td colspan="4">2.1.2</td> <td colspan="4">2.1.3</td> <td colspan="4">2.1.4</td> </tr> <tr> <td>2.1.1.1</td> <td>2.1.1.2</td> <td>2.1.1.3</td> <td>2.1.1.4</td> <td>2.1.2.1</td> <td>2.1.2.2</td> <td>2.1.2.3.</td> <td>2.1.2.4</td> <td>2.1.3.1</td> <td>2.1.3.2</td> <td>2.1.3.3</td> <td>2.1.2.4</td> <td>2.1.4.1</td> <td>2.1.4.2</td> <td>2.1.4.3</td> <td>2.1.4.4</td> <td>2.2.1</td> <td>2.2.2</td> <td>2.2.3</td> <td>2.2.4</td> </tr> </table> </body> </html>
Thanks.