XMLSerializer produces uppercase XHTML tags when serializing editor content
RESOLVED
DUPLICATE
of bug 55313
Status
()
People
(Reporter: Cedric. S., Assigned: Heikki Toivonen (remove -bugzilla when emailing directly))
Tracking
Firefox Tracking Flags
(Not tracked)
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 When trying to serialize the content of an <editor> tag, entered by the user, the string produced contains valid XML (i.e. converion of HTML in well formed XML occured), but the names of the tags are in uppercase, thus being invalid XHTML. Reproducible: Always Steps to Reproduce: 0. - install test.xul somewhere in your chrome directory. - in the browser, type the url chrome://mychrome/content/test.xul 1. click edit 2. type text, click bold and type bold text 3. click view source to see editor's documentElement.innerHTML (tags in lowercase) 4. click to XHTML to see the string produced by the serialized (well formed XML, but tags in uppercase). The wul code to perform the test : --------------------- <?xml version="1.0"?> <!-- Sample XUL file --> <page xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" debug="false" > <script type="application/x-javascript"><!-- src="test.js">--> function getEditor() { return document.getElementById('editor') ; } function edit() { getEditor().contentDocument.designMode="on" ; getEditor().contentWindow.focus() ; } function bold() { getEditor().contentDocument.execCommand('bold',false,null) ; getEditor().contentWindow.focus() ; } function vsrc() { alert( getEditor().contentDocument.documentElement.innerHTML ) ; } function toXhtml() { var s = new XMLSerializer() ; alert( s.serializeToString(getEditor().contentDocument) ) ; } </script> <hbox> <button label="edit" oncommand="edit();"/> <button label="bold" oncommand="bold();"/> <button label="view source" oncommand="vsrc();"/> <button label="to xhtml" oncommand="toXhtml();"/> </hbox> <vbox height="100%" width="100%" flex="1"> <editor flex="1" id="editor" srx="about:blank" style="border-style:solid;"/> </vbox> </page>
![]() |
||
Comment 1•15 years ago
|
||
<editor> only handles HTML. That means that the tags are in fact _NOT_ XHTML tags, but HTML ones, and canonical serialization should uppercase them, per the HTML DOM spec. Now innerHTML is done for compat with IE and hence does not follow the DOM spec. In any case, this is a duplicate of the Editor bug on handling XHTML.
Whiteboard: DUPEME
(Reporter) | ||
Comment 2•15 years ago
|
||
I understand. This makes perfect sense. Below is a little dirty function to transform the XMLized HTML into xhtml. Should I do something with the bug report ? --- function EditorContentToXhtml() { // 1. serialize editor's content as valid XML (but still invalid XHTML) var str = new XMLSerializer().serializeToString( getEditor().contentDocument ); // 2. change DOCTYPE string to be XHTML doctype str = str.replace( /^<!DOCTYPE[^>]*>/, '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' ) ; // 3. make the document conform(?) to XHTML by setting the tag // names in lowercase. str = str.replace( /<(\/?)([A-Z]+)/g, function (str,p1,p2,offset,s) { return '<'+p1+p2.toLowerCase() ; } ) ; return str ; }
Comment 3•15 years ago
|
||
Cedric, find the bug about Midas/editor handling xhtml properly, and mark this one DUPLICATE of that one, just as bz suggested.
(Reporter) | ||
Comment 4•15 years ago
|
||
info : http://bugzilla.mozilla.org/show_bug.cgi?id=218658 also provides a patch to import/export xhtml from the composer *** This bug has been marked as a duplicate of 55313 ***
Status: UNCONFIRMED → RESOLVED
Last Resolved: 15 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•