Hi:

Try this:


                final Element java =
doc.getOwnerDocument().createElement("DslContext");
                java.setAttribute("xmlns:dsl",
"http://www.applyweb.com/dsl";);

                // for eval function
                XPathAPI.eval(node, xpath_expr, new
PrefixResolverDefault(java));

                // for select*** function
                XPathAPI.selectSingleNode(node, xpath_expr, java);

Bye.



----- Original Message -----
From: "Jim Maskus" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 24, 2003 10:54 PM
Subject: XpathAPI and namespaces


> Source
> <dsl:select-list-set xmlns:dsl="http://www.applyweb.com/dsl";>
> <dsl:select-list name="MAJOR" id="Major" />
> <dsl:select-list name="DEGREE" id="Degree" />
> </dsl:select-list-set>
>
> I'm trying to query a DOM tree in Java as follows...
>
> // Set up a DOM tree to query.
> InputSource in = new InputSource(new FileInputStream(inFile));
> DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
> dfactory.setNamespaceAware(true);
> Document doc = dfactory.newDocumentBuilder().parse(in);
>
> Node n1 = XPathAPI.selectSingleNode(doc, "file://name");
> Node n2 = XPathAPI.selectSingleNode(doc, "file://address");
>
> The call to selectSingleNode() code works until I look for an element
> with a namespace which results in the following error...
> Node n3 = XPathAPI.selectSingleNode(doc, "file://dsl:select-list-set");
> Exception in thread "main" javax.xml.transform.TransformerException:
> Prefix must resolve to a namespace: dsl
>
> How do I declare and pass the method selectSingleNode() a namespace
> node as a third parameter.
> Jim
>
>

Reply via email to