Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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
 
Old January 9th, 2005, 08:16 PM
Registered User
 
Join Date: Jan 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default XML - XSL Conveting

I have just started learning about XML. Everything seemed to be going smooth until i encountered my first up-hill: Converting with the MSXSL command. I get the error: "Keyword xsl:apply-template may not be used here."

The source files are picked up from the XML book:

XML code:
<?xml version="1.0"?>
<order>
    <salesperson>John Doe</salesperson>
    <item>Production Class-Widget</item>
    <quantity>16</quantity>
    <date>
        <month>1</month>
        <day>13</day>
        <year>2005</year>
    </date>
<customer>Sally Finkelstein</customer>
</order>


XSL code:

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

<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-template 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'">E16-25A</xsl:when>
            <xsl:when test=". = 'Economy-Class Widget'">E16-25B</xsl:when>

            <xsl:otherwise>00</xsl:otherwise>
        </xsl:choose>
    </part-number>

    <description><xsl:value-of select="."/></description>
</xsl:template>
</xsl:stylesheet>


the xml and xsl source files are located in C:\input
The msxsl.exe file is planted in the C:\Winnt directory
The xmlsdk.msi is installed ok..

Here is what i wrote at the command promt:

C:\WINNT>msxsl c:\input\filename.xml c:\input\filename2.xsl

According to the book, this is the way to do it...

I'll be glad for any answer on this..
Peter
 
Old January 10th, 2005, 01:56 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

Problem is in your XSLT code..You are applying templates inside the item tag..
<item>
     <xsl:apply-template select="order/item"/>
...
</item>

Put the code you have done in the item template instead of apply-template..
 
Old January 10th, 2005, 05:21 AM
Authorized User
 
Join Date: Jul 2004
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You are simply missing an 's', it is <xsl:apply-templates />

 
Old January 10th, 2005, 08:15 AM
Registered User
 
Join Date: Jan 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks alot Santhi and Barcher.

I spent 2 days scrathing my head about this, - and all that was missing was an "s".. typical!
Now I can go on.
Thnx





Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting Source Xml into Target Xml Using XSL. alapati.sasi XSLT 3 May 14th, 2007 10:54 AM
Transforming XML to XML using XSL sakreck XSLT 0 January 9th, 2007 11:48 AM
XML To XML, using XSL & XSD supercop75 XSLT 1 April 8th, 2006 02:48 AM
xml and xsl templates as input to xslt gives xml rameshnarayan XSLT 5 August 3rd, 2005 01:58 AM
Is it my XML or XSL or none of the above ryanpatrick XML 16 May 31st, 2005 09:22 AM





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