Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old February 9th, 2004, 02:06 PM
Registered User
 
Join Date: Feb 2004
Location: , , Canada.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Question re Beginning XML book pages 94-95

In the section subtitled "Associating stylesheets with XML documents using Processing Instructions", I am given the impression that I can add the <?xml-stylesheet> tag to the top of my XML document and reference my xsl stylesheet. Further, the book seems to indicate that if I use IE5 or higher (I am using IE 6), I can simply open the XML file and the browser will use the xsl transformation and display the results.

My question is: I tried this and the result in IE6 is correct (ie, the transformation changed the data), but the result is in plain text only. I cannot seem to get it to show formatted as XML. Is there a way to do this? Or am I supposed to use msxsl first, and then open the result in IE6?

  #2 (permalink)  
Old February 9th, 2004, 05:27 PM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Without any example of a non-working xml document and stylesheet this is very difficult to answer.

--

Joe
  #3 (permalink)  
Old February 9th, 2004, 05:35 PM
Registered User
 
Join Date: Feb 2004
Location: , , Canada.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The book seems to imply that I can simply
1) create an XML document

2) create a XSL transformation including the line
<xsl:output method="xml" indent="yes" encoding "UTF-8"/>

3) add this line to the top of the XML document
<?xml-stylesheet type="text/xsl" href="stylesheet.xsl"?>

4) open the XML document in IE and have it transformed correctly

I have done this, but my only problem is that IE renders the result as plain text, not as XML. How do you get it to appear as XML?

  #4 (permalink)  
Old February 9th, 2004, 05:36 PM
Registered User
 
Join Date: Feb 2004
Location: , , Canada.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

XML file:

<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="XSLTFile1.xsl"?>
<order>
    <salesperson>John Doe</salesperson>
    <item>Production-Class Widget</item>
    <quantity>16</quantity>
    <date>
        <month>1</month>
        <day>13</day>
        <year>2000</year>
    </date>
    <customer>Sally Finkelstein</customer>
</order>

  #5 (permalink)  
Old February 9th, 2004, 05:37 PM
Registered User
 
Join Date: Feb 2004
Location: , , Canada.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

XSL file:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes"/>

<xsl:template match="/">
    <order>
        <date>
            <xsl:value-of select="order/date/year"/><xsl:value-of select="order/date/month"/><xsl:value-of select="order/date/day"/>
        </date>
    <customer>Company A</customer>
    <item> <xsl:apply-templates select="order/item"/>
    <quantity><xsl:value-of select="order/quantity"/></quantity>
    </item>
    </order>
</xsl:template>

<xsl:template match="item">
<part-number>
<xsl:choose>
<xsl:when test=". = 'Production-Class Widget'">E-16-25A</xsl:when>
<xsl:when test=". = 'Economy-Class Widget'">E-16-25B</xsl:when>
<xsl:otherwise>00</xsl:otherwise>
</xsl:choose>
</part-number>
<description><xsl:value-of select="."/></description>
</xsl:template>
</xsl:stylesheet>

  #6 (permalink)  
Old February 10th, 2004, 09:57 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I will try your example later but I seem to remember something about IE and xsl-stylesheet instructions that suggested it only coped when output was html. Try changing the output method.

--

Joe


Similar Threads
Thread Thread Starter Forum Replies Last Post
Beginning JavaServer Pages caslina BOOK: Beginning JavaServer Pages 0 December 13th, 2007 09:59 AM
Wanted: Code for "Beginning C# XML"-book (2002) wmi All Other Wrox Books 1 September 21st, 2004 06:32 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.