Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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?

Reply With Quote
  #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
Reply With Quote
  #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?

Reply With Quote
  #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>

Reply With Quote
  #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>

Reply With Quote
  #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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:31 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.