Oxygen / Schematron using wrong schema

This should cover W3C XML Schema, Relax NG and DTD related problems.
Richard_Wood
Posts: 16
Joined: Tue Jan 12, 2016 9:41 pm

Oxygen / Schematron using wrong schema

Post by Richard_Wood »

Oxygen / Schematron using wrong schema.

I am experiencing different results than another user in my group running the same test with the same files.
Therefore I suspect this is a Preferences setting.

I first experienced this issue after upgrading from Oxygen 16.1 to 17.1 (the version the other person is using)

I am using a Schematron schema to validate an XML file.
The schema for the XML file being validated has an element named <item> with attributes @href and @title.

The Schematron schema references an external file using the document($path) function to connect to an XML file.
The schema for the XML referenced file also contains an element named <item> with attributes @key and @value

The error that I am receiving is saying the attribute on the referenced file <item> element is not allowed:
- Attribute @key is not allowed on element <item>

It seems like Oxygen is trying to validate the reference XML file with the "wrong" schema.
I would suspect that I need to name space the referenced file but the same files work for another person in our group.
Can anyone tell me what Preference setting might be causing this or how to resolve it in some other way?

The definition for <item> in the referenced file is:

Code: Select all


    <xs:element name="item">
<xs:complexType>
<xs:attribute name="key"/>
<xs:attribute name="value"/>
</xs:complexType>
</xs:element>
The definition for <item> in the XML file I am trying to validate is:

Code: Select all


  <xs:element name="item" type="itemType"/>

<xs:complexType name="itemType">
<xs:sequence>
<xs:element ref="item" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="href" type="xs:anyURI"/>
<xs:attribute name="title" type="xs:string" use="required"/>
</xs:complexType>
Here is my schematron file:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
<pattern id="metaPiValidation">
<let name="regid" value="'documentTypes.xml'"/>
<let name="path" value="concat('file:/Y:/documentation/Schematron/SchematronSchemasEtc/registryXml/', $regid)"/>
<let name="categories" value="document($path)"/>
<rule context="/Document/ContentFile">
<report test="1">XML: <value-of select="$categories"/></report>
</rule>
</pattern>
</schema>
Here is the schema for the referenced XML file:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
<xs:element name="registry">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element ref="entry" maxOccurs="unbounded"/>
</xs:choice>
<xs:attribute name="schemaVersion" />
<xs:attribute name="identity" type="xs:NCName"/>
<xs:attribute name="modified" type="xs:dateTime" />
</xs:complexType>
</xs:element>
<xs:element name="entry">
<xs:complexType>
<xs:sequence>
<xs:element ref="item" maxOccurs="unbounded">
</xs:element>
</xs:sequence>
<xs:attribute name="status"/>
<xs:attribute name="modified"/>
</xs:complexType>
</xs:element>
<xs:element name="item">
<xs:complexType>
<xs:attribute name="key">
</xs:attribute>
<xs:attribute name="value">
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
Here is the referenced XML file:

Code: Select all


<?xml version="1.0" encoding="utf-8"?>
<registry xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="file:/Y:/documentation/Projects/DDMF/schema/1-0/registry.xsd"
schemaVersion="1.0"
identity="documentTypes"
modified="2015-07-07T11:29:02">
<entry status="stable" modified="2015-07-07T17:30:00Z" >
<item key="ns" value="TBC"/>
<item key="documentType" value="AAAE"/>
<item key="fic" value=""/>
<item key="documentTypeDisCo" value=""/>
<item key="category" value="CAT1001"/>
<item key="group" value=""/>
<item key="name" value="Electrical/Mechanical Parts Substitution"/>
<item key="supersededBy" value=""/>
</entry>
</registry>
Here is the XML file I am trying to validate:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<Document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="file:/Y:/documentation/Projects/DDMF/Schematron/demo.xsd" >
<status>test</status>
<packageTimestamp>2015-12-17T23:52:00Z</packageTimestamp>
<files>
<ContentFile>
<fileName>myFile.pdf</fileName>
<mediaType>application/pdf</mediaType>
</ContentFile>
</files>
<tableOfContents>
<item title="Title for My File">
<item href="myFile.pdf" title="The Real title of my document"/>
</item>
</tableOfContents>
</Document>
Here is the schema for the XML file that I am trying to validate:

Code: Select all


<?xml version="1.0" encoding="UTF-8" ?> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="3.0">
<xs:element name="Document">
<xs:complexType>
<xs:sequence maxOccurs="1">
<xs:element ref="status"/>
<xs:element ref="packageTimestamp"/>
<xs:element name="files" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element ref="ContentFile" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element ref="tableOfContents" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ContentFile">
<xs:complexType>
<xs:sequence maxOccurs="1">
<xs:group ref="file"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="fileName" type="xs:anyURI"/>
<xs:element name="item" type="itemType"/>
<xs:element name="mediaType"/>
<xs:element name="packageTimestamp" type="xs:dateTime"/>
<xs:element name="status"/>
<xs:element name="tableOfContents">
<xs:complexType>
<xs:sequence>
<xs:element ref="item"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:group name="file">
<xs:sequence>
<xs:element ref="fileName"/>
<xs:element ref="mediaType" minOccurs="0"/>
</xs:sequence>
</xs:group>
<xs:complexType name="itemType">
<xs:sequence>
<xs:element ref="item" maxOccurs="unbounded" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="href" type="xs:anyURI"/>
<xs:attribute name="title" type="xs:string" use="required"/>
</xs:complexType>
</xs:schema>
tavy
Posts: 364
Joined: Thu Jul 01, 2004 12:29 pm

Re: Oxygen / Schematron using wrong schema

Post by tavy »

Hello,

The errors appears because you use Saxon EE (schema-aware) for the Schematron validation.
It seems to be a problem with the Saxon transformation. This is because both XML documents have the same namespace and Saxon uses the same XSD file to validate both instances. I will add an issue with this problem at Saxon.
Until this problem will be solved in Saxon you can deactivate the Saxon EE (schema-aware) for Schematron validation. You can do this by unchecking the "Use Saxon EE (schema aware) for xslt2/xslt3 query language binding" option from the Schematron options page.

Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
Richard_Wood
Posts: 16
Joined: Tue Jan 12, 2016 9:41 pm

Re: Oxygen / Schematron using wrong schema

Post by Richard_Wood »

Octavian,

Thank-you very much for identifying this.
I deselected "Use Saxon EE (schema aware) for xslt2/xslt3 query language binding"
on the Preferences=>XML=>XML Parser=>Schematron menu and it solved the problem!

I will have a much better day today than yesterday :-)

Thanks again!

Rich
Post Reply