View Single Post
  #8 (permalink)  
Old April 28th, 2006, 10:22 AM
mhkay's Avatar
mhkay mhkay is offline
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

In fact the stylesheet isn't correct, because it isn't outputting a name element. It should be

<xsl:template match="name">
<name>
    <test1>
        <xsl:value-of select="test1"/>
    </test1>
    <test2>
        <xsl:value-of select="test2"/>
    </test2>
</name>
</xsl:template>

But that doesn't account for your output. You seem to be doing something badly wrong (in fact, you seem to be looking at the input).

With the above change, Saxon outputs

<?xml version="1.0" encoding="UTF-8"?>
  <name><test1>1</test1><test2>2</test2></name>
  <name><test1>1</test1><test2/></name>

(if you want it indented, add <xsl:output indent="yes"/>)


Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote