Page 1 of 1

Validate part of XML file

Posted: Fri Apr 23, 2021 4:54 pm
by AndreasT
Hello.
This seems to me a noob question, but I cannot find the answer after looking around a bit so sorry if it's obvious.

I have a few XML files that need to be validated and I only have a XSD for the core element of the files. The files also have a header section that wraps the core element.
Is there a way to create a validation scenario that ignores the header and only validates the core element, maybe using XPath?

Re: Validate part of XML file

Posted: Mon Apr 26, 2021 12:31 pm
by tavy
Hello,

No, you cannot use validation scenario to ignore the header element, and associate the XSD schema only with the core element. Probably you can do this from the XSD schema. Maybe you can use a different namespace for the header element, and associate the schema only for that namespace.

Best Regards,
Octavian

Re: Validate part of XML file

Posted: Mon Apr 26, 2021 5:22 pm
by AndreasT
Thank you.
They DO have different namespaces so that led me to another approach that I now remember having used earlier on another project.
I've set up a validation scenario with the XSD for the core of the file and set up a catalog to specify the path to the header file, but Oxygen still fails to validate the header part, it cannot locate the elements.
Do I need to do anything else to load the files linked in the catalog?

Is it possible to see a list of the files that Oxygen has loaded during validation and also if there were any errors during load?

Re: Validate part of XML file

Posted: Tue Apr 27, 2021 3:37 pm
by tavy
Hello,

If you do not have an XSD schema for the header, and you want to validate only the core part, I recommend you to use an NVDL schema.
I think you can create a schema something like this:

Code: Select all

<rules xmlns="http://purl.oclc.org/dsdl/nvdl/ns/structure/1.0">
    <namespace ns="http://testCore">
        <validate schema="coreSchema.xsd"/>
    </namespace>
    <anyNamespace>
        <allow></allow>
    </anyNamespace>
</rules>
This specifies that the elements from the "http://testCore" namespace will be validated with the coreSchema.xsd, and the elements from other namespaces are allowed.
Then you can associate the NVDL schema in the XML document or use a validation scenario.

Best Regards,
Octavian

Re: Validate part of XML file

Posted: Tue Apr 27, 2021 6:51 pm
by AndreasT
Thank you, this solved my problem. :D