Closed Bug 367090 Opened 17 years ago Closed 14 years ago

JavaScript XPath fails with mixed-caps in element names

Categories

(Firefox :: General, defect)

PowerPC
macOS
defect
Not set
normal

Tracking

()

RESOLVED INCOMPLETE

People

(Reporter: westbaystars, Unassigned)

Details

(Whiteboard: [CLOSEME 2010-11-01])

User-Agent:       Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1
Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1

Running XPath queries on XML documents where all element names are all lower case works fine.  However, XML documents with mixed case fail.

Works: "//person/personid"
<people>
  <person>
    <personid>1</personid>
    . . .
  </person>
  . . .
</people>

Fails: "//Person/PersonID"
<People>
  <Person>
    <PersonID>1</PersonID>
    . . .
  </Person>
  . . .
</People>


Reproducible: Always

Steps to Reproduce:
1. Setup xpath method:

xpath = function (doc, path, asString) {
	var type = XPathResult.ANY_TYPE;
	if (asString) {
		type = XPathResult.STRING_TYPE;
	}
	if (!doc) {
		return null;
	}
	var rValue = document.evaluate(path, doc, NSResolver, type, null);
	if (asString) {
		return rValue.stringValue;
	} else {
		return rValue;
	}
};

2. AJAX application queries XML document

3. XML document with mixed case tag names is returned to callback function as doc

4. var pid = xpath(doc, "//Person/PersonID", true);

5. Try with "//person/personid"

6. Return XML with all lower case element names
Actual Results:  
#4 returns an empty string to pid

#5 returns an empty string to pid

#6 returns "1" to pid - correct

Expected Results:  
Expected "1" for both #4 and #6.

Expected empty string for #5.

Using FireBug, I see that tag names (localName, tagName, nodeName properties) are in mixed case for the various nodes in the result XML document.  However, it shows the node for PersonID as "<personid>" in the debugger.  I don't know if that is something that FireBug displays or if it's something in the Mozilla DOM.
This is a mass search for bugs that are in the Firefox General component, are UNCO, and have not been changed for 1000 days and have an unspecified version. 

Reporter, can you please update to Firefox 3.6.10, create a fresh profile, http://support.mozilla.com/en-US/kb/managing+profiles, and test again. If you still see the bug, please update this bug. If the issue is gone, please set the resolution to RESOLVED > WORKSFORME.
Whiteboard: [CLOSEME 2010-11-01]
No reply from reporter, INCOMPLETE. Please retest with Firefox 3.6.12 or later and a new profile (http://support.mozilla.com/kb/Managing+profiles). If you continue to see this issue with the newest firefox and a new profile, then please comment on this bug.
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → INCOMPLETE
Problem exists in version 60.3.0

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<title>jsXpath</title>
</head>
<body>
	<tox>
		<data>
			<lower>
				<str>lower case element test</str>
				<int>1</int>
			</lower>
			<miXed>
				<str>mixed case element test</str>
				<int>2</int>
			</miXed>
		</data>
	</tox>
	<script>
	var xpe = new XPathEvaluator();
	// lower
	var lowerStr = xpe.evaluate("//tox/data/lower/str",document,null,XPathResult.STRING_TYPE,null);
	console.log("lowerStr = "+lowerStr.stringValue);
	var lowerInt = xpe.evaluate("//tox/data/lower/int",document,null,XPathResult.NUMBER_TYPE,null);
	console.log("lowerInt = "+lowerInt.numberValue);
	//
	console.log("----");
	// mixed does not work in Firefox
	var mixedStr = xpe.evaluate("//tox/data/miXed/str",document,null,XPathResult.STRING_TYPE,null);
	console.log("mixedStr = "+mixedStr.stringValue);
	var mixedInt = xpe.evaluate("//tox/data/miXed/int",document,null,XPathResult.NUMBER_TYPE,null);
	console.log("mixedInt = "+mixedInt.numberValue);
	</script>
</body>
</html>
You need to log in before you can comment on or make changes to this bug.