Hello,

I have a problem getting a JDOM Element instance from a document that
specifies a namespace URI but no prefix.  The data is similar to the
following (I have no control over the namespace):

<?xml version="1.0"?>
<Root version="1.0" xmlns="Get - Data - Request.xsd">
        <Data>
                <Element>Some Value</Element>
        </Data>
</Root>

Next, I have a String "xPathStr" whose value is the XPath to the Element
tag.  A JDOM Element "root" refers to the Root tag document.  The source
follows:

        Namespace ns = root.getNamespace();
        XPath xPath = new JDOMXPath( xPathStr );
        xPath.addNamespace( ns.getPrefix(), ns.getURI() );
        Object node = xPath.selectSingleNode( root );

        System.out.println( "namespace -> " + ns.getPrefix() + ":" + ns.getURI() );
        System.out.println( "node: " + node );

When run, the following is shown:

        namespace -> :Get - Data - Request.xsd
        node: null

By removing the "xmlns" attribute the following is shown:

        namespace -> :
        node: org.jdom.Element@HEXADDRESS

Displaying the node's text yielded "Some Value", as expected.

Anyone care to clarify what I'm doing wrong?  Many thanks in advance!

Sincerely,
Dave Jarvis


_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm

_______________________________________________
Jaxen-interest mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jaxen-interest

Reply via email to