XML Validation

  107290
September 23, 2019 07:37 gertp93@gmail.com (Gert)
Hi Internals,

I've been working with XML and validation recently, and the Dom
classes do basically everything that is needed. The only thing is that
to get the errors of the schema validation we call the
`validateSchema` on the DomDocument, and then use the
`libxml_get_errors` function to actually get the errors.

I'd like to propose either adding a flag to the `validateSchema` to
make it throw an error detailing the actual XML errors, or adding a
new function that validates and throws with all errors.

I'd like to do the same with `schemaValidateSource` as well.

Do you think this is something that should be added to PHP itself, or
is it something that should be solved by third party packages?
  107291
September 23, 2019 07:44 kontakt@beberlei.de (Benjamin Eberlei)
Hi Gert,

On Mon, Sep 23, 2019 at 9:38 AM Gert <gertp93@gmail.com> wrote:

> Hi Internals, > > I've been working with XML and validation recently, and the Dom > classes do basically everything that is needed. The only thing is that > to get the errors of the schema validation we call the > `validateSchema` on the DomDocument, and then use the > `libxml_get_errors` function to actually get the errors. > > I'd like to propose either adding a flag to the `validateSchema` to > make it throw an error detailing the actual XML errors, or adding a > new function that validates and throws with all errors. > > I'd like to do the same with `schemaValidateSource` as well. > > Do you think this is something that should be added to PHP itself, or > is it something that should be solved by third party packages? >
this is something that should be added to PHP's dom classes, but the C development always takes longer than a userland library. If you please add a ticket on https://bugs.php.net, for this I will consider it for ext/dom, as I think it would be very useful for PHP 8 to go away from the warnings and libxml error handling approach to something better as you suggest.
> > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >
  107292
September 23, 2019 07:46 gertp93@gmail.com (Gert)
Is this something that would need an RFC?

I'd be willing to take a shot at it myself, but my C experience is
rather limited, so i'm not sure if i could cook up an implementation.


On Mon, 23 Sep 2019 at 09:44, Benjamin Eberlei <kontakt@beberlei.de> wrote:
> > Hi Gert, > > On Mon, Sep 23, 2019 at 9:38 AM Gert <gertp93@gmail.com> wrote: >> >> Hi Internals, >> >> I've been working with XML and validation recently, and the Dom >> classes do basically everything that is needed. The only thing is that >> to get the errors of the schema validation we call the >> `validateSchema` on the DomDocument, and then use the >> `libxml_get_errors` function to actually get the errors. >> >> I'd like to propose either adding a flag to the `validateSchema` to >> make it throw an error detailing the actual XML errors, or adding a >> new function that validates and throws with all errors. >> >> I'd like to do the same with `schemaValidateSource` as well. >> >> Do you think this is something that should be added to PHP itself, or >> is it something that should be solved by third party packages? > > > this is something that should be added to PHP's dom classes, but the C development always takes longer than a userland library. > > If you please add a ticket on https://bugs.php.net, for this I will consider it for ext/dom, as I think it would be very useful for PHP 8 to go away from the warnings and libxml error handling approach to something better as you suggest. >> >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >>
  107293
September 23, 2019 08:41 kontakt@beberlei.de (Benjamin Eberlei)
On Mon, Sep 23, 2019 at 9:47 AM Gert <gertp93@gmail.com> wrote:

> Is this something that would need an RFC? >
I would think this is possible without the RFC. It is similar to https://wiki.php.net/rfc/json_throw_on_error which everyone +1ed You could write out fully the new suggested method signatures, what exception they would throw and how the errors would look like into the bug ticket.
> > I'd be willing to take a shot at it myself, but my C experience is > rather limited, so i'm not sure if i could cook up an implementation. > > > On Mon, 23 Sep 2019 at 09:44, Benjamin Eberlei <kontakt@beberlei.de> > wrote: > > > > Hi Gert, > > > > On Mon, Sep 23, 2019 at 9:38 AM Gert <gertp93@gmail.com> wrote: > >> > >> Hi Internals, > >> > >> I've been working with XML and validation recently, and the Dom > >> classes do basically everything that is needed. The only thing is that > >> to get the errors of the schema validation we call the > >> `validateSchema` on the DomDocument, and then use the > >> `libxml_get_errors` function to actually get the errors. > >> > >> I'd like to propose either adding a flag to the `validateSchema` to > >> make it throw an error detailing the actual XML errors, or adding a > >> new function that validates and throws with all errors. > >> > >> I'd like to do the same with `schemaValidateSource` as well. > >> > >> Do you think this is something that should be added to PHP itself, or > >> is it something that should be solved by third party packages? > > > > > > this is something that should be added to PHP's dom classes, but the C > development always takes longer than a userland library. > > > > If you please add a ticket on https://bugs.php.net, for this I will > consider it for ext/dom, as I think it would be very useful for PHP 8 to go > away from the warnings and libxml error handling approach to something > better as you suggest. > >> > >> > >> -- > >> PHP Internals - PHP Runtime Development Mailing List > >> To unsubscribe, visit: http://www.php.net/unsub.php > >> >