
January 26th, 2011, 09:44 AM
|
|
Registered User
|
|
Join Date: Jan 2011
Posts: 2
Time spent in forums: 1 h 43 sec
Reputation Power: 0
|
|
|
HTML tags in XSL won't display in web browser
I have an XML file containing a namespace and all the tags contain the namespace prefix. I also have an XSL template I want to use to display the XML file as a table in a web browser. Additionally, the XSL file has html tags in it. The problem is the namespace in the XML file is preventing the HTML tags in the XSL template from displaying in the web browser. Instead the XML values display as a single line in Firefox 3.6 (no html) and IE 7 displays the XML file in its entirety - tags and all - and ignores the XSL template. If I remove the namespace prefix from all the tags in the XML file then XML correctly appears as an HTML table in both web browsers. But adding an XHTML namespace and namespace prefix to the HTML tags in the XSL files does not work (in this case, XML file has original namespace and tag prefixes). I need to keep the namespace prefixes in the XML tags so how do I get the HTML to work? XML and XLS files are below.
Thanks,
amallen
Code:
<?xml version="1.0" encoding="UTF-8"?>
<fme:xml-tables xmlns:fme="http://www.safe.com/xml/xmltables" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.safe.com/xml/xmltables Zipcode_summary.xsd">
<?xml-stylesheet type="text/xsl" href="zip_summary.xsl"?>
<fme:Zipcodes-table>
<fme:Zipcodes>
<fme:ZIP>87102</fme:ZIP>
<fme:Number_Of_Outages>1</fme:Number_Of_Outages>
<fme:Customers_By_Zip_I>1</fme:Customers_By_Zip_I>
</fme:Zipcodes>
<fme:Zipcodes>
<fme:ZIP>87111</fme:ZIP>
<fme:Number_Of_Outages>4</fme:Number_Of_Outages>
<fme:Customers_By_Zip_I>28</fme:Customers_By_Zip_I>
</fme:Zipcodes>
<fme:Zipcodes>
<fme:ZIP>87501</fme:ZIP>
<fme:Number_Of_Outages>1</fme:Number_Of_Outages>
<fme:Customers_By_Zip_I>1</fme:Customers_By_Zip_I>
</fme:Zipcodes>
</fme:Zipcodes-table>
</fme:xml-tables>
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fme="http://www.safe.com/xml/xmltables"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:output method="html" version="1.0" encoding="UTF-8" doctype-public="-//W3C//DTD XHTML 1.1//EN" doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<h2>Outage Summary</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Zip</th>
<th>Number of Outages</th>
<th>Total Customers</th>
</tr>
<xsl:for-each select="fme:Zipcodes-table/fme:Zipcodes">
<tr>
<td>
<xsl:value-of select="fme:ZIP"/>
</td>
<td>
<xsl:value-of select="fme:Number_Of_Outages"/>
</td>
<td>
<xsl:value-of select="fme:Customers_By_Zip_I"/>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
|