473,404 Members | 2,179 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,404 software developers and data experts.

Need XLST for this XML

Very new to XML style sheets and need some help getting this XML:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE CDSLogger SYSTEM "CDSLogger.dtd">
<CDSLogger>
<ErrorObject>
<BatchName>This is the first batch</BatchName>
<ErrorCode>12904</ErrorCode>
<Success>True</Success>
</ErrorObject>
<ErrorObject>
<BatchName>This is the second batch</BatchName>
<ErrorCode>16818</ErrorCode>
<Success>True</Success>
</ErrorObject>
<ErrorObject>
<BatchName>This is the third batch</BatchName>
<ErrorCode>14105</ErrorCode>
<Success>False</Success>
</ErrorObject>
<ErrorObject>
<BatchName>This is the fourth batch</BatchName>
<ErrorCode>19017</ErrorCode>
<Success>True</Success>
</ErrorObject>
<ErrorObject>
<BatchName>This is the fifth batch</BatchName>
<ErrorCode>12566</ErrorCode>
<Success>False</Success>
</ErrorObject>
</CDSLogger>

to look like this HTML:

<table cellspacing="0" cellpadding="0" height="100%">
<colgroup>
<colgroup span=3>
<thead>
<tr>
<th scope=colgroup colspan=3>CDS Logger Error Messeges</th>
</tr>
<tr>
<th scope=col>Batch Name</th>
<th scope=col>Error Code</th>
<th scope=col>Success</th>
</tr>
</thead>
<tbody>
<tr>
<td>This is the first batch</td>
<td>12904</td>
<td>True</td>
</tr>
<tr>
<td>This is the second batch</td>
<td>16818</td>
<td>True</td>
</tr>
<tr>
<td>This is the third batch</td>
<td>14105</td>
<td>False</td>
</tr>
<tr>
<td>This is the fourth batch</td>
<td>19017</td>
<td>True</td>
</tr>
<tr>
<td>This is the fifth batch</td>
<td>12566</td>
<td>False</td>
</tr>
</tbody>
</table>

Anyone want to give me a hand???
Jul 20 '05 #1
3 2209
In article <MP************************@news-server.austin.rr.com>,
mr*****@protctorandgamble.com says...
Very new to XML style sheets and need some help getting this XML:

Go it...

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<table cellspacing="0" cellpadding="0" width="300">
<thead>
<tr>
<th scope="colgroup" colspan="3">CDS Logger Error Messages</th>
</tr>
<tr>
<th scope="col" width="100"><div align="left">Batch Name</div></th>
<th scope="col" width="100"><div align="left">Error Code</div></th>
<th scope="col" width="100"><div align="left">Success</div></th>
</tr>
</thead>
<tbody>
<xsl:for-each select="CDSLogger/ErrorObject">
<!-- Sorts by ErrorCode-->
<xsl:sort select="ErrorCode"/>
<tr height="15">
<td height="15" width="100"><div align="left"><xsl:value-of
select="BatchName" /></div></td>
<td height="15" width="100"><div align="left"><xsl:value-of
select="ErrorCode" /></div></td>
<td height="15" width="100"><div align="left"><xsl:value-of
select="Success" /></div></td>
</tr>
</xsl:for-each>
</tbody>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Jul 20 '05 #2
Mr. Clean wrote:
Very new to XML style sheets and need some help getting this XML:
[bunch of XML source removed]
to look like this HTML:
[lots of HTML code removed]

Anyone want to give me a hand???


Where's the results of work you've done this far? Surely you don't
expect us to do your work, do you? Hopefully this isn't some homework
you're too lazy to do yourself....

Here's something I won't bother testing. Perhaps it helps you, perhaps
it doesn't. By the way, XSTL is really for XML->XML transforms so you
cannot easily generate HTML, only XHTML [fragments]. And the
pseudo-(X)HTML code you provided was broken but I didn't bother fixing
it either.

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- Copyright (c) 2003 Mikko Rantalainen, this
code can be distributed under GPL.
TODO: fix the colgroup element(s).
-->
<xsl:template match="/">
<table>
<colgroup>
<colgroup span="3">
<thead>
<tr>
<th scope="colgroup" colspan="3">CDS Logger Error Messeges</th>
</tr>
<tr>
<th scope="col">Batch Name</th>
<th scope="col">Error Code</th>
<th scope="col">Success</th>
</tr>
</thead>
<tbody>

<xsl:apply-templates select="//ErrorObject">
</xsl:apply-templates>

</tbody>
</table>
</xsl:template><!-- match / -->

<xsl:template match="ErrorObject">
<tr>
<td><xsl:value-of select="BatchName" /></td>
<td><xsl:value-of select="ErrorCode" /></td>
<td><xsl:value-of select="Success" /></td>
</tr>
</xsl:template><!-- match ErrorObject -->

<xsl:template match="*">
<div>UNKNOWN: <xsl:value-of select="." /></div>
</xsl:template>

</xsl:stylesheet>

--
Mikko

Jul 20 '05 #3
Mikko Rantalainen wrote:
By the way, XSTL is really for XML->XML transforms so you
cannot easily generate HTML, only XHTML [fragments].


Nope. XSLT 1.0 defines three output modes:
* XML
* HTML
* Text
--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)

Jul 20 '05 #4

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

Similar topics

4
by: Pascal Sartoretti | last post by:
Hello, I am looking for a formal definition of XSLT. Either a DTD or an XML Schema, whatever. Is there such a thing ? There is for instance one for XML Schema itself at...
1
by: Vital Lobachevsky | last post by:
Hi! I'm absolutely newbie with XSLT. Please, help me with this example. I have simple XML document like this: <skip /> <aaa> <link url="url1" /> <link url="url2" />
1
by: gsoftwares | last post by:
Hi, I have a XML string and I want to transform this xml with xsl to get a xml out put. I am trying this with java code, can any one point out where is the problem. XML file <ROWSET> <ROW...
3
by: Hai Nguyen | last post by:
I would like to know after transforming my datatables which store in dataset into XML form. Now I want to save it into a file and also create a XLST file to read it. How can I do that? Would you...
7
by: Roshawn Dawson | last post by:
Hi, I have an xslt file located in the root directory. It is used by an aspx pages in both the root directory and a subdirectory. But for some strange reason, the aspx page in the subdirectory...
1
by: Adrian | last post by:
Hi No sure if xlst is the correct choice! or if it is how I would use it from within a windows VB application! I had XML data help in an xmlelements object and I want to format the data and...
1
by: ad | last post by:
Hi, How can I use xlst to display a xml file in asp.net?
5
by: MD | last post by:
my database return the search result in the xml. I have about 100 fields with 10 records if i use the dom to parse in the browser with javascript takes about 30 seconds to generate the table with...
1
by: dave_kajinsky | last post by:
Hello all, I would like to do something with xlst, perhaps I can get help from this group? Here it goes: I've got 2 files: an ascii file and a file that identifies tokens in the ascii file. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.