XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Closed Thread
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 26th, 2011, 09:44 AM
amallen amallen is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2011
Posts: 2 amallen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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>

Reply With Quote
  #2  
Old January 26th, 2011, 12:28 PM
xml-profi xml-profi is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2009
Posts: 190 xml-profi User rank is Sergeant Major (2000 - 5000 Reputation Level)xml-profi User rank is Sergeant Major (2000 - 5000 Reputation Level)xml-profi User rank is Sergeant Major (2000 - 5000 Reputation Level)xml-profi User rank is Sergeant Major (2000 - 5000 Reputation Level)xml-profi User rank is Sergeant Major (2000 - 5000 Reputation Level)xml-profi User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 7 h 8 m 25 sec
Reputation Power: 48
Send a message via ICQ to xml-profi
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

Reply With Quote
  #3  
Old January 26th, 2011, 01:25 PM
amallen amallen is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2011
Posts: 2 amallen User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 43 sec
Reputation Power: 0
That worked. Thanks Helmut!

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

amallen

Reply With Quote
Closed Thread

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > HTML tags in XSL won't display in web browser

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap