Reputation: 107
Below is my XSD. I am getting errors. Could you please validate this?
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://api.vvz.com/"
xmlns:vz="http://api.vvz.com/"
targetNamespace="http://api.vvz.com/">
<vz:element name="Account">
<annotation>
<documentation>
A sample element
</documentation>
</annotation>
<simpleType name="ID">
<restriction base="xs:string">
<pattern value='[a-zA-Z0-9]'/>
</restriction>
</simpleType>
<complexType>
<complexContent>
<sequence>
<element minOccurs="0" maxOccurs="unbounded" name="fieldsToNull"
nillable="true" type="string"/>
<element minOccurs="0" maxOccurs="1" name="Id" nillable="true"
type="vz:ID"/>
</sequence>
</complexContent>
</complexType>
</vz:element>
</xsd:schema>
The error is
The namespace of element schema must be from schema namespace 'http://www.w3.org/2001/XMLSchema'
Please help me out.
Upvotes: 2
Views: 12667
Reputation: 111491
Your immediate error regarding the target namespace is due to declaring xmlns="http://api.vvz.com/"
on xsd:schema
. Remove that. You don't want the XSD itself in that namespace; you want the governed XML in that namespace, and that's already achieved via targetNamespace="http://api.vvz.com/"
.
The rest of your XSD has many errors and unclear goals. Here's one set of consistent repairs that brings it to be valid:
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:vz="http://api.vvz.com/"
targetNamespace="http://api.vvz.com/">
<xsd:element name="Account" type="vz:AccountType">
<xsd:annotation>
<xsd:documentation>
A sample element
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:complexType name="AccountType">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="fieldsToNull"
nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" maxOccurs="1" name="Id" nillable="true"
type="vz:IdType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="IdType">
<xsd:restriction base="xsd:string">
<xsd:pattern value='[a-zA-Z0-9]'/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
Upvotes: 4
Reputation: 7279
There were a couple of issues:
xsd
prefix).string
must also be in the XML Schema namespace (xsd
prefix).The element complexContent
was extraneous.
<?xml version="1.0" encoding="windows-1252" ?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://api.vvz.com/"
xmlns:vz="http://api.vvz.com/"
targetNamespace="http://api.vvz.com/">
<xsd:simpleType name="ID">
<xsd:restriction base="xsd:string">
<xsd:pattern value='[a-zA-Z0-9]'/>
</xsd:restriction>
</xsd:simpleType>
<xsd:annotation>
<xsd:documentation>
A sample element
</xsd:documentation>
</xsd:annotation>
<xsd:element name="Account">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="fieldsToNull"
nillable="true" type="xsd:string"/>
<xsd:element minOccurs="0" maxOccurs="1" name="Id" nillable="true"
type="vz:ID"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Upvotes: 0