Re: [PEPr] Comment on Semantic Web::XML_GRDDL

From: Date: Mon, 03 Mar 2008 15:22:42 +0000
Subject: Re: [PEPr] Comment on Semantic Web::XML_GRDDL
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-49241@lists.php.net to get a copy of this message
On Sun, Mar 2, 2008 at 1:06 PM, till <klimpong@gmail.com> wrote: > > >> 2) I have a pre-rendered out RDF/XML document to compare my > generated > > > > >> (...) > > > > >> - there's no PHPUnit::assertEqual($xml, $other_xml); which handles > all > > > > >> of the ins and outs that a string comparison won't cut it for. > > > > > > > > > Can you explain this? Are you talking about the difference in > linebreaks > > and possible whitespace? Or what exactly keeps you from a simple string > > comparison? > > Well, it's not just whitespace, line endings and other minor snafu. > > Hmm, I gotcha. Maybe similar_text() or levenshtein() help? Not sure if > this is appropriate though. From your examples similar_text() reports that > the XML "A" and "B" are ~70% identical which doesn't really say > "PASS", but > is also not really "FAIL". ;-) > > You could also count tags and assign checksums to see if they add up - > then again that could still be a complete fail if the XML data is not in > order/invalid. But I guess if the XML is valid (I am thinking basic valid > format AND dtd) you could go the checksum-route. > > Maybe you need to transform (= clean) the XML data before you compare it? > Stylesheets, or something? I am totally clueless how though.:-) > > Cheers, > Till > Actually, this all sounds to me like you're trying to determine the equivalency of the two XML objects, rather than truly being concerned that the "strings" match. Would it be feasible to load the two original XML strings into a DOM object, and use a DOM method that dumps a "normalized" string of its structure, or finally a var_dump() of the DOM object itself? Presumably, the DOM object as a core PHP class is one that is "trustworthy" enough to use in your testing scenario. I'm speaking from a theoretical point of view, given I haven't used any of PHP5's XML stuff... /me lives in php4 land... hence I'm really asking if my thinking sounds valid... -- CRB

« previous php.pear.dev (#49241) next »