Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:7054 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 1856 invoked by uid 1010); 13 Jan 2004 16:41:14 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 1822 invoked from network); 13 Jan 2004 16:41:13 -0000 Received: from unknown (HELO miranda.org) (209.58.150.153) by pb1.pair.com with SMTP; 13 Jan 2004 16:41:13 -0000 Received: (qmail 19881 invoked by uid 546); 13 Jan 2004 16:41:13 -0000 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 13 Jan 2004 16:41:13 -0000 Date: Tue, 13 Jan 2004 11:41:13 -0500 (EST) X-X-Sender: adam@miranda.org To: Christian Schneider cc: Rob Richards , internals@lists.php.net In-Reply-To: <40041D4B.9060900@cschneid.com> Message-ID: References: <00fe01c3d9d1$6e8618a0$f7dea8c0@cyberware.local> <4003FEFA.2090700@cschneid.com> <40041D4B.9060900@cschneid.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [PHP-DEV] SimpleXML: Moving Forward From: adam@trachtenberg.com (Adam Maccabee Trachtenberg) On Tue, 13 Jan 2004, Christian Schneider wrote: > Adam Trachtenberg wrote: > > However, I don't really see any way around this otherwise. Either it's > > general or not. It can't be both. (Unless there's some magical type > > that's both an array and a scalar.) I'm willing to put up with this > > Elements are already a magical type which is an object and an array. > Making foreach work on a both the scalar and array incantation of child > elements seems very useful to me. And usefulness seems to be the goal of > SimpleXML as far as I understand. If that can be done, then I am all for it. Maybe we can somehow make an individual item Iterable. > > maxOccurs attributes in the schema for an element. If maxOccurs > 1, > > then the elements would be placed in an array even if there was only one > > element in that particular instance. > > I don't like the idea: Different behaviour with or without schema. I > write code without schema first. If I decide to add a schema later code > has to be rewritten. Not good. Don't do that. Use the schema. :) > > AFAIK, it's actually also impossible to find out the name of the > > document element using SimpleXML, even using XPath. > > Yup, right now the only way is probably to wrap it in a dummy tag before > giving it to SimpleXML. Sounds like a good idea anyway to me, if I have > a domain specific document with varying content I'd probably do > ... anyway. Unless, of course, you're not in control over those documents. > >> I would actually expect abcd but only once: > >> Node Value: abcd > >> > >> Concatenating all text parts _and_ returning them once for each part > >> definitely seems wrong. > > > > Aren't those two lines contradictory? :) > > Why? Right now it returns abcd twice which is definitely wrong. > Returning ab and cd or (preferably IMHO) abcd once seems right. Sorry. I misread. I thought you wrote "returning them once definitely seems wrong." I agree that we should return "abcd" in this case. -adam -- adam@trachtenberg.com author of o'reilly's php cookbook avoid the holiday rush, buy your copy today!