Closed Bug 2480 Opened 26 years ago Closed 26 years ago

Default namespaces not implemented

Categories

(Core :: DOM: HTML Parser, defect, P2)

x86
Windows NT
defect

Tracking

()

VERIFIED FIXED

People

(Reporter: cohn, Assigned: vidur)

Details

The current implementation of namespaces uses the prefix to identify the namespace, so the prefix 'HTML' has special meaning. According to the namespace spec, it's the URI that should be checked and not the prefix. The current implementation prevents default namespaces from working (e.g., you can't set the default namespace to "http://www.w3.org/TR/REC-html40"). Also, if you try setting a default namespace now, you can an assertion failure: In nsXMLContentSink::PushNameSpacesFrom PRUnichar next = k.CharAt(sizeof(kNameSpaceDef)-1); // If the next character is a :, there is a namespace prefix should be PRUnichar next = k.Length() >= sizeof(kNameSpaceDef) ? k.CharAt(sizeof(kNameSpaceDef)-1) : 0; Since kNameSpaceDef is "xmlns", sizeof (kNameSpaceDef) is 6, not 5, and when you use a default namespace k is "xmlns". By the way, bugzilla lets you search on XML, but there's no component XML in the bug form.
Status: NEW → ASSIGNED
Actually, we do key off the URI and not the namespace. I haven't experimented enough with default namespaces enough. Thanks for the bug.
I should have been more precise. The problem is with nsXMLContentSink::OpenContainer and nsXMLContentSink::CloseContainer's use of the namespace prefix. It determines the namespace from the prefix of the tag. In addition, when there is no tag, it needs to see if there is a default namespace in effect.
I think you may be misreading the code (I'm hoping that you have test cases that demonstrate each of the bugs). The call IsHTMLNameSpace() in nsXMLContentSink simply checks the namespace ID (a per-document construct that is unique for each URI). The HTML URI is special-cased to have a namespace ID of kNameSpaceID_HTML. I still haven't looked at the default namespace issue.
Yes, I did originally misread the code. Sorry about that. However, I believe the default namespace problem is still there. Here's the problem from OpenContainer: nameSpacePrefix = CutNameSpacePrefix(tag); // if there's a default namespace the nameSpacePrefix is null PushNameSpacesFrom(aNode); // will push the default namespace with no prefix correctly nameSpaceID = GetNameSpaceId(nameSpacePrefix); // this routine has a bug: It's first line is if (nsnull == aPrefix) { return kNameSpaceID_None; } With this line, the namespace will be none even if a default namespace has been defined. If you take this out, then a tag with no prefix will match the namespace with no prefix. (I've tried this.) If there's a performance issue, I guess you could keep track of whether there's a default namespace on the stack. Here's my test file: <?xml version="1.0"?> <?xml-stylesheet href="docbook.css" type="text/css"?> <!DOCTYPE Book System "docbook.dtd"> <Book xmlns:html="http://www.w3.org/TR/REC-html40"> <Title>The Book</Title> <Chapter> <Title>Chapter 1.</Title> <Para>Yada yada <html:img src="AniEyes.gif"/> yada. <g xmlns="http://www.w3.org/TR/WD-svg"> <!-- SVG name space applies to <g> element --> <rectangle x="10" y="10" width="50" height="50"/> </g> </Para> </Chapter> </Book>
Yeah, good catch. I think that one's my fault. The nsINameSpace was designed to accept nsnull for a prefix and return the default namespace if there was one in effect. The offending if (nsnull == aPrefix) should be removed from GetNameSpaceId.
Sounds good. I'll make the change, including Richard Cohn's suggestion about kNameSpaceID_None vs. kNameSpaceID_Unknown.
Setting all current Open/Normal to M4.
per leger, assigning QA contacts to all open bugs without QA contacts according to list at http://bugzilla.mozilla.org/describecomponents.cgi?product=Browser
Status: ASSIGNED → RESOLVED
Closed: 26 years ago
Resolution: --- → FIXED
Fixed a while back. I forgot to close the bug.
Don't have access to the .css file so I made a small test case coded as follows: <?xml version="1.0"?> <doc> <test xmlns:html="http://www.w3.org/TR/REC-html40"> <html:b>This sentence should be bolded based on Namespace functionality</html:b> </test> </doc> Using 6/16 Apprunner, verifying bug fixed.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.