A
Andre-John Mas
Hi,
I have an XML document which looks as follows is:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="visitreport.xsl"?>
<VisitReport xmlns="http://reports.myco.com" xmlns:xsi="http://
www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://reports.myco.com xsd/
VisitReport.xsd">
<Visit>
<visitId>138146</visitId>
<date>2007-06-06</date>
</Visit>
this makes reference to both a style sheet and a schema ( I have
provided the XSL at the end ). what I find is that if I include the
'xmlns=' attribute to VisitReport the table header gets displayed, but
none of the data (tested with Firefox and IE). On the other hand if I
remove the attribute it displays properly. Can these appear together
or are they exclusive?
To provide a bit of context, I am wanting to provide an XML output by
my web site, in a such a way that it can be displayed by the web
browser in tabular form, or saved and imported by Excel. Providing the
stylesheet only approach the web page displays properly, but Excel
does not know what the data types are, but if I provide only the
'xmlns=' then Excel knows the data types, but it does not get rendered
by the web browser. Should I be generating two version of the XML
document depending on the use?
Andre
---- The XSL ----
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
<xsl
utput method="html" />
<xsl:template match="/VisitReport">
<html>
<head>
<link rel="stylesheet" type="text/css" href="golden.css" />
</head>
<body>
<h2>Visit Report</h2>
<table border="0">
<thead>
<tr>
<th>Visit ID</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<xsl:for-each select="Visit">
<tr class="even">
<xsl:if test="position() mod 2 = 1">
<xsl:attribute name="class">odd</xsl:attribute>
</xsl:if>
<td><xsl:value-of select="visitId"/></td>
<td><xsl:value-of select="name"/></td>
</tr>
</xsl:for-each>
</tbody>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
I have an XML document which looks as follows is:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="visitreport.xsl"?>
<VisitReport xmlns="http://reports.myco.com" xmlns:xsi="http://
www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://reports.myco.com xsd/
VisitReport.xsd">
<Visit>
<visitId>138146</visitId>
<date>2007-06-06</date>
</Visit>
this makes reference to both a style sheet and a schema ( I have
provided the XSL at the end ). what I find is that if I include the
'xmlns=' attribute to VisitReport the table header gets displayed, but
none of the data (tested with Firefox and IE). On the other hand if I
remove the attribute it displays properly. Can these appear together
or are they exclusive?
To provide a bit of context, I am wanting to provide an XML output by
my web site, in a such a way that it can be displayed by the web
browser in tabular form, or saved and imported by Excel. Providing the
stylesheet only approach the web page displays properly, but Excel
does not know what the data types are, but if I provide only the
'xmlns=' then Excel knows the data types, but it does not get rendered
by the web browser. Should I be generating two version of the XML
document depending on the use?
Andre
---- The XSL ----
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
<xsl
<xsl:template match="/VisitReport">
<html>
<head>
<link rel="stylesheet" type="text/css" href="golden.css" />
</head>
<body>
<h2>Visit Report</h2>
<table border="0">
<thead>
<tr>
<th>Visit ID</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<xsl:for-each select="Visit">
<tr class="even">
<xsl:if test="position() mod 2 = 1">
<xsl:attribute name="class">odd</xsl:attribute>
</xsl:if>
<td><xsl:value-of select="visitId"/></td>
<td><xsl:value-of select="name"/></td>
</tr>
</xsl:for-each>
</tbody>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>