On Sun, 7 Dec 2025 at 04:38, Marcos Magueta <maguetamarcos@gmail.com> wrote:
>
> Hello!
>
> I am likely one of the few people still using XML, but I noticed XSD schema validation is still a TODO on postgresql,
whichI have some personal use cases for.
>
> In this patch I attempt to implement XMLVALIDATE with the already in use libxml following a version I got my hands on
ofthe SQL/XML standard of 2016.
>
> In short, I had to add the ACCORDING word to comply with it and completely ignored the version that was already in
thesrc that fetches arbitrary schemas (it refers to validations of dtds, which is another more troublesome TODO).
>
> I had problems running the regression tests on my machine, so I could only test the feature by spawning a modified
instanceof postgresql and issuing queries through psql, therefore I am marking it as WIP. If anyone can assert the
testspass, I would be glad.
>
> Also, this is my first patch, so I might have not followed standard practices as best as I could, so please pay
particularattention to that on review.
>
> Cheers,
> Marcos Magueta.
HI!
1)
> + // Default case since nothing got returned
> + // out of the normal path for validation calls to libxml
PostgreSQL uses /**/ comments style.
2)
XML regression test suite fails, see attached. By the way, what are
your issues with running `make check` ?
3)
By the way, in [0] we have this
`
The function in PostgreSQL produces an “unimplemented” error, because
PostgreSQL does not have any implementation of the mechanism assumed
in the standard for registering schemas in advance, which is necessary
to address the security implications of a function that could refer to
schemas from arbitrary locations.
`
How does your patch resolve this? I did not find any change in this area
4)
Also I want to mention that without a doc, the patch is not in a
commitable shape.
5) I am a bit surprised by this grammar rule:
> XMLVALIDATE '(' document_or_content a_expr ACCORDING TO XMLSCHEMA a_expr ')'
this allow a wide class of expressions accepted by parser, like
`SELECT xmlvalidate(DOCUMENT (select oid from pg_class) ACCORDING TO
XMLSCHEMA (select 32)) AS is_valid FROM xml_validation_test;`
Is this expected? a_expr is way more than string constants and column
references.. If yes, the regression test that you added, does not
test this..
p.s. I failed to find in google SQL/XML standard of 2016. So, I cannot
double-check if this feature is compliant with it...
[0] https://wiki.postgresql.org/wiki/PostgreSQL_vs_SQL/XML_Standards
--
Best regards,
Kirill Reshke