Closed
Bug 326994
Opened 19 years ago
Closed 19 years ago
XMLSerializer adds namespace declaration for non-empty prefix with empty namespace name
Categories
(Core :: XML, defect)
Core
XML
Tracking
()
RESOLVED
FIXED
People
(Reporter: surkov, Assigned: peterv)
References
Details
Attachments
(2 files, 3 obsolete files)
(deleted),
patch
|
bzbarsky
:
review+
bzbarsky
:
superreview+
|
Details | Diff | Splinter Review |
(deleted),
application/xml
|
Details |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9a1) Gecko/20051212 Firefox/1.6a1
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9a1) Gecko/20051212 Firefox/1.6a1
When instance is created dynamically then instance document submitted with namespace prefix "a0". Something like that:
<a0:root xmlns:a0="" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"/>
The problem is DOMParser fails when it parse such document.
Probably it is isn't xforms problem and I just want to understand what's happen.
Reproducible: Always
Reporter | ||
Comment 1•19 years ago
|
||
Reporter | ||
Comment 2•19 years ago
|
||
Attachment #211719 -
Attachment is obsolete: true
Reporter | ||
Comment 3•19 years ago
|
||
The first issue isn't related with XForms. I'm not sure whether the issue is bug or not but the strange behaviour surely. If element has attribute xmlns="uri1" and I set attribute xmlns="uri2" on it then element has two attributes xmlns="uri2" and xmlns:a0="uri1". When I serialize the element and then I parse it then I get exception.
Reporter | ||
Comment 4•19 years ago
|
||
The second issue is related with xforms, and it probably isn't a bug too. But I guess it is needed in some discussion. The question is following. If instance document root contains default empty namespace (xmlns="") then why we should change default namespace on it from owner document? In instance:
<html xmlns="xhtml namespace uri"
xmlns:xforms="xforms namespace uri">
<xforms:model>
<xforms:instance>
<instanceRoot xmlns=""/>
</xforms:instance>
</xforms:model>
</html>
Result:
<a0:instanceRoot xmlns:a0="" xmlns="html namespace uri"/>
I can't see the utility of it. Any reason?
Updated•19 years ago
|
Attachment #211720 -
Attachment mime type: text/plain → application/xhtml+xml
Comment 5•19 years ago
|
||
Hmm, there seems to be something weird happening. At least you should be able to serialize some XML, and then parse it afterwards.
Peter, can you educate us here? :)
Assignee | ||
Comment 6•19 years ago
|
||
About what?
Comment 7•19 years ago
|
||
(In reply to comment #6)
> About what?
About why we get a parseerror in attachment 211807 [details]
This happens on trunk, but on on 1.8.0.
Assignee | ||
Comment 8•19 years ago
|
||
You need to use setAttributeNS to set xmlns attributes. You're adding a xmlns attribute with no namespace, there's no good way to serialize that. Also see http://lxr.mozilla.org/seamonkey/source/content/base/src/nsXMLContentSerializer.cpp#600
IMHO we should throw on the setAttribute call.
Comment 10•19 years ago
|
||
(In reply to comment #8)
> You need to use setAttributeNS to set xmlns attributes. You're adding a xmlns
> attribute with no namespace, there's no good way to serialize that. Also see
> http://lxr.mozilla.org/seamonkey/source/content/base/src/nsXMLContentSerializer.cpp#600
Ah.
(In reply to comment #9)
> IMHO we should throw on the setAttribute call.
That would be nice. I would have caught the error earlier at least.
Reporter | ||
Comment 11•19 years ago
|
||
(In reply to comment #8)
> You need to use setAttributeNS to set xmlns attributes. You're adding a xmlns
> attribute with no namespace, there's no good way to serialize that. Also see
> http://lxr.mozilla.org/seamonkey/source/content/base/src/nsXMLContentSerializer.cpp#600
>
Do you mean I should write the something like that?
root.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", "http://www.w3.org/1999/xhtml");
The behaviour remains the same.
Reporter | ||
Comment 12•19 years ago
|
||
(In reply to comment #4)
> The second issue is related with xforms, and it probably isn't a bug too. But I
> guess it is needed in some discussion. The question is following. If instance
> document root contains default empty namespace (xmlns="") then why we should
> change default namespace on it from owner document?
>
> I can't see the utility of it. Any reason?
>
I can't find anything in the specs about inheritance default namespace. Note, if I understand right, model owner document, model element, instance element and instance document can have different default namespaces. There is not a way to control default naemspaces. Imo the default namespaces should not be inherited. Am I wrong?
Btw #default value in @includenamespaceprefixes isn't supported.
Assignee | ||
Comment 13•19 years ago
|
||
Morphing this bug, please file the XForms issue as a separate bug if it is one. We should not add a namespace declaration for a non-empty prefix with an empty namespace name, see http://www.w3.org/TR/REC-xml-names/#dt-prefix
Assignee: aaronr → xml
Status: UNCONFIRMED → NEW
Component: XForms → XML
Ever confirmed: true
QA Contact: spride → ashshbhatt
Summary: dynamic instance submission issue → XMLSerializer adds namespace declaration for non-empty prefix with empty namespace name
Assignee | ||
Comment 14•19 years ago
|
||
Boris, what do you think? This patch makes us drop an attribute in the case of:
var doc = ParseXML('<root xmlns=""/>')
var root = doc.documentElement;
root.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns",
"http://www.w3.org/1999/xhtml");
so when serializing root we end up with:
<root/>
The alternative is to output:
<root xmlns:a0="http://www.w3.org/1999/xhtml"/>
Note that in the case of
var doc = ParseXML('<root xmlns="http://www.w3.org/1999/xhtml"/>')
var root = doc.documentElement;
root.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns",
"");
we output:
<a0:root xmlns:a0="http://www.w3.org/1999/xhtml" xmlns=""/>
Assignee: xml → peterv
Status: NEW → ASSIGNED
Attachment #212110 -
Flags: superreview?(bzbarsky)
Attachment #212110 -
Flags: review?(bzbarsky)
Assignee | ||
Comment 15•19 years ago
|
||
Attachment #211720 -
Attachment is obsolete: true
Attachment #211807 -
Attachment is obsolete: true
Comment 16•19 years ago
|
||
Comment on attachment 212110 [details] [diff] [review]
v1
>Index: content/base/src/nsXMLContentSerializer.cpp
>+ skipAttr = index;
Right before that, assert that skipAttr == count? Or can we not do that? That is, can we have two separate prefix-less "xmlns" attrs? If we can, it seems like this fix won't work...
Or is the plan to do this and then throw on prefix-less xmlns attrs not in the xmlns namespace?
r+sr=bzbasky with that sorted out.
Attachment #212110 -
Flags: superreview?(bzbarsky)
Attachment #212110 -
Flags: superreview+
Attachment #212110 -
Flags: review?(bzbarsky)
Attachment #212110 -
Flags: review+
Assignee | ||
Comment 17•19 years ago
|
||
(In reply to comment #16)
> Or is the plan to do this and then throw on prefix-less xmlns attrs not in the
> xmlns namespace?
Yes, and it's bug 315805.
Assignee | ||
Updated•19 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•