Menu

Result Tree Fragment with XSLT 2.0

Help
Frper
2012-05-23
2012-10-08
  • Frper

    Frper - 2012-05-23

    Hello,
    I encounter a strange behaviour of Saxon on my computer.
    When I run a XSLT 2.0 transformation with Saxon, I have Result Tree Fragment
    as if i was in XSLT 1.0.
    Example :

    <xsl:stylesheet xmlns:xsl="[url]http://www.w3.org/1999/XSL/Transform[/url]"  version="2.0">
    <xsl:output method = "xml" indent="yes"  />
    
    <xsl:variable name="liltree">
        <d> <e/> </d>
    </xsl:variable>
    
    <xsl:template match="/">
        <xsl:copy-of select="$liltree//e"/>
    </xsl:template>
    
    </xsl:stylesheet>
    

    Should return <e/> ,but returns nothing.

    Here is the trace of the command :

    java -cp saxon9he.jar net.sf.saxon.Transform -t -o:"result.xml" -s:"foo.xml" -xsl:"TestXslFromForum.xsl"
    Saxon-HE 9.4.0.3J from Saxonica
    Java version 1.6.0_27
    Stylesheet compilation time: 1094 milliseconds
    Processing file:/V:/TestXSL2/foo.xml
    Using parser com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
    Building tree for file:/V:/TestXSL2/foo.xml using class net.sf.saxon.tree.tiny.TinyBuilder
    Tree built in 0 milliseconds
    Tree size: 3 nodes, 0 characters, 0 attributes
    Execution time: 125ms
    Memory used: 5730360
    NamePool contents: 6 entries in 6 chains. 6 URIs
    

    I have implemented several other tests.
    Each time, it seems that my variables are set with Result Tree Fragment.
    Can someone explain to me why I can't ged rid of Result Tree Fragments.
    Thanks.

     
  • Michael Kay

    Michael Kay - 2012-05-23

    Your stylesheet works fine for me. Perhaps you are looking for the output in
    the wrong place (you sent it to a file). Try simplifying your command to

    java -cp saxon9he.jar net.sf.saxon.Transform -xsl:"TestXslFromForum.xsl"
    -s:"TestXslFromForum.xsl"

    I don't know what makes you think this has anything to do with result tree
    fragments. If this were 1.0, you would get an error, not blank output.

     
  • Frper

    Frper - 2012-05-23

    I'm so sorry.
    I made three mistakes in the XPATH expressions of the three examples I wrote.
    And unfortunatly, those examples were falsely correctly treated by XMLSpy.
    For example :

    <xsl:copy-of select="$liltree/e"/> <!-- only one "/" -->
    

    gives </e> thought it should return nothing
    Thank you for your quick answer, I should have read my code better.