Reader::parse() and Service::parse() return different values
Using sabre with XSD validation I'm getting unexpected result when using the XSD snippet from documentation.
There's actually 2 problems with suggested solution:
$service = new Sabre\Xml\Service(); $reader = $service->getReader(); $validXml = $reader->setSchema('myschema.xsd') if ($validXml) { $reader->xml($xml); print_r($reader->parse()); }
will not work as the Schema needs to be set after xml() method call.
Additionally the parse() method is returning root element array with name, value, and attributes keys.
Looking at code this happens because Service::parse() is returning $result['value'] while Reader::parse() is returning $result.
Can you please either correct the code, to always have same result, or at least update the documentation to make it clear what to expect?
where did you found this code?
@staabm Which code exactly? Suggested solution is on https://sabre.io/xml/reading at the end of that page. Reader::parse(): https://github.com/sabre-io/xml/blob/03a31cad79abbcef81e7aff28e56a9d257a0dae2/lib/Reader.php#L56 Service::parse(): https://github.com/sabre-io/xml/blob/03a31cad79abbcef81e7aff28e56a9d257a0dae2/lib/Service.php#L112
are you willing to provide a fix in https://github.com/sabre-io/sabre.io/blob/master/source/xml/reading.md ?
The reader and service having slightly different signatures is definitely a bit strange in hindsight, but definitely by design. I expect most people to use the service, and the service is meant to be most user-friendly frontend for all of this.