Re: Problems with XML_Transformer

From: Date: Fri, 07 Mar 2003 11:53:14 +0000
Subject: Re: Problems with XML_Transformer
References: 1 2  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-14134@lists.php.net to get a copy of this message
On Fri, Mar 07, 2003 at 10:03:35AM +0100, Sebastian Bergmann wrote: > Using &amp; instead of & should solve half the problem. > > Does disabling recursion for the transformation in question work for > you? The other half of the problem is that XML_Transformer gets entities in substituted form from expat. Thus, it cannot distinguish an &amp; form an & and a &lt; from an < upon reparsing. The solution is to hack expat, and have expat do two things: - introduce the PHP functions xml_lookup_entity and xml_entity_lookup_table. xml_lookup_entity would take an entity name and return the replacement text for it as a string. xml_entity_lookup_table would return the entire entity lookup table from expat as a PHP hash. - introduce another callback function xml_entity_handler, which is called instead of the internal expat entity replacement, and which does entity lookup itself. Using these functions it would be possible for PHP to parse "invalid" XML where there are "undeclared" entities, which get dynamic programmatic replacements in PHP. For example, one could implement "entity namespaces" or "scopes" as they are called in the Roxen webserver, implementing &sql:<column name>; entities and the like (see http://docs.roxen.com/roxen/3.3/web_developer_manual/entity/index.xml). Using these functions it would also be possible for PHP to provide identity replacements for &amp;, &lt;, &quot; and other entities, enabling proper reparsing. I had started such an expat patch, but have lost the patch due to my carelessness (Thies should have a copy in his mail for review .-). Also the expat incestines are in a state that makes it a very demanding task to look at them for any longer amount of time, thus I haven't finished my patch... Kristian

« previous php.pear.dev (#14134) next »