Validation of XML Schema by other XML Schema
Having trouble installing Oxygen? Got a bug to report? Post it all here.
Validation of XML Schema by other XML Schema
Dear colleagues,
My overall goal is to develop XML Schema for domains-specific XML Schemas. I'm trying to do so following the hints given in the article at http://www.xml.com/pub/a/2002/10/02/metaschema.html.
Is there some way how to force Oxygen to use my own XML Schema for http://www.w3.org/2001/XMLSchema namespace instead of some built-in one? I searched the Options|Properties and there is nothing like that. I'm quite sure that it is not enough to set the schemaLocation attribute (yes, I know that W3C specs do not require processor to handle schemaLocation attribute).
My current testcase is the following.The first code snip is an empty instance XML Schema that is validated by Oxygen. I require it to be validated by XMLSchemaErrated.xsd schema downloaded from http://www.w3.org/2001/XMLSchema.xsd (which I renamed). To ensure myself that the downloaded schema is used for validation I modified definition of xs:schema element -- 1) I changed the type of targetNamespace attribute from xs:anyURI to xs:nonNegativeInteger and 2) I added mandatory attribute xxx. Both changes are marked with bold font in the second code snip, where I show the relevant part of xs:schema element of XMLSchemaErrated.xsd. The expected result is that the schema instance (the first code snip) bellow will not be validated with two errors. However it is validated.
My question is: What is wrong?
--- code snip 1 ---
<?xml version='1.0' encoding='UTF-8'?>
<xs:schema
targetNamespace="http://www.w3.org/2001/XMLSchema"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/XMLSchema XMLSchemaErrated.xsd"
>
</xs:schema>
--- code snip 1 ---
--- code snip 2 ---
<xs:element name="schema" id="schema">
<xs:annotation>
<xs:documentation source="http://www.w3.org/TR/xmlschema-1/#element-schema"/>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="xs:openAttrs">
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="xs:include"/>
<xs:element ref="xs:import"/>
<xs:element ref="xs:redefine"/>
<xs:element ref="xs:annotation"/>
</xs:choice>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:group ref="xs:schemaTop"/>
<xs:element ref="xs:annotation" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:sequence>
<xs:attribute name="targetNamespace" type="xs:nonNegativeInteger"/>
<xs:attribute name="version" type="xs:token"/>
<xs:attribute name="finalDefault" type="xs:fullDerivationSet" use="optional" default=""/>
<xs:attribute name="blockDefault" type="xs:blockSet" use="optional" default=""/>
<xs:attribute name="attributeFormDefault" type="xs:formChoice" use="optional" default="unqualified"/>
<xs:attribute name="elementFormDefault" type="xs:formChoice" use="optional" default="unqualified"/>
<xs:attribute name="id" type="xs:ID"/>
<xs:attribute ref="xml:lang"/>
<xs:attribute name="xxx" type="xs:string" use="required"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
...
</xs:element>
--- code snip 2 ---
Thank you for your help!
Regards,
Ondrej
PS: (off-topic) note: I have schema-full-checking in on
My overall goal is to develop XML Schema for domains-specific XML Schemas. I'm trying to do so following the hints given in the article at http://www.xml.com/pub/a/2002/10/02/metaschema.html.
Is there some way how to force Oxygen to use my own XML Schema for http://www.w3.org/2001/XMLSchema namespace instead of some built-in one? I searched the Options|Properties and there is nothing like that. I'm quite sure that it is not enough to set the schemaLocation attribute (yes, I know that W3C specs do not require processor to handle schemaLocation attribute).
My current testcase is the following.The first code snip is an empty instance XML Schema that is validated by Oxygen. I require it to be validated by XMLSchemaErrated.xsd schema downloaded from http://www.w3.org/2001/XMLSchema.xsd (which I renamed). To ensure myself that the downloaded schema is used for validation I modified definition of xs:schema element -- 1) I changed the type of targetNamespace attribute from xs:anyURI to xs:nonNegativeInteger and 2) I added mandatory attribute xxx. Both changes are marked with bold font in the second code snip, where I show the relevant part of xs:schema element of XMLSchemaErrated.xsd. The expected result is that the schema instance (the first code snip) bellow will not be validated with two errors. However it is validated.
My question is: What is wrong?
--- code snip 1 ---
<?xml version='1.0' encoding='UTF-8'?>
<xs:schema
targetNamespace="http://www.w3.org/2001/XMLSchema"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/XMLSchema XMLSchemaErrated.xsd"
>
</xs:schema>
--- code snip 1 ---
--- code snip 2 ---
<xs:element name="schema" id="schema">
<xs:annotation>
<xs:documentation source="http://www.w3.org/TR/xmlschema-1/#element-schema"/>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="xs:openAttrs">
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="xs:include"/>
<xs:element ref="xs:import"/>
<xs:element ref="xs:redefine"/>
<xs:element ref="xs:annotation"/>
</xs:choice>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:group ref="xs:schemaTop"/>
<xs:element ref="xs:annotation" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:sequence>
<xs:attribute name="targetNamespace" type="xs:nonNegativeInteger"/>
<xs:attribute name="version" type="xs:token"/>
<xs:attribute name="finalDefault" type="xs:fullDerivationSet" use="optional" default=""/>
<xs:attribute name="blockDefault" type="xs:blockSet" use="optional" default=""/>
<xs:attribute name="attributeFormDefault" type="xs:formChoice" use="optional" default="unqualified"/>
<xs:attribute name="elementFormDefault" type="xs:formChoice" use="optional" default="unqualified"/>
<xs:attribute name="id" type="xs:ID"/>
<xs:attribute ref="xml:lang"/>
<xs:attribute name="xxx" type="xs:string" use="required"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
...
</xs:element>
--- code snip 2 ---
Thank you for your help!
Regards,
Ondrej
PS: (off-topic) note: I have schema-full-checking in on
Hi Ondrej,
When you open a schema file in oXygen it is opened in a special editor for XML Schemas. The validate action performs a validation of the schema file content that is not a check against the schema for schemas. The validation is done by Xerces checking a lot of rules that cannot be expressed inside a schema file.
If you want to check a schema against a schema file just change the file to have the extension xml or some other extension associated with the XML Editor (for instance you can associate the .schema extension with the xml editor in the Options->Prefereces -- File types dialog). Then the validate action will perform a validation against the specified schema.
I took the http://www.w3.org/2001/XMLSchema.xsd schema and I changed only the target namespace as in your message, then the following document:
gives the following errors:
Best Regards,
George
When you open a schema file in oXygen it is opened in a special editor for XML Schemas. The validate action performs a validation of the schema file content that is not a check against the schema for schemas. The validation is done by Xerces checking a lot of rules that cannot be expressed inside a schema file.
If you want to check a schema against a schema file just change the file to have the extension xml or some other extension associated with the XML Editor (for instance you can associate the .schema extension with the xml editor in the Options->Prefereces -- File types dialog). Then the validate action will perform a validation against the specified schema.
I took the http://www.w3.org/2001/XMLSchema.xsd schema and I changed only the target namespace as in your message, then the following document:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/XMLSchema file:/D:/test/current/XMLSchema.xsd"
targetNamespace="test">
</schema>
Code: Select all
E cvc-datatype-valid.1.2.1: 'test' is not a valid value for 'integer'. schemaTest.xml file:/D:/test/current/schemaTest.xml 5:1
E cvc-attribute.3: The value 'test' of attribute 'targetNamespace' on element 'schema' is not valid with respect to its type, 'nonNegativeInteger'. schemaTest.xml file:/D:/test/current/schemaTest.xml 5:1
George
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