This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
XSL
- To: xsl-list <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] XSL
- From: Jim Nelson <jnelson at contivo dot com> (by way of Mulberry TechnologiesList Owner)
- Date: Thu, 8 Mar 2001 15:40:35 -0500
- Reply-To: xsl-list at lists dot mulberrytech dot com
I have listed below 2 different scenarios with the associated .xsl. I have
listed the .xml once, since it is used in both cases.
Objective: Produce output that looks like this;
Price Location
$3.99 USA
$5.30 CAN
$4.55 MEX
$6.55 CHN
In my first scenario I can produce : books2.xsl
$3.99 USA
$5.30 CAN
$4.55 MEX
$6.55 CHN
...which you will notice does not have the header information. I tried to
insert some <xsl:text> tag's to show the header "Price Location" and IE 5.5
gives me an error, indicating tags are in wrong location, which they are
not.
Scenario 1 header: Books.xsl - <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> (which I understand is
the correct way)
Scenario 2 header: Books2.xsl - <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/TR/WD-xsl"> (which is the old way from Micro
Soft)
In short, both the .xsl files are exactly the same, except for the header
information. The old way ( Books2.xsl) produces better results, but I cannot
use <xsl:text> and I assume it is because of the old header information.
When I use the new header information I get a lot of other data, unexpected.
I hope I have given enough surrounding information. Now here are the code
and .xml files. Thanks for your assistance.
BOOKS.XSL
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<xsl:apply-templates/>
</html>
</xsl:template>
<xsl:template match="books">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="book[author='Rodney Goldberg']">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="price">
<p>
<xsl:value-of select="."/>
<xsl:value-of select="@loc"/>
</p>
</xsl:template>
</xsl:stylesheet>
BOOKS2.XSL
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<xsl:apply-templates/>
</html>
</xsl:template>
<xsl:template match="books">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="book[author='Rodney Goldberg']">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="price">
<p>
<xsl:value-of select="."/>
<xsl:value-of select="@loc"/>
</p>
</xsl:template>
</xsl:stylesheet>
BOOKS.XML
<?xml:stylesheet type="text/xsl" href="books.xsl"?>
<books>
<book>
<author>Joe Schmoe</author>
<title>Winning XML</title>
<price loc="USA">3.95</price>
</book>
<book>
<ident>
<isbn>333-333-2222</isbn>
<libnum>RE122-33333-89</libnum>
<stocknum>F222999900222</stocknum>
</ident>
<author>Ann Landers</author>
<author>Debbie Doolittle</author>
<title>Rules of Etiquette</title>
<title>How to go through life without making an ass of
yourself</title>
<price loc="USA">8.99</price>
<price loc="CAN">10.99</price>
<price loc="MEX">9.99</price>
</book>
<book>
<ident>
<isbn>4-3333-11-11001-1</isbn>
<libnum>XB222-00-3388</libnum>
<stocknum>D4477889038383</stocknum>
</ident>
<author>Max Attacx</author>
<title>Felix LaFlur</title>
<price>14.80</price>
</book>
<book>
<ident>
<isbn>88-222-00-5</isbn>
<libnum>VWQ122-33333-89</libnum>
<stocknum>B22299007322</stocknum>
</ident>
<author>Rodney Goldberg</author>
<title>Mental Tennis</title>
<title>How to play championship tennis</title>
<price loc="USA">3.99</price>
<price loc="CAN">5.30</price>
<price loc="MEX">4.55</price>
<price loc="CHN">6.55</price>
</book>
</books>
James Nelson
Director Consulting Services
Contivo, Inc.
Voice: 650-426-4156
Cell: 916-806-0272
Email: jnelson@contivo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list