XInclude usage and xsi:noNamespaceSchemaLocation limitation, workaround?

This should cover W3C XML Schema, Relax NG and DTD related problems.
ssenegas
Posts: 2

XInclude usage and xsi:noNamespaceSchemaLocation limitation, workaround?

Fri Dec 07, 2012 6:12 pm

First, thank you for being indulgent, I am an XML Schema beginner.

I have build a XML file split up with several includes, using XInclude. I have chosen this method above others because each included XML files can be standalone validated.

As I am working on local file, I didn't defined any namespace and then I use xsi:noNamespaceSchemaLocation attribute to reference my xsd file.

parameters.xml

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="parameters.xsd">
    <xi:include href="./Transducers/transducers.xml" parse="xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
</Root>


parameters.xsd

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:include schemaLocation="./Transducers/transducers.xsd"/>
    <xs:element name="Root">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="Transducers" minOccurs="1" maxOccurs="1"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>


Tranducers/transducer.xml

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<Transducers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="./transducers.xsd">
...
</Transducers>

I don't put the transducers.xsd file because it doesn't give anymore added value to the problem. Just take into account that the transducer.xml is valid against his schema.

So, when I try to validate parameters.xml I got the following error :

The 'noNamespaceSchemaLocation' attribute references a schema whose target namespace was already used for validation.

Error that I can easily understand, but I can not get around in my situation.

What would be the solution in that case. Thanks.
adrian
Posts: 2442

Re: XInclude usage and xsi:noNamespaceSchemaLocation limitation, workaround?

Tue Dec 11, 2012 6:27 pm

Hi,

I wasn't able to reproduce the context to obtain this error in Oxygen. In my case the validation worked just fine. Are you validating with Oxygen or a different tool?

My transducers.xsd schema looks like this:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"  elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:element name="Transducers"/>
</xs:schema>

I've seen a discussion about his on stackoverflow here:
XInclude Schema/Namespace Problem?

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
ssenegas
Posts: 2

Re: XInclude usage and xsi:noNamespaceSchemaLocation limitation, workaround?

Wed Dec 12, 2012 5:44 pm

Validation made with Oxygen, here is the result after validation

Code: Select all

SystemID: \\Aphrodite\Public\ParametersForMB760\Schemas\Project\Transducers\transducers.xml
Engine name: Xerces
Severity: error
Description: cvc-complex-type.3.2.2: Attribute 'xml:base' is not allowed to appear in element 'Transducers'.
Start location: 3:118
URL: http://www.w3.org/TR/xmlschema-1/#cvc-complex-type


The line which cause the error is the following :

<Transducers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="./transducers.xsd">

Here is my transducers.xsd file

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
   <xs:include schemaLocation="./amode.xsd"/>
   <xs:simpleType name="stringtype">
      <xs:restriction base="xs:string"/>
   </xs:simpleType>
   <xs:simpleType name="inttype">
      <xs:restriction base="xs:positiveInteger"/>
   </xs:simpleType>
   <xs:simpleType name="dectype">
      <xs:restriction base="xs:decimal"/>
   </xs:simpleType>
   <xs:simpleType name="booltype">
      <xs:restriction base="xs:boolean"/>
   </xs:simpleType>
   <xs:simpleType name="possibleanglelist_type">
      <xs:list itemType="xs:integer"/>
   </xs:simpleType>
   <xs:simpleType name="numberofelements_type">
      <xs:restriction base="xs:integer">
         <xs:minInclusive value="0" fixed="false"/>
         <xs:maxInclusive value="128" fixed="false"/>
      </xs:restriction>
   </xs:simpleType>
   <xs:simpleType name="steeringcoef_type">
      <xs:restriction base="dectype">
         <xs:minInclusive value="0" fixed="false"/>
         <xs:maxInclusive value="1" fixed="false"/>
      </xs:restriction>
   </xs:simpleType>
   <xs:simpleType name="radius_typevalue">
      <xs:restriction base="dectype">
         <xs:minInclusive value="0" fixed="false"/>
         <xs:maxInclusive value="100" fixed="false"/>
      </xs:restriction>
   </xs:simpleType>
   <xs:complexType name="width_type">
      <xs:simpleContent>
         <xs:extension base="xs:decimal">
            <xs:attribute name="unit" type="distanceunit_type" use="required"/>
         </xs:extension>
      </xs:simpleContent>
   </xs:complexType>
   <xs:complexType name="radius_type">
      <xs:simpleContent>
         <xs:extension base="radius_typevalue">
            <xs:attribute name="unit" type="xs:token" default="mm"/>
         </xs:extension>
      </xs:simpleContent>
   </xs:complexType>
   <xs:simpleType name="crystaltofacedistance_typevalue">
      <xs:restriction base="dectype">
         <xs:minInclusive value="0" fixed="false"/>
         <xs:maxInclusive value="10" fixed="false"/>
      </xs:restriction>
   </xs:simpleType>
   <xs:simpleType name="distanceunit_type">
      <xs:restriction base="xs:token">
         <xs:enumeration value="mm"/>
         <xs:enumeration value="cm"/>
         <xs:enumeration value="dm"/>
         <xs:enumeration value="m"/>
      </xs:restriction>
   </xs:simpleType>
   <xs:complexType name="crystaltofacedistance_type">
      <xs:simpleContent>
         <xs:extension base="crystaltofacedistance_typevalue">
            <xs:attribute name="unit" type="distanceunit_type" use="required"/>
         </xs:extension>
      </xs:simpleContent>
   </xs:complexType>
   <xs:simpleType name="centrefrequency_typevalue">
      <xs:restriction base="xs:decimal">
         <xs:minInclusive value="0" fixed="false"/>
         <xs:maxInclusive value="15" fixed="false"/>
      </xs:restriction>
   </xs:simpleType>
   <xs:simpleType name="frequencyunit_type">
      <xs:restriction base="xs:token">
         <xs:enumeration value="Hz"/>
         <xs:enumeration value="KHz"/>
         <xs:enumeration value="MHz"/>
      </xs:restriction>
   </xs:simpleType>
   <xs:complexType name="centrefrequency_type">
      <xs:simpleContent>
         <xs:extension base="centrefrequency_typevalue">
            <xs:attribute name="unit" type="frequencyunit_type" use="required"/>
         </xs:extension>
      </xs:simpleContent>
   </xs:complexType>
   <xs:complexType name="lineararraytransducer_type">
      <xs:complexContent>
         <xs:extension base="electronicarraytransducer_type">
            <xs:sequence>
               <xs:element name="possibleAngleList" type="possibleanglelist_type"/>
               <xs:element name="steeringCoef" type="steeringcoef_type"/>
            </xs:sequence>
         </xs:extension>
      </xs:complexContent>
   </xs:complexType>
   <xs:complexType name="curvedarraytransducer_type">
      <xs:complexContent>
         <xs:extension base="electronicarraytransducer_type">
            <xs:sequence>
               <xs:element name="possibleAngleList" type="possibleanglelist_type"/>
               <xs:element name="radius" type="radius_type"/>
            </xs:sequence>
         </xs:extension>
      </xs:complexContent>
   </xs:complexType>
   <xs:complexType name="phasedarraytransducer_type">
      <xs:complexContent>
         <xs:extension base="electronicarraytransducer_type">
            <xs:sequence>
               <xs:element name="possibleAngleList" type="possibleanglelist_type"/>
            </xs:sequence>
         </xs:extension>
      </xs:complexContent>
   </xs:complexType>
   <xs:complexType name="electronicarraytransducer_type" abstract="true">
      <xs:annotation>
         <xs:documentation>Defines the electronic transducer abstract type.</xs:documentation>
      </xs:annotation>
      <xs:complexContent>
         <xs:extension base="transducer_type">
            <xs:sequence>
               <xs:element name="spatialCompound" type="booltype"/>
            </xs:sequence>
         </xs:extension>
      </xs:complexContent>
   </xs:complexType>
   <xs:complexType name="transducer_type" abstract="true">
      <xs:annotation>
         <xs:documentation xml:lang="en">Defines the transducer abstract type.</xs:documentation>
      </xs:annotation>
      <xs:sequence>
         <xs:element name="crystalToFaceDistance" type="crystaltofacedistance_type" default="0"/>
         <xs:element name="numberOfElements" type="numberofelements_type" default="64"/>
         <xs:element name="centreFrequency" type="centrefrequency_type" default="0"/>
         <xs:element name="width" type="width_type" default="20"/>
         <xs:element name="AMode" type="amode_type"/>
      </xs:sequence>
      <xs:attribute name="name" type="stringtype" use="required"/>
   </xs:complexType>
   <xs:element name="Transducer" type="transducer_type"/>
   <xs:element name="ElectronicArrayTransducer" type="electronicarraytransducer_type" substitutionGroup="Transducer"/>
   <xs:element name="LinearArrayTransducer" type="lineararraytransducer_type" substitutionGroup="Transducer"/>
   <xs:element name="PhasedArrayTransducer" type="phasedarraytransducer_type" substitutionGroup="Transducer"/>
   <xs:element name="CurvedArrayTransducer" type="curvedarraytransducer_type" substitutionGroup="Transducer"/>
   <xs:element name="Transducers">
      <xs:complexType>
         <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element ref="Transducer"/>
         </xs:choice>
      </xs:complexType>
   </xs:element>
</xs:schema>


Could you try it and tell me what you obtain ?

Regards,
Sébastien
ionela
Posts: 187

Re: XInclude usage and xsi:noNamespaceSchemaLocation limitation, workaround?

Wed Dec 12, 2012 8:06 pm

Hi Sébastien,

Thank for sharing also transducers.xsd file with us.

Now, I was able to reproduce this error on our side. In order to avoid it you need to disable
Base URI fix-up option from Option -> Preferences -> XML / XML Parser.
You can find more details about this in our user manual:
http://www.oxygenxml.com/doc/ug-editor/ ... arser.html

Regards,
Ionela
Ionela Istodor
oXygen XML Editor and Author Support

Return to “XML Schemas”

Who is online

Users browsing this forum: No registered users and 0 guests