> It seems like a limitation that toXmlString() can't handle default
> namespaces or implicitly defined namespaces. For instance, when you
> use xml:id, you're using a namespace xml that you don't declare, and
> when you're using the default namespace http://example.com that
> namespace doesn't have a binding. toXmlString() apparently wants
> everything to be explicit, so it makes up bindings for the two
> namespaces — aaa and aab — and uses them to explicitly namespace the
> id attribute as well as the <root> node. I think the output XML string
> is functionally equivalent, but it's clearly not literally equivalent
> :(

What really worries me is that apparently if i use XMLList for parsing 
the doc (i have to, as i need the PI) i can't access the default 
namespace via namespaceDeclarations().

XML.ignoreProcessingInstructions = false;
var a:XMLList = XMLList(
    '<?xml-stylesheet href="my.css" type="text/css"?>' +
    '<root xmlns="http://example.com/"; />');
trace(a.toXMLString());
// <?xml-stylesheet href="my.css" type="text/css"?>
// <aaa:root xmlns:aaa="http://example.com/"/>
trace(XML(a[1]).namespace());
// http://example.com/ (correct)
trace(XML(a[1]).namespaceDeclarations().length);
// 0 (wrong. this should be 1)

If i explicitly give my root element a prefix, like so:

XML.ignoreProcessingInstructions = false;
var a:XMLList = XMLList(
    '<?xml-stylesheet href="my.css" type="text/css"?>' +
    '<xyz:root xmlns:xyz="http://example.com/"; />');

Everything is fine:

trace(a.toXMLString());
// <?xml-stylesheet href="my.css" type="text/css"?>
// <xyz:root xmlns:xyz="http://example.com/"/>
trace(XML(a[1]).namespace());
// http://example.com/ (correct)
trace(XML(a[1]).namespaceDeclarations().length);
// 1 (correct)

As soon as a default namespace declaration is involved, it is ignored by 
namespaceDeclarations(). That's also probably why toXMLString() invents 
a prefix in that case (same for xml:id attributes, because there is no 
declaration for the xml prefix, as it is implicitly defined).

Plus, all of this does not happen when i parse with XML() rather than 
XMLList(). But then i can't access the PI.

Afaik this is a bug.

Cheers,
Claus.

-- 
claus wahlers
côdeazur brasil
http://codeazur.com.br/
http://wahlers.com.br/claus/blog/


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to