Trying to output an xml file with xsl

D

DonMiche

I'm having trouble producing an xml output from another xml file using
xsl. The proper values are output to the browser as text with no
formating or xml tags (<rowset> and <row>).

Any ideas?


(The xml source is available below)

Here is my xsl:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:eek:utput method="xml" indent="yes"/>
<xsl:template match="ProductInfo">
<rowset>
<xsl:for-each select="Details">
<row>
<ProductName>
<xsl:value-of select="ProductName"/>
</ProductName>
<Asin>
<xsl:value-of select="Asin"/>
</Asin>
<Catalog>
<xsl:value-of select="Catalog"/>
</Catalog>
<ReleaseDate>
<xsl:value-of select="ReleaseDate"/>
</ReleaseDate>
<ImageUrlSmall>
<xsl:value-of select="ImageUrlSmall"/>
</ImageUrlSmall>
<ListPrice>
<xsl:value-of select="ListPrice"/>
</ListPrice>
</row>
</xsl:for-each>
</rowset>
</xsl:template>
</xsl:stylesheet>


(Here is my source xml)

<?xml version="1.0" ?>
<?xml-stylesheet type="text/xsl" href="amazon.xsl"?>
<ProductInfo>
<Details
url="http://www.amazon.com/exec/obidos/A...?dev-t=D3EE7PA4A5L11O&camp=2025&link_code=xm2">
<Asin>0380977427</Asin>
<ProductName>Quicksilver (The Baroque Cycle, Vol. 1)</ProductName>
<Catalog>Book</Catalog>
<Authors>
<Author>Neal Stephenson</Author>
</Authors>
<ReleaseDate>23 September, 2003</ReleaseDate>
<Manufacturer>William Morrow</Manufacturer>

<ImageUrlSmall>http://images.amazon.com/images/P/0380977427.01.THUMBZZZ.jpg</ImageUrlSmall>

<ImageUrlMedium>http://images.amazon.com/images/P/0380977427.01.MZZZZZZZ.jpg</ImageUrlMedium>

<ImageUrlLarge>http://images.amazon.com/images/P/0380977427.01.LZZZZZZZ.jpg</ImageUrlLarge>
<Availability>Usually ships within 24 hours</Availability>
<ListPrice>$27.95</ListPrice>
<OurPrice>$19.01</OurPrice>
<UsedPrice>$16.92</UsedPrice>
</Details>
<Details
url="http://www.amazon.com/exec/obidos/A...?dev-t=D3EE7PA4A5L11O&camp=2025&link_code=xm2">
<Asin>0060523875</Asin>
<ProductName>The System of the World : Volume Three of The
Baroque Cycle</ProductName>
<Catalog>Book</Catalog>
<Authors>
<Author>Neal Stephenson</Author>
</Authors>
<ReleaseDate>21 September, 2004</ReleaseDate>
<Manufacturer>William Morrow</Manufacturer>

<ImageUrlSmall>http://images.amazon.com/images/P/0060523875.01.THUMBZZZ.jpg</ImageUrlSmall>

<ImageUrlMedium>http://images.amazon.com/images/P/0060523875.01.MZZZZZZZ.jpg</ImageUrlMedium>

<ImageUrlLarge>http://images.amazon.com/images/P/0060523875.01.LZZZZZZZ.jpg</ImageUrlLarge>
<Availability>Not yet published</Availability>
<ListPrice>$27.95</ListPrice>
<OurPrice>$19.56</OurPrice>
</Details>
<Details
url="http://www.amazon.com/exec/obidos/A...?dev-t=D3EE7PA4A5L11O&camp=2025&link_code=xm2">
<Asin>0553380958</Asin>
<ProductName>Snow Crash</ProductName>
<Catalog>Book</Catalog>
<Authors>
<Author>NEAL STEPHENSON</Author>
</Authors>
<ReleaseDate>02 May, 2000</ReleaseDate>
<Manufacturer>Bantam </Manufacturer>

<ImageUrlSmall>http://images.amazon.com/images/P/0553380958.01.THUMBZZZ.jpg</ImageUrlSmall>

<ImageUrlMedium>http://images.amazon.com/images/P/0553380958.01.MZZZZZZZ.jpg</ImageUrlMedium>

<ImageUrlLarge>http://images.amazon.com/images/P/0553380958.01.LZZZZZZZ.jpg</ImageUrlLarge>
<Availability>Usually ships within 24 hours</Availability>
<ListPrice>$14.00</ListPrice>
<OurPrice>$11.20</OurPrice>
<UsedPrice>$4.99</UsedPrice>
</Details>
<Details
url="http://www.amazon.com/exec/obidos/A...?dev-t=D3EE7PA4A5L11O&camp=2025&link_code=xm2">
<Asin>0060512806</Asin>
<ProductName>Cryptonomicon</ProductName>
<Catalog>Book</Catalog>
<Authors>
<Author>Neal Stephenson</Author>
</Authors>
<ReleaseDate>05 November, 2002</ReleaseDate>
<Manufacturer>Avon</Manufacturer>

<ImageUrlSmall>http://images.amazon.com/images/P/0060512806.01.THUMBZZZ.jpg</ImageUrlSmall>

<ImageUrlMedium>http://images.amazon.com/images/P/0060512806.01.MZZZZZZZ.jpg</ImageUrlMedium>

<ImageUrlLarge>http://images.amazon.com/images/P/0060512806.01.LZZZZZZZ.jpg</ImageUrlLarge>
<Availability>Usually ships within 24 hours</Availability>
<ListPrice>$7.99</ListPrice>
<OurPrice>$7.99</OurPrice>
<UsedPrice>$3.95</UsedPrice>
</Details>
<Details
url="http://www.amazon.com/exec/obidos/A...?dev-t=D3EE7PA4A5L11O&camp=2025&link_code=xm2">
<Asin>0060599340</Asin>
<ProductName>The Confusion LTD</ProductName>
<Catalog>Book</Catalog>
<Authors>
<Author>Neal Stephenson</Author>
</Authors>
<ReleaseDate>01 October, 2004</ReleaseDate>
<Manufacturer>William Morrow</Manufacturer>

<ImageUrlSmall>http://images.amazon.com/images/P/0060599340.01.THUMBZZZ.jpg</ImageUrlSmall>

<ImageUrlMedium>http://images.amazon.com/images/P/0060599340.01.MZZZZZZZ.jpg</ImageUrlMedium>

<ImageUrlLarge>http://images.amazon.com/images/P/0060599340.01.LZZZZZZZ.jpg</ImageUrlLarge>
<Availability>Not yet released.</Availability>
<ListPrice>$200.00</ListPrice>
<OurPrice>$136.00</OurPrice>
</Details>
<Details
url="http://www.amazon.com/exec/obidos/A...?dev-t=D3EE7PA4A5L11O&camp=2025&link_code=xm2">
<Asin>0553380966</Asin>
<ProductName>The Diamond Age : Or, a Young Lady's Illustrated
Primer</ProductName>
<Catalog>Book</Catalog>
<Authors>
<Author>Neal Stephenson</Author>
</Authors>
<ReleaseDate>02 May, 2000</ReleaseDate>
<Manufacturer>Bantam </Manufacturer>

<ImageUrlSmall>http://images.amazon.com/images/P/0553380966.01.THUMBZZZ.jpg</ImageUrlSmall>

<ImageUrlMedium>http://images.amazon.com/images/P/0553380966.01.MZZZZZZZ.jpg</ImageUrlMedium>

<ImageUrlLarge>http://images.amazon.com/images/P/0553380966.01.LZZZZZZZ.jpg</ImageUrlLarge>
<Availability>Usually ships within 24 hours</Availability>
<ListPrice>$13.95</ListPrice>
<OurPrice>$11.16</OurPrice>
<UsedPrice>$6.45</UsedPrice>
</Details>
<Details
url="http://www.amazon.com/exec/obidos/A...?dev-t=D3EE7PA4A5L11O&camp=2025&link_code=xm2">
<Asin>0380815931</Asin>
<ProductName>In the Beginning...was the Command Line</ProductName>
<Catalog>Book</Catalog>
<Authors>
<Author>Neal Stephenson</Author>
</Authors>
<ReleaseDate>09 November, 1999</ReleaseDate>
<Manufacturer>Avon</Manufacturer>

<ImageUrlSmall>http://images.amazon.com/images/P/0380815931.01.THUMBZZZ.jpg</ImageUrlSmall>

<ImageUrlMedium>http://images.amazon.com/images/P/0380815931.01.MZZZZZZZ.jpg</ImageUrlMedium>

<ImageUrlLarge>http://images.amazon.com/images/P/0380815931.01.LZZZZZZZ.jpg</ImageUrlLarge>
<Availability>Usually ships within 24 hours</Availability>
<ListPrice>$10.00</ListPrice>
<OurPrice>$8.00</OurPrice>
<UsedPrice>$3.50</UsedPrice>
</Details>
<Details
url="http://www.amazon.com/exec/obidos/A...?dev-t=D3EE7PA4A5L11O&camp=2025&link_code=xm2">
<Asin>1576752402</Asin>
<ProductName>The Referral of a Lifetime: The Networking System
that Produces Bottom-Line Results . . . Every Day!</ProductName>
<Catalog>Book</Catalog>
<Authors>
<Author>Timothy L. Templeton</Author>
<Author>Lynda Rutledge Stephenson</Author>
<Author>Tim Templeton</Author>
<Author>Kenneth H. Blanchard</Author>
</Authors>
<ReleaseDate>May, 2003</ReleaseDate>
<Manufacturer>Berrett-Koehler Pub</Manufacturer>

<ImageUrlSmall>http://images.amazon.com/images/P/1576752402.01.THUMBZZZ.jpg</ImageUrlSmall>

<ImageUrlMedium>http://images.amazon.com/images/P/1576752402.01.MZZZZZZZ.jpg</ImageUrlMedium>

<ImageUrlLarge>http://images.amazon.com/images/P/1576752402.01.LZZZZZZZ.jpg</ImageUrlLarge>
<Availability>THIS TITLE IS CURRENTLY NOT AVAILABLE. If you would
like to purchase this title, we recommend that you occasionally check
this page to see if it has become available.</Availability>
<ListPrice>$19.95</ListPrice>
<OurPrice>$13.97</OurPrice>
<UsedPrice>$14.64</UsedPrice>
</Details>
<Details
url="http://www.amazon.com/exec/obidos/A...?dev-t=D3EE7PA4A5L11O&camp=2025&link_code=xm2">
<Asin>0553573861</Asin>
<ProductName>Zodiac</ProductName>
<Catalog>Book</Catalog>
<Authors>
<Author>Neal Stephenson</Author>
</Authors>
<ReleaseDate>01 June, 1995</ReleaseDate>
<Manufacturer>Bantam </Manufacturer>

<ImageUrlSmall>http://images.amazon.com/images/P/0553573861.01.THUMBZZZ.jpg</ImageUrlSmall>

<ImageUrlMedium>http://images.amazon.com/images/P/0553573861.01.MZZZZZZZ.jpg</ImageUrlMedium>

<ImageUrlLarge>http://images.amazon.com/images/P/0553573861.01.LZZZZZZZ.jpg</ImageUrlLarge>
<Availability>Usually ships within 24 hours</Availability>
<ListPrice>$7.50</ListPrice>
<OurPrice>$7.50</OurPrice>
<UsedPrice>$3.95</UsedPrice>
</Details>
</ProductInfo>
 
M

Martin Honnen

DonMiche said:
I'm having trouble producing an xml output from another xml file using
xsl. The proper values are output to the browser as text with no
formating or xml tags (<rowset> and <row>).

Well, what do you expect a browser to do, it is XML that you produce and
if you do not associate a CSS stylesheet with the XML the browser won't
do more than rendering the content of text nodes
 
A

Andy Dingley

DonMiche said:
I'm having trouble producing an xml output from another xml file using
xsl. The proper values are output to the browser as text with no
formating or xml tags (<rowset> and <row>).

Works for me. However if you do this in a raw browser (I suspect
you're doing the transform client-side, using that
<?xml-stylesheet type="text/xsl" href="amazon.xsl"?>
at the top) then you're not generating any HTML. The browser will
ignore the tags it doesn't recognise and just give you the text
content -- which is what it is doing, and about all you can expect of
it.

What are you trying to do here ? Make HTML for a browser, or make XML
for something else that knows how to handle it ? (in which case, a
browser is the wrong diagnostic tool - try doing transforms on the
server)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,690
Members
48,796
Latest member
Greg L.

Latest Threads

Top