XSD Validation Error (Import schema)
This should cover W3C XML Schema, Relax NG and DTD related problems.
-
- Posts: 1
- Joined: Mon Dec 17, 2012 1:02 pm
XSD Validation Error (Import schema)
Post by mamtarun1828 »
Hi
I need some help regarding XML Schema Validation.
I am struck with XSD validation issues when I try to reference other schema in base schema.
I am getting the error message "src-resolve: Cannot resolve the name 'cmn:MasterNode' to a(n) 'type definition' component."
Stripped Version of Schema Design is listed below
1. Base Schema file (v21.xsd) references element "MasterNode" of the schema v2_refer.xsd . On validation of schema , gets the error message as listed above
<xs:schemaattributeFormDefault="unqualified"
elementFormDefault="qualified"
xmlns:cmn="file:///Users/tarun/schema/v2refer/v2_refer"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="file:///Users/tarun/schema">
<xs:importnamespace="file:///Users/tarun/schema/v2refer/v2_refer"schemaLocation="/Users/tarun/schema/v2refer/v2_refer.xsd"/>
<xs:elementname="TestMaster"type="cmn:MasterNode"></xs:element>
<xs:elementname="ROOT">
<xs:complexType>
<xs:sequence>
<xs:elementname="NOD">
<xs:complexType>
<xs:sequence>
<xs:elementname="Nod"maxOccurs="10">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
2) Schema that is being referenced is defined below
<xs:schemaattributeFormDefault="unqualified"elementFormDefault="qualified"
targetNamespace="file:///Users/tarun/schema/v2refer/v2_refer"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:cmn="file:///Users/tarun/schema/v2refer/v2_refer"
>
<xs:elementname="MasterNode">
<xs:complexType>
<xs:sequence>
<xs:elementtype="xs:string"name="Tomcat"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Any help will be highly appreciated.
Thanks,
Tarun
I need some help regarding XML Schema Validation.
I am struck with XSD validation issues when I try to reference other schema in base schema.
I am getting the error message "src-resolve: Cannot resolve the name 'cmn:MasterNode' to a(n) 'type definition' component."
Stripped Version of Schema Design is listed below
1. Base Schema file (v21.xsd) references element "MasterNode" of the schema v2_refer.xsd . On validation of schema , gets the error message as listed above
<xs:schemaattributeFormDefault="unqualified"
elementFormDefault="qualified"
xmlns:cmn="file:///Users/tarun/schema/v2refer/v2_refer"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="file:///Users/tarun/schema">
<xs:importnamespace="file:///Users/tarun/schema/v2refer/v2_refer"schemaLocation="/Users/tarun/schema/v2refer/v2_refer.xsd"/>
<xs:elementname="TestMaster"type="cmn:MasterNode"></xs:element>
<xs:elementname="ROOT">
<xs:complexType>
<xs:sequence>
<xs:elementname="NOD">
<xs:complexType>
<xs:sequence>
<xs:elementname="Nod"maxOccurs="10">
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
2) Schema that is being referenced is defined below
<xs:schemaattributeFormDefault="unqualified"elementFormDefault="qualified"
targetNamespace="file:///Users/tarun/schema/v2refer/v2_refer"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:cmn="file:///Users/tarun/schema/v2refer/v2_refer"
>
<xs:elementname="MasterNode">
<xs:complexType>
<xs:sequence>
<xs:elementtype="xs:string"name="Tomcat"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Any help will be highly appreciated.
Thanks,
Tarun
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: XSD Validation Error (Import schema)
Hi,
You're referring to a type that does not exist.
<xs:element name="TestMaster" type="cmn:MasterNode"></xs:element>
What does exist with that name (MasterNode) is an element, NOT a type:
<xs:element name="MasterNode">
So, rewrite v2_refer.xsd as:
and in the main schema refer the type:
BTW, file URLs as namespaces are rather uncommon (e.g. file:///Users/tarun/schema/v2refer/v2_refer). You might want to use something simpler. It doesn't have to be an existing URL (or even an URL).
e.g. "http://v2refer.ns" or "my.ns.v2"
For schemaLocation you might want to use a relative path instead, especially if the schemas are kept together in close proximity (same or adjacent folder).
Regards,
Adrian
You're referring to a type that does not exist.
<xs:element name="TestMaster" type="cmn:MasterNode"></xs:element>
What does exist with that name (MasterNode) is an element, NOT a type:
<xs:element name="MasterNode">
So, rewrite v2_refer.xsd as:
Code: Select all
<xs:complexType name="MasterNodeType">
<xs:sequence>
<xs:element type="xs:string" name="Tomcat"/>
</xs:sequence>
</xs:complexType>
<xs:element name="MasterNode" type="cmn:MasterNodeType"/>
Code: Select all
<xs:element name="TestMaster" type="cmn:MasterNodeType"/>
e.g. "http://v2refer.ns" or "my.ns.v2"
For schemaLocation you might want to use a relative path instead, especially if the schemas are kept together in close proximity (same or adjacent folder).
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service