Hi Jim, >> How do I declare and pass the method selectSingleNode() a namespace two ways:
1) Using XPathAPI.selectSingleNode(Node contextNode, String str, Node namespaceNode), where "namespaceNode" contains namespaces declarations, i.e. has "xmlns:X" attributes. 2) Using XPathAPI.eval(Node contextNode, String str, PrefixResolver prefixResolver), where you'll have your own implementation of PrefixResolver which will map namespace to prefix. thanks, Dimitry -----Original Message----- From: Jim Maskus [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 24, 2003 13:55 To: [EMAIL PROTECTED] 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, "//name"); Node n2 = XPathAPI.selectSingleNode(doc, "//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, "//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
