I'm using xalan-j-2.3.1 When I parse a document like this using Xerces 2.1.0 DOMParser:
<?xml version="1.0" ?> <interaction xmlns="http://webalo.com/xmlns/ups-ial-ais" xmlns:ais="http://webalo.com/xmlns/ups-ial-ais" xmlns:ns1="http://webalo.com/MyGoogle" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <instructions> <getInstruction> <verb>get</verb> <ais:instance xsi:type="ns1:GoogleSearchQuery" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://webalo.com/MyGoogle" > <restrict></restrict> <safeSearch>false</safeSearch> </ais:instance> </getInstruction> </instructions> </interaction> I must use paths like: //:verb /:interaction/:instructions from the XPathAPI in order to access the data. If I use paths like //verb no nodes are found. Now that I look at the xalan-j faqs, I see that perhaps this is not supposed to work. If that is true, I believe it to be a defect in the xalan xpath implementation, which, if conforming to the XSLT spec, should work on any legal namespace-aware document (in this case, the real document from which I excerpted the piece above is validated to the highest extent by Xerces against its schema).. It is not a reasonable solution to "Add a namespace declaration with a prefix...." as the FAQ suggests, since we all must process documents that are produced beyond our control. Presumably it will not work to transform the documents using xalan-j to add the prefix, since the transformation will depend on xpath and that will fail.. For a generic tool like xalan-j to carve out a subset of legal and valid xml documents on which to work correctly seems a mistake to me. There is a well-defined mapping at any element node of the above document between prefixes (including the null prefix) and namespaces, and there's no good reason why xpath could not be made to use it, either using colons or not for the no-prefix namespace. Jeff ----- Original Message ----- From: "Joseph Kesselman" <[EMAIL PROTECTED]> To: "Jeff Greif" <[EMAIL PROTECTED]> Cc: "Dominique Devienne" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Tuesday, November 26, 2002 3:11 PM Subject: Re: xpath constructor > Uhm... If Xalan's really accepting that syntax, it's a bug and we should > fix it. > > If you want to access namespaced nodes, you'll have to start the names in > your XPath with a *PREFIX*, not just with a colon, and you'll have to > provide a prefix resolver to map those to the appropriate URIs. > > Leading colon without a prefix does *not* mean "default namespace". > > XPath 2.0 introduces an architected concept of > default-namespace-for-this-XPath. It doesn't use a bare leading colon > either. > > > > ______________________________________ > Joe Kesselman / IBM Research >
