# [PATCH] ext. dom php_dom.c

- Thread: https://externals.io/message/3361
- Original archive: https://news-web.php.net/php.internals/3361
- Started by John Huntjens on 2003-07-11T11:20:14+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #3361 — John Huntjens — 2003-07-11T11:20:14+00:00

URL: https://externals.io/message/3361#3361

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);

---

## #3362 — Rob Richards — 2003-07-11T11:52:03+00:00

URL: https://externals.io/message/3361#3362 · In reply to: #3361

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

---

## #3363 — John Huntjens — 2003-07-11T12:03:49+00:00

URL: https://externals.io/message/3361#3363 · In reply to: #3362

<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

---

## #3365 — John Huntjens — 2003-07-11T12:26:49+00:00

URL: https://externals.io/message/3361#3365 · In reply to: #3364

> > […]
>
> 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

---

## #3364 — Rob Richards — 2003-07-11T12:28:54+00:00

URL: https://externals.io/message/3361#3364 · In reply to: #3361

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
