Validation of the BITS2.1 schema fails in Xerces, passes in Saxon EE. Something to do with xml.xsd. What's going on?

This should cover W3C XML Schema, Relax NG and DTD related problems.
dave76
Posts: 1
Joined: Tue Nov 21, 2023 8:04 pm

Validation of the BITS2.1 schema fails in Xerces, passes in Saxon EE. Something to do with xml.xsd. What's going on?

Post by dave76 »

I'm just getting started with XML schema and am trying to understand the BITS 2.1 schema, which is a schema for books, created by the US National Library of Medicine https://jats.nlm.nih.gov/extensions/bits/2.1/xsd.html

When I tried to validate it, I got the following warning and error:
W [oXygen] Hint: Some components referred by your schema were not found. If this schema file is included in a schema from where those components are visible then you should validate it starting from that main schema file. You can do this either by using the Main Files support (add the main schema file in the Main Files folder) or by creating a validation scenario (associated with the current file) that will validate the main schema file. Search for "Main Files Support" and/or "Validation Scenario" in the oXygen Help for more information.
E [Xerces] Cannot resolve the name 'xml:base' to a(n) 'attribute declaration' component.
Switching from Xerces to Saxon EE makes the error go away. I've gone back and forth a few times. It's a reproducible behaviour.

The error is raised by this declaration

Code: Select all

      <xsd:complexType mixed="true">
         <xsd:choice minOccurs="0" maxOccurs="unbounded">
            <xsd:group ref="abbrev-elements"/>
         </xsd:choice>
         <xsd:attribute name="alt" use="optional" type="xsd:string"/>
         <xsd:attribute name="content-type" use="optional" type="xsd:string"/>
         <xsd:attribute name="hreflang" use="optional" type="xsd:NMTOKEN"/>
         <xsd:attribute name="id" use="optional" type="xsd:ID"/>
         <xsd:attribute name="specific-use" use="optional" type="xsd:string"/>
         <xsd:attribute ref="xlink:actuate" use="optional"/>
         <xsd:attribute ref="xlink:href" use="optional"/>
         <xsd:attribute ref="xlink:role" use="optional"/>
         <xsd:attribute ref="xlink:show" use="optional"/>
         <xsd:attribute ref="xlink:title" use="optional"/>
         <xsd:attribute ref="xlink:type" use="optional" fixed="simple"/>
         <xsd:attribute ref="xml:base" use="optional"/>
         <xsd:attribute ref="xml:lang" use="optional"/>
      </xsd:complexType>
On the one hand, xml:base is part of the default XML elements. On the other hand, xmlns:xml isn't included in the namespace declaration in the xsd file I downloaded. That begs the question, should it be?

Code: Select all

<xsd:schema xmlns:mtl="http://www.mulberrytech.com/taglib"
            xmlns:c="http://www.w3.org/ns/xproc-step"
            xmlns:mml="http://www.w3.org/1998/Math/MathML"
            xmlns:xi="http://www.w3.org/2001/XInclude"
            xmlns:ali="http://www.niso.org/schemas/ali/1.0/"
            xmlns:xlink="http://www.w3.org/1999/xlink"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema">
In other words, why didn't NLM include xmlns:xml="..." in the above declaration?
It's also not explicitly imported. In fact, one clue as to what's going on is that in the main file of the schema, there's an import statement that's commented out.

Code: Select all

   <xsd:import namespace="http://www.w3.org/1999/xlink"
               schemaLocation="standard-modules/xlink.xsd"/>
   <xsd:import namespace="http://www.w3.org/1998/Math/MathML"
               schemaLocation="standard-modules/mathml3/mathml3.xsd"/>
   <xsd:import namespace="http://www.w3.org/2001/XInclude"
               schemaLocation="standard-modules/module-xi.xsd"/>
   <xsd:import namespace="http://www.niso.org/schemas/ali/1.0/"
               schemaLocation="standard-modules/module-ali.xsd"/>
<!--   <xsd:import namespace="http://www.w3.org/XML/1998/namespace"
               schemaLocation="standard-modules/xml.xsd"/>-->
   <xsd:include schemaLocation="BITS-book2-1-elements.xsd"/>
   
So I'm a bit confused. Is this Xerces not recognising that the base xml namespace is implicit, or should it actually be declared and Saxon EE is passing something that shouldn't be passed? Bearing in mind, I didn't write this schema, it's an industry standard schema in broad use, so I assume it's correct. Is this a known issue with validation and the commented out portion of the import statement a workaround?

Any insights into why this discrepancy is happening would be greatly appreciated.
teo
Posts: 57
Joined: Wed Aug 30, 2017 3:56 pm

Re: Validation of the BITS2.1 schema fails in Xerces, passes in Saxon EE. Something to do with xml.xsd. What's going on

Post by teo »

Hello Dave,

I think that the message returned by Xerces contains important information about the cause of the reported problem.
The schema you validated is part of a hierarchy.
Certain referenced components were not found because they are defined within other schemas in the respective hierarchy, but these schemas are not accessible.
You should check the <import> elements in the validated schema and their "schemaLocation" attributes.
The schema hierarchy of which the schema you validate takes part must be complete, all the sub-modules referred must be accessible.

The schema hierarchy under discussion (although it is about the previous version, i.e. 2.0 instead of 2.1) is also used in Oxygen.
You can consult the sub-directory "frameworks\jats\lib\schemas\BITS-2.0-XSD" in the directory where you installed Oxygen on your computer.

Regards,
Teo
Teodor Timplaru
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply