473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

Jul 24 '06 #1
1 1321
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

gr*********@axis.hu 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
Jul 24 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Griff | last post by:
Test program: =============================================================== t = 5.8 interval = 2.0 while t < 6.1: print "%s mod %s = %s " % (t, interval, t % interval ) t += 0.1...
3
by: Tjerk Wolterink | last post by:
I posted my problem earlier, but i simplified the examples, and i know what the cause of the problem is, but i dont know the solution, my xml file: <?xml version="1.0" encoding="ISO-8859-1"?>...
1
by: jt | last post by:
Looking up into Crypto.PublicKey.RSA, I see there is a computed value named "u" for which I can't see the use. The value of "u" is the inverse of p modulo q, in the code: obj.u =...
10
by: john blackburn | last post by:
Hi, I am trying to get an extremely simple character string encryption function to work using modulo 10 arithmetic. void ccencode(UNSIGNED8* pattern) { UNSIGNED8 key = CCKEY; UNSIGNED8...
2
by: Alexander | last post by:
I played a little bit with modulo cause I wanted to implement a small parser for functions as I stumbled over a calculation error. First I thought the reason might be a type conversion I did...
11
by: Ben Blank | last post by:
I have a loop which iterates over an array in a particular order: for (j = 0; j < 16; j++) T = ...; The loop proceeds normally for j = 0 through j = 4, but gives an IndexOutOfRangeException at...
12
by: Chadwick Boggs | last post by:
I need to perform modulo operations on extremely large numbers. The % operator is giving me number out of range errors and the mod(x, y) function simply seems to return the wrong results. Also,...
4
by: inkexit | last post by:
I'm writing a basic piece of software that will tell me how many shares of stock I can buy if the shares cost X each and I have Y to spend. I have it coded as: int main() { float price,...
5
by: shumaker | last post by:
The VS help files list % as the modulo operator, but I read in another post that someone said it was the remainder operator. I'm getting -2 % 64 = -2, but I need 62 or -62, because I am trying...
3
by: Michel Walsh | last post by:
Mathematically, r = a modulo b (b being the divisor) is defined such that if b <0, and if r <>0, its sign should be the sign of b. C# does not follow this definition. int indx = -1;...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.