Re: XML Declaration

Martin Honnen <[email protected]>
Newsgroups gmane.comp.mozilla.devel.xml
Organization Liberty Development
Message-ID <dmhugf$2ui2__10268.5220692821$1133282476$gmane$org@ripley.aoltw.net>

Jonas Sicking wrote:

> bruno vernay wrote:
> 
>> Dirty hack :
>>     var piElem = doc.createProcessingInstruction("xml", "version='1.0'
>> encoding='UTF8'");
> 
> 
>>  - a XML Declaration is not a Processing Instruction
>> Real dirty ...
> 
> 
> Yeah, it is in fact so dirty that it should not work. Could you file a 
> bug in bugzilla about that and post the bug number here.


Where is the bug in your view, should the DOM not allow creating such a 
processing instruction or should the serializer bark at that processing 
instruction when serializing the document?

Unfortunately the DOM in W3C DOM Level 2 for createProcessingInstruction 
is not too specific on what kind of target arguments should throw 
errors. <http://www.w3.org/TR/DOM-Level-2-Core/core.html#i-Document> says:
   "Exceptions
    DOMException
     INVALID_CHARACTER_ERR: Raised if the specified target contains an 
illegal character."

DOM Level 3 (although Mozilla does not support much of that so far) is a 
bit more specific. 
<http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-135944439> says:
   "Exceptions
    DOMException
      INVALID_CHARACTER_ERR: Raised if the specified target is not an 
XML name according to the XML version in use specified in the 
Document.xmlVersion attribute."

But even with that if we look at <http://www.w3.org/TR/REC-xml/#NT-Name> 
there are no restrictions for XML names itself to be e.g. "xml".

Only <http://www.w3.org/TR/REC-xml/#sec-pi> clearly excludes e.g. "xml" 
or "XML" as target names for processing instructions but there is 
nothing in the DOM spec saying that createProcessingInstruction should 
implement that rule.

I have made a test case here:
<http://home.arcor.de/martin.honnen/mozillaBugs/domLevel2/CreateXMLDeclarationAsProcessingInstruction1.html>
It is easy filing a bug with that but I am not sure about the component, 
i.e. DOM with createProcessingInstruction or XML with XMLSerializer.

None of the other DOM implementations I have tested (the above test case 
with IE 6 and MSXML, with Opera 8.5 and Opera 9 Preview; a short Java 
test program using the built-in DOM in Java 1.4 and 1.5) throw an error 
on createProcessingInstruction with target "xml".

-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.