[PATCH] ext. dom php_dom.c

php.internals

John Huntjens

23 years ago
Hello list, Version 5.0.0b1 Extension dom File: php_dom.c Test script: $dom = new domDocument(); $dom->load('test.xml'); print $dom->savexml(); test.xml: <?xml version="1.0"?> <!DOCTYPE app [ <!ENTITY sysmenu SYSTEM "test2.xml"> ]> <app>&sysmenu;</app> test2.xml: <?xml version="1.0"?> <menu>test</menu> When running the test script, in the entitys get not expanded. But the standard http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-D OMConfiguration says about this: "entities" true [required] Keep EntityReference and Entity nodes in the document. Issue normalizationFeature-9: How does that interact with expand-entity-references? ALH suggests consolidating the two to a single feature called "entity-references" that is used both for load and save. Resolution: Consolidate both features into a single feature called 'entities'. (Telcon 27 Jan 2002). false [required] (default) Remove all EntityReference and Entity nodes from the document, putting the entity expansions directly in their place. Text nodes are into "normal" form. Only EntityReference nodes to non-defined entities are kept in the document. Proposal: change line 542 of php_dom.c from: xmlInitParser(); into: xmlInitParser(); /* http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-D OMConfiguration section entitys: "entities" false [required] (default) Remove all EntityReference and Entity nodes from the document, putting the entity expansions directly in their place. Text nodes are into "normal" form. Only EntityReference nodes to non-defined entities are kept in the document. */ xmlSubstituteEntitiesDefault(1);

Rob Richards

23 years ago
From: John Huntjens
> When running the test script, in the entitys get not expanded. > But the standard >
http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-D
> OMConfiguration > says about this:
DOMConfiguration has not been implemented at the moment as it is level 3 spec, so opted to just extend the specs, at least for now, as it is much more usable for the user. Concentration has been to at least get things up to level 2 working while some level 3 functionality has been added. Grab the latest code from cvs (added yesterday). New properties were added to the domDocument. (They are all booleans). validateOnParse - default FALSE (will load and validate against DTD) resolveExternals - default FALSE (will load the DTD without performaing validation) preserveWhiteSpace - default TRUE substituteEntities - default FALSE Your code would look like the following: $dom = new domDocument(); $dom->resolveExternals = TRUE; $dom->substituteEntities = TRUE; $dom->load('test.xml'); print $dom->savexml(); Note: these properties have not yet been worked into the save methods yet, only the load methods. Also, use of libxml globals i.e. xmlSubstituteEntitiesDefault(1); - very bad thing especially with multiple extensions using libxml. Rob

John Huntjens

23 years ago
<snip>
> Grab the latest code from cvs (added yesterday). New properties were added > to the domDocument. (They are all booleans). > > validateOnParse - default FALSE (will load and validate against DTD) > resolveExternals - default FALSE (will load the DTD without performaing > validation) > preserveWhiteSpace - default TRUE > substituteEntities - default FALSE > > Your code would look like the following: > > $dom = new domDocument(); > $dom->resolveExternals = TRUE; > $dom->substituteEntities = TRUE; > $dom->load('test.xml'); > print $dom->savexml(); > > Note: these properties have not yet been worked into the save methods yet, > only the load methods. > > Also, use of libxml globals i.e. xmlSubstituteEntitiesDefault(1); - very
bad
> thing especially with multiple extensions using libxml.
Thanks Rob, I got the latest snap from http://snaps.php.net/ , version php5-200307111130.tar.tar, but that one wil not compile document.c /sys/tmp/php5-200307111130/ext/dom/document.c: In function `php_dom_ctx_error': /sys/tmp/php5-200307111130/ext/dom/document.c:120: parse error before `parser' /sys/tmp/php5-200307111130/ext/dom/document.c:122: `parser' undeclared (first use in this function) /sys/tmp/php5-200307111130/ext/dom/document.c:122: (Each undeclared identifier is reported only once /sys/tmp/php5-200307111130/ext/dom/document.c:122: for each function it appears in.) make: *** [ext/dom/document.lo] Error 1 Do I have the wrong snap? John

Rob Richards

23 years ago
John Huntjens wrote in message
> /sys/tmp/php5-200307111130/ext/dom/document.c: In function > `php_dom_ctx_error': > /sys/tmp/php5-200307111130/ext/dom/document.c:120: parse error before > `parser' > /sys/tmp/php5-200307111130/ext/dom/document.c:122: `parser' undeclared > (first use in this function) > /sys/tmp/php5-200307111130/ext/dom/document.c:122: (Each undeclared > identifier is reported only once > /sys/tmp/php5-200307111130/ext/dom/document.c:122: for each function it > appears in.) > make: *** [ext/dom/document.lo] Error 1
The snap is correct. What are you using for configure and what version of libxml are you using? Rob

John Huntjens

23 years ago
> > /sys/tmp/php5-200307111130/ext/dom/document.c: In function > > `php_dom_ctx_error': > > /sys/tmp/php5-200307111130/ext/dom/document.c:120: parse error before > > `parser' > > /sys/tmp/php5-200307111130/ext/dom/document.c:122: `parser' undeclared > > (first use in this function) > > /sys/tmp/php5-200307111130/ext/dom/document.c:122: (Each undeclared > > identifier is reported only once > > /sys/tmp/php5-200307111130/ext/dom/document.c:122: for each function it > > appears in.) > > make: *** [ext/dom/document.lo] Error 1 > > The snap is correct. What are you using for configure and what version of > libxml are you using? > > Rob
configure \ --enable-track-vars --with-apxs \ --with-config-file-path=/etc \ --without-mysql \ --without-pear \ --with-interbase \ --with-simplexml \ --with-xsl \ --with-ftp \ --with-gd \ --with-imap \ --with-imap-ssl \ --with-dbase \ --with-zlib libxml2: 2.5.7 lixxslt: 1.0.31 John