Re: dom creation
[email protected] (Christian Stocker)
| Newsgroups | php.xml.dev |
|---|---|
| Organization | Bitflux GmbH |
| Message-ID | <[email protected]> |
[ replied to php-xml-dev ] On Fri, 2003-04-11 at 14:40, Rob Richards wrote: > Here is a question. > > How should we handle the creation of the DOM? I was asking this myself as well... > > Currently there are xmldoc and xmldocfile. domxml_open_mem() and domxml_open_file() are the current recommended function names in userland. But I'm not very happy with them, either. > Should these be left as is, or > should we start looking at DOMImplementation and possibly DOMBuilder (level > 3) which would create a document, etc... Then going along that route, The problem with DOM level 2 (http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html) is, that there's no definition how to read files/string and serialize them. This is were Level 3 on the other hand has the "Load and Save" Specification (http://www.w3.org/TR/2003/WD-DOM-Level-3-LS-20030226/) for this. Therefore I think, it would be wise to use some of the proposed methods there. But maybe this is could lead to implementation-overkill as well.. loading a file would then be $domdocument = dombuilder:parse_uri($filename); which is ok. But reading from a string seems to be quite complicated: $domdocument = dombuilder:parse($dominputsource); where $dominputsource is another class with characterStreams and alike. I think for parsing xml from strings, we could just do it with $domdocument = dombuilder:parse_string($xmlstring); even if it's not in the domstandard.. the DOMWriter Interface seems to be a little bit complicated as well... But, just saw "Convenience Interfaces" (http://www.w3.org/TR/2003/WD-DOM-Level-3-LS-20030226/) $domdocument = domimplementation:create_document() $domdocument->load($uri); $domdocument->loadXML($string); $serialized = $domdocument->saveXML(); looks exactly like what we need for the time being. Maybe ->saveXMLtoFile as another method. > if > looking at DOMImplementation/DOMBuilder should we start looking at useing > streams? (Which I am not sure where streams are regarding stability at this > point). Streams would be nice, but not of importance for me for the 5.0.0 release. > I am thinking for the immediate, to just implement xmldoc and/or xmldoc file > so that work can get started on the underlying pieces and then trying to > switch over to other methods possibly. But I dont want to start off with > something that is going to kick us in the ass further down the road. I think the "DOM Convenience Methods" are just ok. > When this new extension is completly implemented, BC is definitely going out > the window without a some type of wrapper. I don't have a problem with that ;) On another Area: DOM Standard reports errors with Exceptions. PHP5 does support exceptions, but, IIRC, it is not recommended to throw Exceptions from extensions. Are there any opinions about this? chregu -- christian stocker | bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich phone +41 1 240 56 70 | mobile +41 76 561 88 60 | fax +41 1 240 56 71 http://www.bitflux.ch | [email protected] | gnupg-keyid 0x5CE1DECB