Hi,

This problem is now fixed. DefaultNameStep was badly broken and even
allowed a name with no prefix to match nodes in all namespaces but with
the same local name.

I've investigated why the Jaxen tests won't run - it fails when
estimating the number of text nodes in a dom4j test document. Turns out
the SAXReader used to load the test document doesn't merge adjacent text
nodes. I'll make the following changes if I hear no objections:

* Make the dom4j DocumentNavigator getDocument() method use a SAXReader
with mergeAdjacentText set to true
* Make the DocumentNavigatorTest getDocument() method call the dom4j
DocumentNavigator getDocument() method.

However, although CData is treated like text (as it should), there's
currently no mechanism to merge adjacent CData and normal text nodes so
they only show up as one in the DocumentNavigator - I would expect this
to happen based on the Text Nodes section in the XPath spec:

"5.7 Text Nodes
Character data is grouped into text nodes. As much character data as
possible is grouped into each text node: a text node never has an
immediately following or preceding sibling that is a text node. 
[...]
Each character within a CDATA section is treated as character data.
Thus, <![CDATA[<]]> in the source document will treated the same as
&lt;. Both will result in a single < character in a text node in the
tree. Thus, a CDATA section is treated as if the <![CDATA[ and ]]> were
removed and every occurrence of < and & were replaced by &lt; and &amp;
respectively."

Any ideas?

-- Steen
[EMAIL PROTECTED]

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:jaxen-interest-admin@;lists.sourceforge.net] On Behalf 
> Of Steen Lehmann
> Sent: 7. november 2002 15:34
> To: [EMAIL PROTECTED]
> Subject: [Jaxen] Problem with DefaultNameStep introduced in rev. 1.24?
> 
> 
> Hi,
> 
> I'm trying to build my own dom4j.jar file with the latest 
> Jaxen from the cvs, but am running into problem running the 
> dom4j tests.
> 
> The dom4j DocumentNavigator returns a ClassCastException, 
> which I believe stem from the following piece of code added 
> as of rev. 1.24 (after 1.0 FCS). The type int gets the value 
> 0 for Element and Namespace nodes, which causes the later 
> call to nav.getElementNamespaceUri( node ) to freak out. My 
> guess is the intention is only Element nodes should have a 
> type of 0. If this is the case I suggest making it a boolean 
> named "isElement" since 'type' says very little.
> 
> BTW I can't run the Jaxen tests because of some issue with 
> whitespace handling (too many text nodes).
> 
> -- Steen
> 
>     public boolean matches(Object node,
>                            ContextSupport contextSupport)
>     {
>         Navigator nav  = contextSupport.getNavigator();
>         String  myUri     = null;
>         String nodeName = null;
> 
>         int type = 0;
>         if ( nav.isElement( node ) )
>         {
>             nodeName = nav.getElementName( node );
>         }
>         else if ( nav.isAttribute( node ) )
>         {
>             nodeName = nav.getAttributeName( node );
>             type = 1;
>         }
>         else if ( nav.isDocument( node ) )
>         {
>             return ( ! hasPrefix ) && matchesAnyName;
>         }
>         else if ( nav.isNamespace( node ) )
>         {
>             nodeName = nav.getNamespacePrefix( node );
>         }
>         else
>         {
>             return false;
>         }
> 
>         // System.out.println( "Matching nodeURI: " + nodeUri 
> + " name: " + nodeName );
> 
> 
>         if ( hasPrefix )
>         {
>             myUri = 
> contextSupport.translateNamespacePrefixToUri( this.prefix );
>             // If we have a prefix that does not map to no namespace,
>             // but the node doesn't have *any* namespace-uri, 
> then we fast-fail.
> 
>             String nodeUri = null;
>             switch(type){
>                 case 0:
>                     nodeUri  = nav.getElementNamespaceUri( node );
>                 break;
>                 case 1:
>                     nodeUri  = nav.getAttributeNamespaceUri( node );
>                 break;
>             }
> 
>             if ( ( myUri != null   && !"".equals( myUri ) )
>                  &&
>                  ( nodeUri == null || "".equals( nodeUri ) ) )
>             {
>                 return false;
>             }
>         }
>         else if ( matchesAnyName )
>         {
>             return true;
>         }
> 
> 
> 
> -------------------------------------------------------
> This sf.net email is sponsored by: See the NEW Palm 
> Tungsten T handheld. Power & Color in a compact size! 
> http://ads.sourceforge.net/cgi-bin/redirect.pl?> palm0001en
> 
> _______________________________________________
> 
> Jaxen-interest mailing list [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jaxen-interest
> 



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Jaxen-interest mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jaxen-interest

Reply via email to