Closed
Bug 157933
Opened 23 years ago
Closed 23 years ago
Namespaces are not recognized by XPath
Categories
(Core :: XSLT, defect)
Tracking
()
RESOLVED
WONTFIX
People
(Reporter: asagatov, Assigned: peterv)
Details
I'm trying to use Xpath search engine for XML documents containing namespaces.
And it appears that it's impossible to query for an element with namespace prefix.
I'm trying to run the following script:
function bodyOnLoad()
{
sXML_ns =
'<?xml version="1.0" encoding="UTF-8"?><saw:wasq
xmlns:saw="http://kkk"><petyk><saw:bob/></petyk></saw:wasq>';
docXML_ns=(new DOMParser()).parseFromString(sXML_ns, "text/xml");
rslv = docXML_ns.createNSResolver(docXML_ns.documentElement);
//test N1 - try to resolve NS prefix
alert("saw URI: " + rslv.lookupNamespaceURI('saw'));
//test N2 - selectSingleNode; no namespaces
var tPT = selectSingleNode(docXML_ns.documentElement,"petyk",rslv);
alert("tPT == null: " + (tPT == null));
if (tPT != null)
alert("eval = " + (new XMLSerializer()).serializeToString(tPT));
//test N2 - selectSingleNode; namespaces
tPT = selectSingleNode(docXML_ns.documentElement,"petyk/saw:bob",rslv);
alert("tPT == null: " + (tPT == null));
if (tPT != null)
alert("eval = " + (new XMLSerializer()).serializeToString(tPT));
}
function selectSingleNode(elem,expr,rslv)
{
return elem.ownerDocument.evaluate(expr, elem, rslv, 0, null).iterateNext();
}
Results:
Test 1 works - namespace prefix is resolved correctly using NS resolver.
Test 2 works - search for an element without namespace prefix returns correct
result.
Test 3 fails. Instead of an expected element it returns null.
Version of Mozilla browser I'm using (from Help/About screen) is:
Mozilla 1.0
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.0) Gecko/20020530
Please help. We are trying to port existing IE application to Mozilla and this
bug is really critical for us.
Thanks,
Azamat
Comment 1•23 years ago
|
||
Over to the owner of the XPath code and ccing more XPath people.
Assignee: jst → peterv
This is a known problem for the 1.0 release. Try a tipbuild (or it might even
work with an 1.1alpha)
Azamat: could you please try this with a more recent build. It should be fixed
in the 1.1beta release.
Component: DOM Other → XSLT
Marking as worksforme. If this still doesn't work for you with a recent nightly
then please reopen this bug
Status: UNCONFIRMED → RESOLVED
Closed: 23 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•