'error while try to import xsd schema to excel
I have the following schema
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="import">
<xs:complexType>
<xs:sequence>
<xs:element name="node">
<xs:complexType>
<xs:attribute name="action" type="xs:string" default="create"/>
<xs:attribute name="type" type="xs:string" default="document"/>
<xs:element name="location" type="xs:string"/>
<xs:element name="file" type="xs:string"/>
<xs:element name="title" type="xs:string">
<xs:complexType>
<xs:attribute name="language" type="xs:string" default="en"/>
</xs:complexType>
</xs:element>
<xs:element name="attribute">
<xs:complexType>
<xs:simpleContent>
<xs:extension>
<xs:attribute name="name" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="الجهة المرسل اليها"/>
<xs:enumeration value="الجهة المرسلة للخطاب"/>
<xs:enumeration value="الموضوع المختصر"/>
<xs:enumeration value="تاريخ الحافظة"/>
<xs:enumeration value="تاريخ المراسلة"/>
<xs:enumeration value="رقم الخطاب الخاص بالجهة"/>
<xs:enumeration value="رقم القرار"/>
<xs:enumeration value="رقم المراسلة الخاص بالجهاز"/>
<xs:enumeration value="عنوان الخطاب"/>
<xs:enumeration value="كود المراسلة"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="category">
<xs:complexType>
<xs:sequence>
<xs:element ref="attribute" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
when I tried to import it inside excel it gives me the following error
Solution 1:[1]
You have several errors in your XSD:
Attribute declarations have to appear after the elements. Yes, it is one of the quirky "features" of XSD
Your elements in your
complexTypehave to be in anxs:sequence.You can only have either a
type=...attribute on you elements or anxs:complexTypechild (orxs:simpleTypeof course, but here it doesn't matter).Thexs:extensionrequires abaseattribute. I set it toxs:string`, guessing... change it if it doesn't fit.I couldn't fix your last error which is a reference without a definition that is referred to:
Cannot resolve the name 'attribute' to a(n) 'element declaration' component.
in the line
<xs:element ref="attribute" maxOccurs="unbounded"/>
So a (mostly) fiex version of your XSD looks like
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="import">
<xs:complexType>
<xs:sequence>
<xs:element name="node">
<xs:complexType>
<xs:sequence>
<xs:element name="location" type="xs:string"/>
<xs:element name="file" type="xs:string"/>
<xs:element name="title">
<xs:complexType>
<xs:attribute name="language" type="xs:string" default="en"/>
</xs:complexType>
</xs:element>
<xs:element name="attribute">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="????? ?????? ?????"/>
<xs:enumeration value="????? ??????? ??????"/>
<xs:enumeration value="??????? ???????"/>
<xs:enumeration value="????? ???????"/>
<xs:enumeration value="????? ????????"/>
<xs:enumeration value="??? ?????? ????? ??????"/>
<xs:enumeration value="??? ??????"/>
<xs:enumeration value="??? ???????? ????? ???????"/>
<xs:enumeration value="????? ??????"/>
<xs:enumeration value="??? ????????"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="category">
<xs:complexType>
<xs:sequence>
<xs:element ref="attribute" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="action" type="xs:string" default="create"/>
<xs:attribute name="type" type="xs:string" default="document"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
As said above, the problem with the line
<xs:element ref="attribute" maxOccurs="unbounded"/>
remains unsolved and I cannot infer a solution without the greater context, so I leave it to your expertise to fix that.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | zx485 |

