Page 1 of 1

validation of XML-instances consisting of elements from different namespaces

Posted: Mon Aug 04, 2025 6:07 pm
by fleert
hi

Not a problem with oXygen itself, but just wondering how to replicate the handy validation functionality offered bij oXygen in another framework.
I have XML-instances such as:

Code: Select all

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
  xmlns:my="https://example.com/my-ns"
  xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="
    http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd  
    https://example.com/my-ns https://example.com/my-ns/my-schema.xsd">
  <url>
    <loc>https://example.com/my-ns/my-sitemap</loc>
    <lastmod>2022-09-02T00:00:00+02:00</lastmod>
    <changefreq>weekly</changefreq>
    <priority>1</priority>
    <my:Extension>
      <my:element>....</my:element>
    </my:Extension>
  </url>
</urlset>
Both the XSDs mentioned in @xsi:schemaLocation are resolvable by oXygen using OASIS catalogs. The sitemap.xsd allows xs:any at the end of <url>, as shown in my example: <my:Extension>. All works fine: non-conforming validation errors against both the sitemap.xsd and my-schema.xsd are reported.
BTW: I cannot change sitemap.xsd but have full control over my-schema.xsd.

But now I need to mimic this functionality using Xerxes in another framework, so not using oXygen. Now the validation reports include errors
  • for elements from sitemap.xsd but not present in my-schema.xsd: Cannot find the declaration of element 'urlset'.
  • from sitemap.xsd itself: The matching wildcard is strict, but no declaration can be found for element my:Extension
How does oXygen call Xerces to make this work? And how would I be able to replicate that?

Any help appreciated.
Theun

Re: validation of XML-instances consisting of elements from different namespaces

Posted: Tue Aug 05, 2025 7:32 am
by Radu
Hi Theun,
Oxygen does not invoke the Xerces library from the command line, it works with the library directly in the Java code and we have lots of code which deals with validation, changes made to the Xerces parser.
I would suggest you take a look at the Xerces features list:
https://xerces.apache.org/xerces2-j/features.html
There is a feature named "http://apache.org/xml/features/honour-a ... aLocations", maybe this is the feature which needs to be enabled. But I'm not sure, this needs to be tested.
Regards,
Radu

Re: validation of XML-instances consisting of elements from different namespaces

Posted: Tue Aug 05, 2025 11:04 am
by fleert
hi Radu,

Thanks for your quick reply (as always). I will need to try and test the Xerxes features. Not sure I can mimic oXygen though :-)

keep up the good work
Theun