Using Dom Objects in PHP, the default namespace is redeclared in some nodes.
- by TomcatExodus
I'm working on a template engine, having migrated from regex driven to DOM driven. It appears though, that whenever I create a DomDocumentFragment to encapsulate some portion of a document temporarily, the namespace attribute is added to each node in the fragment. Since my default namespace for a given document will 99% of the time be XHTML, it's adding the XHTML namespace declaration.
Being the default namespace, this seems fruitless, and ultimately nodes in any other namespace will be stripped out at render time anyways.
Aside from iteratively removing namespace attributes, is there some way I can prevent this from occurring to begin with? Its quite problematic, as this will likely increase render time filesize considerably, as large portions of a given document may be stored in a fragment.
I've tried $doc->normalizeDocument(), but as I assumed, it did nothing.