xsl-list
[Top] [All Lists]

RE: [xsl] Inconsistent interpretation of // relative to document()

2007-08-22 15:02:09
As others have said, the difference is probably that the stylesheet has a
different base URI in the two cases. The base URI is an implicit argument to
the document() function. When using JAXP, the base URI is set when you call
setSystemId() on the Source object used to construct the Templates object.
When using Ant, I'm afraid I have no idea where the base URI comes from -
but you can avoid problems by supplying an absolute URI as the value of the
parameter, or by calling resolve-uri() to control the URI resolution
yourself.

Michael Kay
http://www.saxonica.com/ 

-----Original Message-----
From: Richard Hoberman 
[mailto:richard(_dot_)hoberman(_at_)sadalbari(_dot_)com] 
Sent: 22 August 2007 12:42
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Inconsistent interpretation of // relative to 
document()

I get different results when using Saxon to merge two 
documents, depending on whether I invoke Saxon via Ant or via JAXP.

The difference appears to be how "//" is interpreted while 
processing nodes obtained using document().  The Ant version 
finds nodes in the source document (as opposed to the one 
obtained via the function).  The JAXP version finds nodes 
among those returned by the document function.

Which is the correct behaviour?  (Also, is there a name for "//"?)
 
I am using Saxon-8.9B, Sun JDK 1.6, XSLT 2.  My stylesheet is below.

Regards

Richard Hoberman


<xsl:stylesheet version="2.0"
                xmlns="http://www.w3.org/1999/XSL/Format";
                xmlns:c="http://www.sadalbari.com/2007/FO/Composition";
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

    <xsl:param name="template-source" />
   
    <xsl:variable name="template" 
select="document($template-source)/*" />
   
    <xsl:template match="c:composition">
        <xsl:apply-templates select="$template" mode="insert" />
    </xsl:template>
   
    <xsl:template match="c:insert" mode="insert">
        <xsl:variable name="name" select="@name" />
        <xsl:apply-templates select="//c:define[(_at_)name=$name]/node()"
mode="insert" />       
    </xsl:template>
   
    <xsl:template match="@*|node()" mode="insert">
      <xsl:copy>
        <xsl:apply-templates select="@*|node()" mode="insert" />
      </xsl:copy>
    </xsl:template>
   
    <xsl:template match="@*|node()" mode="copy">
      <xsl:copy>
        <xsl:apply-templates select="@*|node()" mode="copy" />
      </xsl:copy>
    </xsl:template>
   
    <xsl:template match="*" />

</xsl:stylesheet>



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>