M
mahalie
Hello,
I am trying to learn xml/xslt and just finished reading "Understanding
XML" an article by Dare Obasanjo at MSDN. I was just trying to view
his example xml file in a browser.
First it wasn't working in either Internet Explorer or Firefox, then
after fixing some spacing and figuring out that I needed to change
<xsl:for-each select="items/compact-disc"> to
select="order/items/compact-disc"
it works in Internet Explorer as expected. Can someone explain to me
why it's not working Firefox? Here's the text.xml document:
<?xml version="1.0" encoding="iso-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="test.xsl" ?>
<order id="ord123456">
<customer id="cust0921">
<first-name>Dare</first-name>
<last-name>Obasanjo</last-name>
<address>
<street>One Microsoft Way</street>
<city>Redmond</city>
<state>WA</state>
<zip>98052</zip>
</address>
</customer>
<items>
<compact-disc>
<price>16.95</price>
<artist>Nelly</artist>
<title>Nellyville</title>
</compact-disc>
<compact-disc>
<price>17.55</price>
<artist>Baby D</artist>
<title>Lil Chopper Toy</title>
</compact-disc>
</items>
<!-- Always go the extra mile for the customer -->
<special-instructions xmlns:html="http://www.w3.org/1999/xhtml/">
<html>If customer is not available at the address then attempt
leave package at one of the following locations listed in order
of
which should be attempted first
<htmll>
<html:li>Next Door</html:li>
<html:li>Front Desk</html:li>
<html:li>On Doorstep</html:li>
</htmll>
<html:b>Note</html:b> Remember to leave a note detailing where
to pick up the package.
</html>
</special-instructions>
</order>
And here's the text.xsl document:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:html="http://www.w3.org/1999/xhtml">
<xslutput method="xml" indent="yes"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" />
<xsl:template match="/">
<html lang="en" xml:lang="en">
<head>
<title>Order Information - ord123456</title>
</head>
<body>
<table border="1">
<tr><th>Artist</th><th>Title</th><th>Price</th></tr>
<xsl:for-each select="order/items/compact-disc">
<tr>
<td><xsl:value-of xmlns="" select="artist" /></td>
<td><xsl:value-of xmlns="" select="title" /></td>
<td><xsl:value-of xmlns="" select="price" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
p.s. Just in case you're worried I'm getting an MS-only view of things
I'm also reading simple concepts on http://www.w3schools.com/xml/ and
more technical stuff on http://www.xml.com/ but I'm definately open to
suggestions of good resources.
I am trying to learn xml/xslt and just finished reading "Understanding
XML" an article by Dare Obasanjo at MSDN. I was just trying to view
his example xml file in a browser.
First it wasn't working in either Internet Explorer or Firefox, then
after fixing some spacing and figuring out that I needed to change
<xsl:for-each select="items/compact-disc"> to
select="order/items/compact-disc"
it works in Internet Explorer as expected. Can someone explain to me
why it's not working Firefox? Here's the text.xml document:
<?xml version="1.0" encoding="iso-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="test.xsl" ?>
<order id="ord123456">
<customer id="cust0921">
<first-name>Dare</first-name>
<last-name>Obasanjo</last-name>
<address>
<street>One Microsoft Way</street>
<city>Redmond</city>
<state>WA</state>
<zip>98052</zip>
</address>
</customer>
<items>
<compact-disc>
<price>16.95</price>
<artist>Nelly</artist>
<title>Nellyville</title>
</compact-disc>
<compact-disc>
<price>17.55</price>
<artist>Baby D</artist>
<title>Lil Chopper Toy</title>
</compact-disc>
</items>
<!-- Always go the extra mile for the customer -->
<special-instructions xmlns:html="http://www.w3.org/1999/xhtml/">
<html>If customer is not available at the address then attempt
leave package at one of the following locations listed in order
of
which should be attempted first
<htmll>
<html:li>Next Door</html:li>
<html:li>Front Desk</html:li>
<html:li>On Doorstep</html:li>
</htmll>
<html:b>Note</html:b> Remember to leave a note detailing where
to pick up the package.
</html>
</special-instructions>
</order>
And here's the text.xsl document:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:html="http://www.w3.org/1999/xhtml">
<xslutput method="xml" indent="yes"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" />
<xsl:template match="/">
<html lang="en" xml:lang="en">
<head>
<title>Order Information - ord123456</title>
</head>
<body>
<table border="1">
<tr><th>Artist</th><th>Title</th><th>Price</th></tr>
<xsl:for-each select="order/items/compact-disc">
<tr>
<td><xsl:value-of xmlns="" select="artist" /></td>
<td><xsl:value-of xmlns="" select="title" /></td>
<td><xsl:value-of xmlns="" select="price" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
p.s. Just in case you're worried I'm getting an MS-only view of things
I'm also reading simple concepts on http://www.w3schools.com/xml/ and
more technical stuff on http://www.xml.com/ but I'm definately open to
suggestions of good resources.