Page 1 of 1

Using Schema+Schematron on XML files with XMLNS error

Posted: Tue Aug 29, 2023 4:31 pm
by aujunior
I'm having issues using schema validation along with Schematron validation when the XML file contains a XMLNS tag.

We are developing a framework to work with ATA2300, and in this specification, the namespace xmlns="http://www.ataebiz.org/XMLSchema" is used. A catalog file was created to apply the schema to the XML files. A Schematron was also created to validate some rules apart from the schema. However, when we have the XMLNS tag, Oxygen doesn't take the Schematron into account. When I remove the XMLNS tag, the Schematron works, but the schema stops working.

Am I doing something wrong, or is it really a tool issue?

Validation scenario:
image.png
Catalog:
image.png
Simple Schematron:
image.png
File with XMLNS working with Schema, but not with schematron:
image.png
File without XMLNS working with Schematron, but not with schema:
image.png

We are having the same problem when using xsi:noNamespaceSchemaLocation instead of xsi:schemaLocation

Re: Using Schema+Schematron on XML files with XMLNS error

Posted: Tue Aug 29, 2023 5:48 pm
by aujunior
I found the solution.

The following declaration is missing in schematron:
<sch:ns uri="http://www.ataebiz.org/XMLSchema" prefix="ata"/>

Now it working fine.


I'm sorry.

Re: Using Schema+Schematron on XML files with XMLNS error

Posted: Wed Aug 30, 2023 7:53 am
by Radu
Hi,
Right, once your XML is in a certain namespace, the XPath expressions in the Schematron need to match elements in that namespace.
So either write flexible matches like *:para or match directly elements in the namespace by using ata:para and mapping the "ata" prefix to the namespace.
Regards,
Radu