Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reader::parse() and Service::parse() return different values #181

Open
kamilszewczyk opened this issue Mar 23, 2020 · 4 comments
Open

Reader::parse() and Service::parse() return different values #181

kamilszewczyk opened this issue Mar 23, 2020 · 4 comments

Comments

@kamilszewczyk
Copy link

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?

@staabm
Copy link
Member

staabm commented Mar 23, 2020

where did you found this code?

@kamilszewczyk
Copy link
Author

@staabm
Which code exactly?
Suggested solution is on https://sabre.io/xml/reading at the end of that page.
Reader::parse():

public function parse(): array

Service::parse():
public function parse($input, string $contextUri = null, string &$rootElementName = null)

@staabm
Copy link
Member

staabm commented Mar 23, 2020

are you willing to provide a fix in https://github.com/sabre-io/sabre.io/blob/master/source/xml/reading.md ?

@evert
Copy link
Member

evert commented Mar 23, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants