Closed Bug 327730 Opened 18 years ago Closed 17 years ago

indentical namespace declared twice in root node of submitted xml data (post) if not specified in instance tag.

Categories

(Core Graveyard :: XForms, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: klaus.bitto, Unassigned)

References

Details

Attachments

(6 files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20060123 Firefox/1.5
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20060123 Firefox/1.5

If you have no xmlns declared in xforms:instance, the root node of the submitted xml data (on method="post" for the referenced submission) contains the xmlns:prefix="..." twice. This leads to DOM parsers throwing warnings or errors.

See the following: (testcase1.xhtml)
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:gd="http://www.example.com/~klausbitto/namespace" xml:lang="en" lang="en">
	<head>
		<title>Test: namespace doubled submission bug</title>
		<xf:model>
			<xf:instance>
				<gd:instancedataroot>
					<gd:somedata>
						Text node goes here.
					</gd:somedata>
				</gd:instancedataroot>
			</xf:instance>
			<xf:submission action="file:///D:/Temp/xhtmloutput1.xml" method="put" id="sub" />
		</xf:model>
	</head>
	<body>
		<xf:submit submission="sub"><xf:label>Submit</xf:label></xf:submit>
	</body>
</html>

Produces on submit: (xmloutput1.xml)
<?xml version="1.0" encoding="UTF-8"?>
<gd:instancedataroot xmlns:gd="http://www.example.com/~klausbitto/namespace" xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:gd="http://www.example.com/~klausbitto/namespace">
					<gd:somedata>
						Text node goes here.
					</gd:somedata>
				</gd:instancedataroot>

However this does not happen when a xmlns is used in xforms:instance and thus the created data uses no namespace at all:

testcase2.xhtml:

<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:gd="http://www.example.com/~klausbitto/namespace" xml:lang="en" lang="en">
	<head>
		<title>Test: namespace doubled submission bug</title>
		<xf:model>
			<xf:instance>
				<gd:instancedataroot xmlns="http://www.example.com/~klausbitto/namespace">
					<gd:somedata>
						Text node goes here.
					</gd:somedata>
				</gd:instancedataroot>
			</xf:instance>
			<xf:submission action="file:///D:/Temp/xhtmloutput2.xml" method="put" id="sub" />
		</xf:model>
	</head>
	<body>
		<xf:submit submission="sub"><xf:label>Submit</xf:label></xf:submit>
	</body>
</html>

leads to xmloutput2.xml:

<?xml version="1.0" encoding="UTF-8"?>
<instancedataroot xmlns="http://www.example.com/~klausbitto/namespace" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:gd="http://www.example.com/~klausbitto/namespace">
					<somedata>
						Text node goes here.
					</somedata>
				</instancedataroot>

Reproducible: Always

Steps to Reproduce:
1. Copy the code above into xhtml / xml files.
2. Run both xhtml files and view the resulting xml files.


Actual Results:  
If the user namespace is preserved in the submission data, the namespace declaration is duplicated.

Expected Results:  
No second declaration.
This is possibly related to bug 326994, though it is possible
that http://lxr.mozilla.org/seamonkey/source/extensions/xforms/nsXFormsSubmissionElement.cpp#1032
has something to do with this too...
(In reply to comment #5)
> This is possibly related to bug 326994, though it is possible
> that
> http://lxr.mozilla.org/seamonkey/source/extensions/xforms/nsXFormsSubmissionElement.cpp#1032
> has something to do with this too...
> 

Yes, I guess it is. I'll investigate the problem.
The first testcase is some different from the one described in bug 326994 (I filed    a bug 329479 related with it). But I guess the second testcase is not problem because result xml seems to be valid and I can't see in the specs to it would address to that. Relly there is nothing bad in such dublication.
Attached file testcase
The simple testcase (testcase attachment) showing the first issue. Probably Peter can helps because problem is related with xml.
See bug 326994 comment 8 (AddNameSpaces uses SetAttribute).
Attached file setAttributeNS test
(In reply to comment #10)
> See bug 326994 comment 8 (AddNameSpaces uses SetAttribute).
> 

setAttributeNS(XMLNS_NS, attrName, attrValue) throws an exception "An attempt was made to create or change an object in a way which is incorrect with regard to namespaces".

Probably I do something wrong. Peter, can you get a testcase what sets namespace attribute?
root.setAttributeNS(XMLNS_NS, "xmlns:foo", "http://www.w3.org/1999/foo");
The first issue will be fixed by the bug 329479 patch. The second imo isn't a bug. If you agree with me about second issue then please mark this bug as dublicate of 329479.
Status: UNCONFIRMED → NEW
Depends on: 329479
Ever confirmed: true
OS: Windows XP → All
Hardware: PC → All
Assignee: aaronr → xforms
I tried this today on trunk.  Works for me.  Closing this as WORKSFORME.  Please reopen if you feel that this is still a problem.
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → WORKSFORME
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: