Re: annoying DOM limitation
| From: | Rob Richards | Date: | Fri, 13 May 2005 21:18:38 +0000 |
| Subject: | Re: annoying DOM limitation | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-16242@lists.php.net to get a copy of this message | ||
I had just posted a comment on your blog about this.
$root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xsd','http://www.w3.org/2001/XMLSchema');
should do exactly what you want.
Rob
George Schlossnagle wrote:
While hacking on a PHPDoc -> WSDL generator, I ran into an annoying limitation in the dom extension: you can't add a namespace to a dom document unless you have an element in that namespace. Why might you want to do this? Well, a common thing is to have your xml-schema types to be specified as attribute values, i.e. <element name="foo" type="xsd:string"/> for this to work I need xsd to be an alias for http://www.w3.org/2001/ XMLSchema. To work around this, I added a DomElement::addNS($uri, $alias) method to Dom. Adding the namespace 'manually' as an attribute on an element does not work. I know this isn't part of the Dom spec, but it's incredibly useful. Does anyone (Rob, Chegru) mind me adding it to HEAD?