I am working on a template engine by moving from a regular expression controlled by the DOM. However, it seems that whenever I create DomDocumentFragmentto encapsulate some part of the document temporarily, a namespace attribute is added to each node in the fragment. Since my default namespace for this document will be XHTML 99% of the time, it adds an XHTML namespace declaration.
Being the default namespace, this seems barren, and eventually nodes in any other namespace will be deleted during rendering.
Besides iteratively deleting namespace attributes, is there any way I can prevent this from happening? This is quite problematic, as it is likely to significantly increase the size of the time file, since large fragments of this document can be saved in a fragment.
I tried $doc->normalizeDocument(), but, as I expected, did nothing.
source
share