Wednesday, 25 February 2015

How to incorporate external entity sets into a php-generated XML document?



I've spent the last couple of hours trying to figure this out...searching google and stack overflow also did not help me unfortunately.


My problem is the following: I can't figure out how to change the doctype in my php generated XML file to incorporate an external entity set (in my case MathML entities).


According to w3, incorporating the MathML XML set works by declaring the doctype like with the following entity included:



<!ENTITY % htmlmathml-f PUBLIC
"-//W3C//ENTITIES HTML MathML Set//EN//XML"
"http://ift.tt/1DTXGQQ"
>


However, I just can't wrap my head around on how to do this when generating the XML file with PHP using DOMDocument?


When looking into the PHP manual of the DOMDocument class, I can see that it has a property resolveExternals which has the following description:



Set it to TRUE to load external entities from a doctype declaration. This is useful for including character entities in your XML document.



And when looking into the DOMDocumentType class, I found out that it has a read-only property entities described as follows:



A DOMNamedNodeMap containing the general entities, both external and internal, declared in the DTD.



This made me conclude that it has to be possible to change the doctype to include external entities using some method.


But I just can't figure out how to do it. I know it most probably is some method of the DOMDocumentType class, but I just can't figure out which one and how to use it.


To sum-up, my question is: How can I change the doctype declaration of my php generated DOMDocument XML file to incorporate the external MathML entity set from w3?


No comments:

Post a Comment