I am parsing some XML with PHP DOMDocument. This is my code:
$doc = new DOMDocument;
$doc->resolveExternals = true;
$doc->substituteEntities = true;
$doc->load('../poems_xml/'.$pid.'.xml');
$xsl = new DOMDocument;
$xsl->load('../xslt/title.xsl');
$proc = new XSLTProcessor;
$proc->importStylesheet($xsl);
$ptitle = $proc->transformToXML($doc);
I have an entity file declared at the beginning of my .xml:
<?xml version="1.0" encoding="utf-8"?>
<?oxygen RNGSchema="../dtd/dps.rng" type="xml"?>
<?xml-stylesheet href="../dtd/dps.css" type="text/css"?>
<!DOCTYPE TEI SYSTEM "../dtd/entities.ent">
[...]
And the entities file looks like this:
[...]
<!ENTITY d1_AytR_002 "<rs key='d1_AytR_002'>d1_AytR_002</rs>">
[...]
In my .xml I use these entities like so:
...&d1_AytR_002;...
Now, it all goes well in terms of parsing the file and transform it via the xslt and css files, except for the entities. They just get ignored. Turning on the php_error_log flag, I get this:
Notice: DOMDocument::load(): Namespace default prefix was not found in Entity, line: 1 in index.php on line 28
(line 28 of index.php
is where the load('../poems_xml/'.$pid.'.xml')
instruction is). Can someone shed some light on what I should check/add regarding my entities?
I'm using PHP 5.6.40.
A workaround (and possible permanent solution) is that of adding the namespace to each of the <!ENTITY>
s, like so:
<!ENTITY d1_AytR_002 "<rs xmlns="http://www.tei-c.org/ns/1.0" key='d1_AytR_002'>d1_AytR_002</rs>">