Forum Moderators: open
I have an .xml file that has nested tables, when I view the file in IE, it looks like the way I want it to. However, when I try to view in html,the only way it will work is if I have only 1 nested table.
Any ideas on what I am doing wrong?
This is the xml part.
<?xml version="1.0"?>
<sport>
<league>
<team>
<name></name>
<number></number>
<year></year>
</team>
</league>
</sport>
Not sure what transforming means, but this is the html code that I have. Bascially I am trying to have the XML presented on this html page.
This is the html, hope it makes it clearly on what I am trying to do. Thanks for the help
<xml id="filename" src="filename.xml"></xml>
<table cellpadding=6 cellspacing=6 border="1" datasrc="#filename">
<thead>
<tr bgcolor=silver>
<th>league</th>
<th>team</th>
<th>name</th>
<th>number</th>
<th>year</th>
</tr>
</thead>
<tr>
<td><div dataFld="league"></div></td>
<td><div dataFld="team"></div></td>
<td><div dataFld="name"></div></td>
<td><div dataFld="number"></div></td>
<td><div dataFld="year"></div></td>
</table>
- if you perhaps could provide a simplified (but not too simplified) example for your xml-file, as eg. 'x.xml':
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xml" href="x.xsl"?>
<sport>
<league>
<lnam>champions</lnam>
<team>
<tnam>superteam</tnam>
<pnam>miller</pnam>
<tnum>33</tnum>
<year>2005</year>
</team>
</league>
<league>
<lnam>losers</lnam>
<team>
<tnam>subteam</tnam>
<pnam>filler</pnam>
<tnum>32</tnum>
<year>2004</year>
</team>
</league>
</sport>
- and if you also could provide an example for the wanted output, eg:
league team name number year
champions superteam miller 33 2005
losers subteam filler 32 2004
- then maybe one of the forum members could explain to you that:
to generate the wanted output you will have to
provide an xsl-file, eg. 'x.xsl' which is called by the second line of 'x.xml' when you click on 'x.xml'.
this file would look similar to the following:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/><xsl:template match="/">
<html><head><title>x.xml transformed by x.xsl</title></head>
<body>
<table cellpadding="6" cellspacing="6" border="1">
<thead>
<tr bgcolor="silver">
<th>league</th>
<th>team</th>
<th>name</th>
<th>number</th>
<th>year</th>
</tr>
</thead>
<xsl:apply-templates/>
</table>
</body></html>
</xsl:template>
<xsl:template match="league">
<tr>
<td><xsl:value-of select=".//lnam"/></td>
<td><xsl:value-of select=".//tnam"/></td>
<td><xsl:value-of select=".//pnam"/></td>
<td><xsl:value-of select=".//tnum"/></td>
<td><xsl:value-of select=".//year"/></td>
</tr>
</xsl:template>
</xsl:stylesheet>
then you would have a kind of starting point.
good luck!