Subj : Re: XML declaration broken going from Mozilla 1.8a6 to 1.8b
To : netscape.public.mozilla.jseng
From : Martin Honnen
Date : Sat Mar 12 2005 01:26 pm
ant wrote:
> I've some E4X scripts that stopped working after moving up to Mozilla
> 1.8b beta because creating XML objects from strings starting with an
> XML declaration no longer works:
>
> A simple page demonstrating the problem:
>
>
>
>
>
>
>
>
>
> This works fine in Mozilla 1.8a6 but in 1.8b it fails with:
>
> Error: xml is a reserved identifier
> Source File: Line: 1, Column: 17
> Source Code: encoding='LATIN-1'?>petra
>
> Is this a bug or something I'm doing wrong?
This is somehow a regression of the fix for bug
The problem is that something looking like this
is the XML declaration if it sits at the beginning of the whole XML
document but is a processing instruction with the disallowed target name
'xml' if it occurs elsewhere.
Now
new XML(value)
according to the E4X specification "13.4.2 The XML Constructor" does the
following
Let x = ToXML(value)
and ToXML(value) according to the E4X specification "10.3.1 ToXML
Applied to the String Type" takes the string and wraps it into
value
to then parse it.
So your example markup
new XML("petra");
is parsed as
petra
and thus the is causing an error.
Rhino with E4X however doesn't throw that error while on the other hand
being able to give an error when the string passed to the XML
constructor function contains later in the markup.
This looks for me a bit like a design flaw in E4X, it is probably
desirable that you can take the whole XML markup from an XML document
(including the XML declaration) and pass it to new XML() but of course
any implementation following the E4X specification literally wraps the
argument to new XML() into
meaning that any XML declaration in the original markup is then
technically an error during parsing.
Maybe Brendan and/or Igor know better whether new XML() in E4X should be
able to consume the complete XML markup from a document including the
XML declaration.
--
Martin Honnen
http://JavaScript.FAQTs.com/
.