Closed
Bug 45627
Opened 24 years ago
Closed 24 years ago
XMLSerializer::serializeToString() doesn't recognize empty elements
Categories
(Core :: XML, defect, P3)
Core
XML
Tracking
()
VERIFIED
FIXED
mozilla0.9
People
(Reporter: taras.tielkes, Assigned: hjtoi-bugzilla)
Details
(Whiteboard: [fixinhand, fixes 45552 too])
Attachments
(8 files)
(deleted),
patch
|
Details | Diff | Splinter Review | |
(deleted),
text/xml
|
Details | |
(deleted),
patch
|
Details | Diff | Splinter Review | |
(deleted),
patch
|
Details | Diff | Splinter Review | |
(deleted),
patch
|
Details | Diff | Splinter Review | |
(deleted),
text/xml
|
Details | |
(deleted),
patch
|
Details | Diff | Splinter Review | |
(deleted),
patch
|
Details | Diff | Splinter Review |
var xmlDoc = document.implementation.createDocument("", "x", null);
alert( new XMLSerializer().serializeToString( xmlDoc ) );
-------------------------------------------------------------
This will show "<x></x>".
This is absolutely correct, but it would be nice if XMLSerializer would
recognize that an element is empty, and output an empty element tag. This will
save some space with larger documents with a lot of empty elements.(Trivial
though, but looks nice)
Assignee | ||
Updated•24 years ago
|
Target Milestone: --- → mozilla0.9
Assignee | ||
Comment 2•24 years ago
|
||
Assignee | ||
Comment 3•24 years ago
|
||
Assignee | ||
Comment 4•24 years ago
|
||
Assignee | ||
Comment 5•24 years ago
|
||
Assignee | ||
Comment 6•24 years ago
|
||
Assignee | ||
Comment 7•24 years ago
|
||
jst pointed out that we already have content serializers in layout. I removed
code duplication by calling the implementation in layout dir. While doing this I
noticed several bugs in the implementation there, namely:
- empty elements are not output as empty
- HTML tags get uppercased
- default namespace somehow gets assigned the prefix "xmlns" for output
- HTML tags get the HTML namespace declaration attribute twice
- script tag contents do not get output in testcase 1
My patches 1/2, 2/2 and 3/3 applied together fix all but the last two problems.
They are still suboptimal (too many string operations to my liking, and if
someone actually declared namespace prefix "xmlns" we would not output that).
This fix also fixes bug 45552.
Whiteboard: [fixinhand, fixes 45552 too]
Assignee | ||
Comment 8•24 years ago
|
||
I am taking all XMLExtras bugs to make it easier to see what I am working on...
Assignee: vidur → heikki
Status: ASSIGNED → NEW
Assignee | ||
Comment 9•24 years ago
|
||
PIs seem to be missing as well.
Assignee | ||
Comment 10•24 years ago
|
||
Assignee | ||
Comment 11•24 years ago
|
||
Assignee | ||
Comment 12•24 years ago
|
||
Assignee | ||
Comment 13•24 years ago
|
||
The last patch to layout/base enables ConfirmPrefix again. Now I know the
purpose: it is needed in case some script was moving elements around, for instance.
Also, because HTML elements do not really understand namespaces, they do not
report the namespace prefix properly - rather the name contains the prefix and
the actual name. There are quite a few hacks to work around this.
I have opened new bugs to track the issues that I have found while working with
this:
- bug 63559 DOMParser loses HTML element attributes
- bug 63558 XMLSerializer does not serialize starting XML PI
- bug 63560 XMLSerializer does not output html:script contents
- bug 63561 XMLSerializer does not output comments and PIs after document
element close
Comment 14•24 years ago
|
||
r=vidur. We should get the document encoder to work on free-standing subtrees as
well.
Assignee | ||
Comment 15•24 years ago
|
||
Bug 63568 opened to track the issue of serializing free-standing subtrees.
Status: NEW → ASSIGNED
Comment 16•24 years ago
|
||
sr=jst for the patches 1/2, 2/2 and the last patch.
I have one coding style nitpick about the last patch, code like this:
if (!content) return NS_ERROR_FAILURE;
I'd prefer seeing that either either broken up on two lines or:
NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
... but I'd accept the patch as is if you don't wanna change that.
I think the namespace code could be cleaned up alot once our HTML elements use
nsINodeInfo so that prefixes and namespaces are always correctly preserved.
Assignee | ||
Comment 17•24 years ago
|
||
Fixed.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•