You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Gunnlaugur Thor Briem <gt...@dimon.is> on 2001/10/02 15:13:59 UTC

RE: NodeSet-Bug in 2_2_x ? Please add your vote...

Makes sense to me ... acceptable and desired.

	- Gulli



> -----Original Message-----
> From: Myriam_Midy@lotus.com [mailto:Myriam_Midy@lotus.com]
> Sent: 28. september 2001 14:55
> To: xalan-dev@xml.apache.org
> Subject: Re: NodeSet-Bug in 2_2_x ? Please add your vote...
>
>
>
> We found the problem,but before checking in a fix, we'd like everyone's
> opinion.
>
> The problem is that when we are wrapping the given DOM nodelist with the
> DTM layer, we make sure that nodes in the DTM nodelist are in document
> order and are not duplicated. Fixing the code would imply that we will now
> take any given DOM nodelist and create a DTM nodelist without any checking
> or ordering and assume that the given nodelist is "properly" built.
>
> Is that acceptable to everyone and the desirable behaviour??
>
> Thanks,
> Myriam
>
>
>
>                     Patrick Lay
>                     <lay@informatik.un       To:     xalan-dev@xml.apache.org
>                     i-bonn.de>               cc:     (bcc: Myriam Midy/CAM/Lotus)
>                                              Subject:     NodeSet-Bug in 2_2_x ?
>                     09/25/01 05:42 AM
>                     Please respond to
>                     xalan-dev
>
>
>
>
>
>
> Hi,
>
>
> I'm trying to 'collect' nodes in a org.apache.xpath.NodeSet using Xalan
> Extensions and found out a strange behaviour, which looks like a bug to
> me.
>
>
> I'm using this XML file:
>
> items.xml:
> ==========
> <?xml version="1.0" encoding="ISO-8859-1"?>
>   <items>
>     <item name="a">xa</item>
>     <item name="b">xb</item>
>     <item name="c">xc</item>
>     <item name="d">xd</item>
>   </items>
>
>
> and this stylesheet:
>
> collectortest.xsl:
> ==================
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version
> ="1.0"
>   xmlns:coll="xalan://NodeCollector" exclude-result-prefixes="xalan coll">
>
>   <xsl:template match="/">
>     <out>
>       <xsl:value-of select="coll:add(//item[@name='b'])"/>
>       <xsl:value-of select="coll:add(//item[@name='a'])"/>
>       <xsl:value-of select="coll:add(//item[@name='c'])"/>
>       <xsl:value-of select="coll:add(//item[@name='a'])"/>
>       <xsl:value-of select="coll:add(//item[@name='b'])"/>
>       <xsl:for-each select="coll:getNodes()">
>         :<xsl:value-of select="@name"/>
>       </xsl:for-each>
>     </out>
>   </xsl:template>
> </xsl:stylesheet>
>
>
> and this Extension:
>
> NodeCollector.java:
> ===================
> import java.io.*;
> import org.apache.xpath.NodeSet;
> import org.w3c.dom.*;
>
> public class NodeCollector
> {
>   private NodeSet nodeset = new NodeSet();
>
>   public NodeCollector() {
>     System.err.println("-----> NodeCollector instantiated");
>   }
>
>   public void add(NodeList nodes) {
>     System.err.println("-----> called add, "+nodes.getLength()+" nodes");
>     nodeset.addNodes(nodes);
>   }
>
>   public NodeSet getNodes() {
>     System.err.println("-----> called getNodes, size: " + nodeset.size());
>     return nodeset;
>   }
> }
>
>
> The interesting part follows now:
> Using xalan-j_2_1_0, I get this output:
>   -----> NodeCollector instantiated
>   -----> called add, 1 nodes
>   -----> called add, 1 nodes
>   -----> called add, 1 nodes
>   -----> called add, 1 nodes
>   -----> called add, 1 nodes
>   -----> called getNodes, size: 5
>   <?xml version="1.0" encoding="UTF-8"?>
>   <out>
>         :b
>         :a
>         :c
>         :a
>         :b</out>
>
> This is what I expect (and want) to get...
> but, using xalan-j_2_2_D10 or nightly builds, I get:
>
>   <?xml version="1.0" encoding="UTF-8"?>
>   -----> NodeCollector instantiated
>   -----> called add, 1 nodes
>   -----> called add, 1 nodes
>   -----> called add, 1 nodes
>   -----> called add, 1 nodes
>   -----> called add, 1 nodes
>   -----> called getNodes, size: 5
>   <out>
>         :a
>         :b
>         :c</out>
>
> i.e. sorted and duplicates eliminated...
> Since the getNodes()-size is 5, the NodeSet seems to be ok, and this
> 'error' is originating elsewhere (in the DTM ??)
> I even tried a NodeList (which doesn't seem to work in 2_1_0, but it
> didn't change anything.
>
> So, is this a bug or a feature ? ;)
> If it is intended, how do I manage to get my 'wanted' output ?
>
>
> Thanks and regards,
> Patrick
> --
> * Dipl.-Inform. Patrick Lay
> * Institut für Informatik III     Phone +49 (228) 73-4537
> * Universität Bonn                Fax   +49 (228) 73-4382
> * Römerstraße 164                 lay@informatik.uni-bonn.de
> * D-53117 Bonn (Germany)          http://www.informatik.uni-bonn.de/~lay/
>
>
>
>
>
>