Re: [PHP-XML-DEV] Lack of configuration support in SAX interface
[email protected] (Rob Richards) Thu, 08 Sep 2005 21:11:59 -0400
| Newsgroups | php.xml.dev |
|---|---|
| Message-ID | <[email protected]> |
Jirka Kosek wrote: > is there a way how to configure SAX parser (xml_parser_create) > similarly as DOM or SimpleXML? I mean specifying constants like > LIBXML_NOENT, LIBXML_DTDLOAD, LIBXML_DTDATTR etc. to control parser > behaviour. > > It seems that default behaviour of SAX parser is quite non-conforming > to XML spec, it even doesn't expand references to internal entities. Based on the extensions mentioned I assume this is under PHP 5.x and libxml is being used for the xml extension. It was designed for compatibility with the one under PHP 4 that used expat so behavior in 5 was based on behavior from 4. For example, expanding entity refs requires that no default handler is defined. In the event its an internal pre-defined entity, they only are not expanded when no character data handler is present. So to answer your initial question, no, there is not a way to currently do this while also keeping compatibility between libxml2 and expat. For this type of control you might want to look at xmlreader (though uses its own constants to control behavior and is not event based). Rob