On Thu, Dec 27, 2001 at 09:08:03AM -0800, Gary L Peskin wrote:
> Jeff --
> 
> I think the problem is that these are two different sets of nodes.  In
> your XSLT, the first "a" target appears as a child of the xsl:variable
> for treefrag1 whereas the second "a" target appears as a child of the
> xsl:variable for treefrag2.
> 
> I haven't tried it but if you try the example from exslt page, it should
> work.  Here, we are working with the same nodes that are being selected
> into different variables.

Ah I see what you mean.. different 'views' of the same tree. Pity that
the definition of node equality is so restricted. Thanks for the
explanation :)

--Jeff

> HTH,
> Gary
> 
> > -----Original Message-----
> > From: Jeff Turner [mailto:[EMAIL PROTECTED] 
> > Sent: Thursday, December 27, 2001 6:10 AM
> > To: [EMAIL PROTECTED]
> > Subject: xalan:difference question
> > 
> > 
> > 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