Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 24th, 2006, 09:35 AM
graf.laszlo@axis.hu
Guest
 
Posts: n/a
Default modulo

Hi all,

I have an XML structure wich looks like this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<a>
<b1 id="1">
<c1>C11</c1>
<c2>C12</c2>
...
</b1>
<b1 id="2">
<c1>C21</c1>
<c2>C22</c2>
...
</b1>
<b1 id="3">
<c1>C31</c1>
<c2>C32</c2>
...
</b1>
...
<b1 id="m">
<c1>C(m)1</c1>
<c2>C(m)2</c2>
...
</b1>
</a>
where the number of 'b' tags is greater than 3 and the number of 'c'
tags is greater than 2.
How can I transform the XML data using XSLT to get the following HTML
table structure?

<table>
<tr>
<td>
<table>
<tr>
<th>b1 (id=1)</th>
<td>c1 : C11</td>
<td>c2 : C12</td>
...
</tr>
</table>
</td>
<td>
<table>
<tr>
<th>b1 (id=2)</th>
<td>c1 : C21</td>
<td>c2 : C22</td>
...
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<th>b1 (id=3)</th>
<td>c1 : C31</td>
<td>c2 : C32</td>
...
</tr>
</table>
</td>
<td>
<table>
<tr>
<th>b1 (id=4)</th>
<td>c1 : C41</td>
<td>c2 : C42</td>
...
</tr>
</table>
</td>
</tr>
...
</table>

Thank you,
Laci

  #2  
Old July 24th, 2006, 12:05 PM
George Bina
Guest
 
Posts: n/a
Default Re: modulo

Hi Laci,

I cannot see any difficulty here, something as simple as the stylesheet
below will get you the desired output:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>

<xsl:template match="a">
<table>
<tr><xsl:apply-templates/></tr>
</table>
</xsl:template>
<xsl:template match="b1">
<td>
<table>
<tr>
<th><xsl:value-of select="name()"/(id=<xsl:value-of
select="@id"/>)</th>
<xsl:apply-templates/>
</tr>
</table>
</td>
</xsl:template>
<xsl:template match="c1|c2">
<td><xsl:value-of select="name()"/: <xsl:value-of
select="."/></td>
</xsl:template>
</xsl:stylesheet>

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

graf.laszlo@axis.hu wrote:
Quote:
Hi all,
>
I have an XML structure wich looks like this:
>
<?xml version="1.0" encoding="ISO-8859-1"?>
<a>
<b1 id="1">
<c1>C11</c1>
<c2>C12</c2>
...
</b1>
<b1 id="2">
<c1>C21</c1>
<c2>C22</c2>
...
</b1>
<b1 id="3">
<c1>C31</c1>
<c2>C32</c2>
...
</b1>
...
<b1 id="m">
<c1>C(m)1</c1>
<c2>C(m)2</c2>
...
</b1>
</a>
where the number of 'b' tags is greater than 3 and the number of 'c'
tags is greater than 2.
How can I transform the XML data using XSLT to get the following HTML
table structure?
>
<table>
<tr>
<td>
<table>
<tr>
<th>b1 (id=1)</th>
<td>c1 : C11</td>
<td>c2 : C12</td>
...
</tr>
</table>
</td>
<td>
<table>
<tr>
<th>b1 (id=2)</th>
<td>c1 : C21</td>
<td>c2 : C22</td>
...
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<th>b1 (id=3)</th>
<td>c1 : C31</td>
<td>c2 : C32</td>
...
</tr>
</table>
</td>
<td>
<table>
<tr>
<th>b1 (id=4)</th>
<td>c1 : C41</td>
<td>c2 : C42</td>
...
</tr>
</table>
</td>
</tr>
...
</table>
>
Thank you,
Laci
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles