Re: Making SimpleXML more useful
| From: | Tom Samplonius | Date: | Fri, 29 Apr 2011 23:57:01 +0000 |
| Subject: | Re: Making SimpleXML more useful | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-52090@lists.php.net to get a copy of this message | ||
> > $sxe->addChild('child', 123); # Adds element with namespace
> > inherited from the parent
> > $sxe->addChild('child', 123, 'urn:somenamespace'); # Adds child
> > with specified namespace
> > $sxe->addChild('child', 123, -1); # Adds child with no namespace
> > qualification
>
> Again, there is no problem here as <child xmlns="">123</child> is
> unqualified
Specifying the "xmlns" pseudo-attribute *is* namespace qualification. Qualification is
the act of specifying a namespace. And there is a difference between no namespace
(xmlns="") and the default namespace. The XML document:
<parent xmlns="urn:something">
<child xmlns="">123</child>
</parent>
and:
<parent xmlns="urn:something">
<child>123</child>
</parent>
are different documents. In the first case, the <child> element is not in any namespace, and
in the later, the <child> element is in the default namespace. Ben Schmidt mentioned this in
an earlier response.
XMLSchema's can further specify the structure of XML documents beyond what is in the
XMLNamespace spec, including requiring that elements be unqualified and specifying a target
namespace for the unqualified elements. An XML document structure defined by an XMLSchema really
only has one correct form.
Tom