Hi,

I'm trying to use the extension 'difference' function, whose entire
documentation consists of:

  "Implemented in org.apache.xalan.lib.Extensions, difference(node-set1,
  node-set2) returns a node-set with the nodes in node-set1 and not in
  node-set2."

  -- http://xml.apache.org/xalan-j/extensionslib.html#difference


I have the following XSL:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
        xmlns:xalan="http://xml.apache.org/xalan";
        extension-element-prefixes="xalan"
        >

        <xsl:template match="/">
                <xsl:variable name="treefrag1">
                        <target>a</target>
                        <target>b</target>
                        <target>c</target>
                </xsl:variable>
                <xsl:variable name="treefrag2">
                        <target>a</target>
                        <target>b</target>
                </xsl:variable>

                <xsl:for-each 
select="xalan:difference(xalan:nodeset($treefrag1), 
xalan:nodeset($treefrag2))/*">
                        <xsl:message> Got: <xsl:value-of select="."/> 
</xsl:message>
                </xsl:for-each>
                <xsl:message>Finished!</xsl:message>
        </xsl:template>
</xsl:stylesheet>


Ie, two result fragments converted to nodesets, which I then want to
determine the 'difference' of. I'm expecting a nodeset containing just
<target>c</target>. Here's what I get:

$ java org.apache.xalan.xslt.Process -in small.xsl -xsl small.xsl -out /dev/null
 Got: a
 Got: b
 Got: c
Finished!


Can anyone see what's wrong here?

Btw, assuming Xalan follows the semantics of exslt's set:difference, this may 
be relevant:

http://www.exslt.org/set/functions/difference/index.html

But that demonstrates the node-set coming from a select on the source document,
not from an xalan:nodeset(). Could that make a (ahem) difference?

Thanks,


--Jeff

Reply via email to