Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
XML Declaration
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  14 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
brunover...@gmail.com  
View profile  
 More options Nov 25 2005, 8:40 am
Newsgroups: netscape.public.mozilla.xml
From: brunover...@gmail.com
Date: 25 Nov 2005 05:40:17 -0800
Local: Fri, Nov 25 2005 8:40 am
Subject: XML Declaration
I would like to add an XML declaration to a Javascript generated
Document :

    var doc = document.implementation.createDocument("", "", null);
    var rootElem = doc.createElement("toto");
    rootElem.setAttribute("version", "12334");
    doc.appendChild(rootElem);
    var serializer = new XMLSerializer();
    serializer.serializeToStream(doc, foStream, "UTF-8");

I get no <?xml ..?> at the beginning of the file ! I tried to
appenChild a createProcessingInstruction("xml", "version='1.0'
encoding='UTF8'");
But with no success.
Thanks
Bruno


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Honnen  
View profile  
 More options Nov 27 2005, 10:41 am
Newsgroups: netscape.public.mozilla.xml
From: Martin Honnen <mahotr...@yahoo.de>
Date: Sun, 27 Nov 2005 16:41:08 +0100
Local: Sun, Nov 27 2005 10:41 am
Subject: Re: XML Declaration

brunover...@gmail.com wrote:
> I would like to add an XML declaration to a Javascript generated
> Document :

>     var doc = document.implementation.createDocument("", "", null);
>     var rootElem = doc.createElement("toto");
>     rootElem.setAttribute("version", "12334");
>     doc.appendChild(rootElem);

Note that you can shorten that to
   var doc = document.implementation.createDocument("", "toto", null);
   doc.documentElement.setAttribute("version", "12334");

>     var serializer = new XMLSerializer();
>     serializer.serializeToStream(doc, foStream, "UTF-8");

> I get no <?xml ..?> at the beginning of the file !

Do you get one if you serialize to an encoding like ISO-8859-1 where the
XML declaration is mandatory then?

--

        Martin Honnen
        http://JavaScript.FAQTs.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bruno vernay  
View profile  
 More options Nov 28 2005, 3:36 am
Newsgroups: netscape.public.mozilla.xml
From: "bruno vernay" <brunover...@gmail.com>
Date: 28 Nov 2005 00:36:53 -0800
Local: Mon, Nov 28 2005 3:36 am
Subject: Re: XML Declaration
No, using  serializer.serializeToStream(doc, foStream, "ISO-8859-1");
change the encoding, but doesn't put an XML Declaration !

Maybe I should post to netscape.public.mozilla.dom too ?

or fill a bug or a feature request ?

Thanks
Bruno


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bruno vernay  
View profile  
 More options Nov 28 2005, 3:46 am
Newsgroups: netscape.public.mozilla.xml
From: "bruno vernay" <brunover...@gmail.com>
Date: 28 Nov 2005 00:46:06 -0800
Local: Mon, Nov 28 2005 3:46 am
Subject: Re: XML Declaration
Dirty hack :
    var piElem = doc.createProcessingInstruction("xml", "version='1.0'
encoding='UTF8'");
...
    doc.appendChild(rootElem);
    doc.insertBefore(piElem, rootElem);

Note :
 - you can claim UTF-8 and encode in ISO-8859-1
 - a XML Declaration is not a Processing Instruction
Real dirty ...


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonas Sicking  
View profile  
 More options Nov 28 2005, 5:03 pm
Newsgroups: netscape.public.mozilla.xml
From: Jonas Sicking <jonas.rem...@me.sicking.cc>
Date: Mon, 28 Nov 2005 14:03:59 -0800
Local: Mon, Nov 28 2005 5:03 pm
Subject: Re: XML Declaration

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.

/ Jonas


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bruno vernay  
View profile  
 More options Nov 29 2005, 4:55 am
Newsgroups: netscape.public.mozilla.xml
From: "bruno vernay" <brunover...@gmail.com>
Date: 29 Nov 2005 01:55:19 -0800
Local: Tues, Nov 29 2005 4:55 am
Subject: Re: XML Declaration
Done : https://bugzilla.mozilla.org/show_bug.cgi?id=318086
In fact it is working.
Fell free to vote for this bug (feature request.)
Thanks

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Honnen  
View profile  
 More options Nov 29 2005, 11:09 am
Newsgroups: netscape.public.mozilla.xml, netscape.public.mozilla.dom
From: Martin Honnen <mahotr...@yahoo.de>
Date: Tue, 29 Nov 2005 17:09:50 +0100
Local: Tues, Nov 29 2005 11:09 am
Subject: Re: XML Declaration

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/CreateXMLDec...>
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/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Honnen  
View profile  
 More options Nov 29 2005, 11:56 am
Newsgroups: netscape.public.mozilla.xml, netscape.public.mozilla.dom
From: Martin Honnen <mahotr...@yahoo.de>
Date: Tue, 29 Nov 2005 17:56:46 +0100
Local: Tues, Nov 29 2005 11:56 am
Subject: Re: XML Declaration

Martin Honnen wrote:
> I have made a test case here:
> <http://home.arcor.de/martin.honnen/mozillaBugs/domLevel2/CreateXMLDec...>

> 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.

Further test case here:
<http://home.arcor.de/martin.honnen/mozillaBugs/domLevel2/CreateXMLDec...>
which creates two processing instructions looking like XML declarations
so that the serialized markup is not well-formed then.

Neither Mozilla (tested now with Mozilla/5.0 (Windows; U; Windows NT
5.1; en-US; rv:1.9a1) Gecko/20051129 Firefox/1.6a1) nor other browsers
give any errors when creating the DOM. Also no error when serializing.

--

        Martin Honnen
        http://JavaScript.FAQTs.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bruno vernay  
View profile  
 More options Nov 29 2005, 12:33 pm
Newsgroups: netscape.public.mozilla.xml, netscape.public.mozilla.dom
From: "bruno vernay" <brunover...@gmail.com>
Date: 29 Nov 2005 09:33:26 -0800
Local: Tues, Nov 29 2005 12:33 pm
Subject: Re: XML Declaration
In fact it is a chance that Firefox doesn't throw an exception when
creating a "wrong" Processing Instruction. Because it allow us to
overcome the real problem which is Serializing doesn't write an XML
Declaration.
I hesitate to name it an enhancement, but I saw other features (XML
Load & save for example) marked as bug, so I marked it as bug too, but
it can be seen as a feature request.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jonas Sicking  
View profile  
 More options Nov 29 2005, 2:41 pm
Newsgroups: netscape.public.mozilla.xml, netscape.public.mozilla.dom
From: Jonas Sicking <jonas.rem...@me.sicking.cc>
Date: Tue, 29 Nov 2005 11:41:35 -0800
Local: Tues, Nov 29 2005 2:41 pm
Subject: Re: XML Declaration

>>> 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?

IMHO the bug is in that we allow such a PI to be created.

> 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 believe the intention of the DOM WG was to disallow illegal PI-names,
both in DOM L2 and DOM L3. Even though I agree they are very unclear on
that.

/ Sicking


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Heikki Toivonen  
View profile  
 More options Nov 30 2005, 1:55 am
Newsgroups: netscape.public.mozilla.xml, netscape.public.mozilla.dom
From: Heikki Toivonen <hj...@comcast.net>
Date: Tue, 29 Nov 2005 22:55:26 -0800
Local: Wed, Nov 30 2005 1:55 am
Subject: Re: XML Declaration

Martin Honnen wrote:
> Neither Mozilla (tested now with Mozilla/5.0 (Windows; U; Windows NT
> 5.1; en-US; rv:1.9a1) Gecko/20051129 Firefox/1.6a1) nor other browsers
> give any errors when creating the DOM. Also no error when serializing.

Given that there is no other way to create the processing instruction
(right?), I would hate to "fix" this by making it impossible to create
the processing instruction.

Anybody know what you are supposed to do in DOM to create a processing
instruction? What will DOM 4 say?

--
  Heikki Toivonen


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
bruno vernay  
View profile  
 More options Nov 30 2005, 5:27 am
Newsgroups: netscape.public.mozilla.xml, netscape.public.mozilla.dom
From: "bruno vernay" <brunover...@gmail.com>
Date: 30 Nov 2005 02:27:34 -0800
Local: Wed, Nov 30 2005 5:27 am
Subject: Re: XML Declaration
Do you mean XML Declaration ?? It is in DOM 3 (I think)

Looks like it should be possible to set xmlVersion :
http://www.w3.org/TR/DOM-Level-3-Core/core.html#Document3-version

It is said that the serializer can write (or not write the XML
Declaration) :
http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#parameter-xml-decl...

Anyway I would like some Javascript methods like
http://www.cafeconleche.org/books/xmljava/chapters/ch13s03.html


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Honnen  
View profile  
 More options Nov 30 2005, 9:13 am
Newsgroups: netscape.public.mozilla.xml, netscape.public.mozilla.dom
From: Martin Honnen <mahotr...@yahoo.de>
Date: Wed, 30 Nov 2005 15:13:42 +0100
Local: Wed, Nov 30 2005 9:13 am
Subject: Re: XML Declaration

Heikki Toivonen wrote:
> Given that there is no other way to create the processing instruction
> (right?), I would hate to "fix" this by making it impossible to create
> the processing instruction.

That sounds like some misunderstanding. In terms of the XML
specification and it terms of the W3C DOM the XML declaration is not a
processing instruction even if the markup delimiters are the same.
If you load XML from source and the W3C DOM is built then the XML
declaration does not show up in the DOM as a child node at all,
certainly not as a processing instruction node.
In DOM Level 3 core some info from the XML declaration should be exposed
as properties of the document object, namely
   xmlVersion
     <http://www.w3.org/TR/DOM-Level-3-Core/core.html#Document3-version>
   xmlEncoding
     <http://www.w3.org/TR/DOM-Level-3-Core/core.html#Document3-encoding>
   xmlStandalone
   <http://www.w3.org/TR/DOM-Level-3-Core/core.html#Document3-standalone>

The current problem in this thread is originally that XMLSerializer and
its serialization methods do not seem to create an XML declaration when
serializing a DOM document and that a "hack to fix that" by creating and
inserting a processing instruction node in the DOM looking like an XML
declaration when being serialized is possible.
But Jonas thinks that hack should not work and be fixed.
If Bruno is right that
   serializer.serializeToStream(doc, foStream, "ISO-8859-1")
does not create an XML declaration then I think the method should be
fixed first to ensure an XML declaration properly declares the encoding
the serialized markup has.

> Anybody know what you are supposed to do in DOM to create a processing
> instruction?

Of course you can create a processing instruction with the method
createProcessingInstruction.
The question however is how you can make sure serialization of a DOM
tree has an XML declaration without needing the above "hack" of putting
in a processing instruction in the DOM looking like the XML declaration
when being serialized.
DOM Level 3 Load and Save for LSSerializer allows to set a property
named xml-declaration to have one.
Only Opera (8.xy release versions and the version 9 preview) implement
DOM Level 3 Load and Save but setting that property does not work so far
<http://home.arcor.de/martin.honnen/operaBugs/op9/DOMLevel3/LSSerializ...>

--

        Martin Honnen
        http://JavaScript.FAQTs.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Heikki Toivonen  
View profile  
 More options Dec 16 2005, 8:48 pm
Newsgroups: netscape.public.mozilla.xml, netscape.public.mozilla.dom
From: Heikki Toivonen <hj...@comcast.net>
Date: Fri, 16 Dec 2005 17:48:27 -0800
Local: Fri, Dec 16 2005 8:48 pm
Subject: Re: XML Declaration

Martin Honnen wrote:
> Heikki Toivonen wrote:

>> Given that there is no other way to create the processing instruction
>> (right?), I would hate to "fix" this by making it impossible to create
>> the processing instruction.

> That sounds like some misunderstanding. In terms of the XML

Argh, I mixed processing instruction and XML declaration. I meant to
talk about XML declaration. As far as I was aware it was not possible to
create XML declarations with DOM except by processing instruction
misuse. But I don't know DOM 3, and based on the links you provided it
does seem like DOM 3 will provide at least some help here. Sorry for the
confusion.

--
  Heikki Toivonen


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »