HighDots Forums  

Need XLST for this XML

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Need XLST for this XML in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mr. Clean
 
Posts: n/a

Default Need XLST for this XML - 08-18-2003 , 11:19 AM






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???

Reply With Quote
  #2  
Old   
Mikko Rantalainen
 
Posts: n/a

Default Re: Need XLST for this XML - 08-18-2003 , 01:54 PM






Mr. Clean wrote:
Quote:
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



Reply With Quote
  #3  
Old   
Johannes Koch
 
Posts: n/a

Default Re: Need XLST for this XML - 08-19-2003 , 03:03 AM



Mikko Rantalainen wrote:
Quote:
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.)



Reply With Quote
Reply




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.