Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > modulo

Reply
Thread Tools

modulo

 
 
graf.laszlo@axis.hu
Guest
Posts: n/a
 
      07-24-2006
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

 
Reply With Quote
 
 
 
 
George Bina
Guest
Posts: n/a
 
      07-24-2006
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"
xmlnssl="http://www.w3.org/1999/XSL/Transform">
<xslutput 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

http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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


 
Reply With Quote
 
 
 
Reply

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[xsl] sort & modulo Tjerk Wolterink XML 3 04-22-2005 12:49 PM
Java ME modulo method ?? 900390d@acadiau.ca Java 1 05-19-2004 11:56 PM
Fast Division/Modulo Operation silentlights C Programming 8 04-23-2004 12:21 PM
Problems using modulo Griff Python 5 04-20-2004 12:20 PM
General modulo-question Christian Kruggel Java 1 07-07-2003 05:44 PM



Advertisments