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

Reply via email to