#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2011
    Posts
    2
    Rep 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>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    191
    Rep Power
    49
    no use foreach for this sample
    and xsl:stylesheet in second row
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="fme.xsl"?>
    <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">
    	
    
    	<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>
    better xsl
    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>-->
    					<xsl:apply-templates select="fme:xml-tables"/>
    				</table>
    			</body>
    		</html>
    	</xsl:template>
    	<xsl:template match="fme:Zipcodes-table">
    		<xsl:apply-templates select="fme:Zipcodes"/>
    	</xsl:template>
    	<xsl:template match="fme:Zipcodes">
    		<tr>
    			<xsl:apply-templates select="fme:ZIP"/>
    			<xsl:apply-templates select="fme:Number_Of_Outages"/>
    			<xsl:apply-templates select="fme:Customers_By_Zip_I"/>
    		</tr>
    	</xsl:template>
    
    	<xsl:template match="fme:ZIP">
    		<td>
    			<xsl:value-of select="."/>
    		</td>
    	</xsl:template>
    	<xsl:template match="fme:Number_Of_Outages">
    		<td>
    			<xsl:value-of select="."/>
    		</td>
    	</xsl:template>
    	<xsl:template match="fme:Customers_By_Zip_I">
    		<td>
    			<xsl:value-of select="."/>
    		</td>
    	</xsl:template>
    </xsl:stylesheet>
    Helmut Hagemann Germany

    fallen to the bottom of the facts?
    I reach my hand and we go together


    wer lesen und google kann ist klar im Vorteil
    who read and google is able is clear in the advantage
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2011
    Posts
    2
    Rep Power
    0
    That worked. Thanks Helmut!

    I started using XSL 2 days ago. Obviously I have a lot to learn.

    amallen

IMN logo majestic logo threadwatch logo seochat tools logo