Я пытаюсь переопределить атрибут maxOccurs
элемента в простой XML-схеме, используя плагин Eclipse WTP в качестве моей IDE.
Файл: widget1.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://www.example.org/widget"
elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.example.org/widget">
<xsd:complexType name="WidgetType">
<xsd:sequence>
<xsd:element name="Name" type="xsd:string"/>
<xsd:element name="ProductID" type="xsd:unsignedInt"/>
</xsd:sequence>
</xsd:complexType>
<xsd:element name="Widgets">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Widget" type="tns:WidgetType" minOccurs="1" maxOccurs="65536"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Файл: widget2.xsd В этом файле я хочу переопределить атрибут maxOccurs
для Widget
до 10.
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://www.example.org/widget" elementFormDefault="qualified"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://www.example.org/widget">
<xsd:include schemaLocation="widget1.xsd"/>
<xsd:redefine schemaLocation="widget1.xsd">
<xsd:complexType name="Widgets">
<xsd:complexContent>
<xsd:restriction base="Widgets">
<xsd:sequence>
<xsd:element name="tns:Widget" maxOccurs="10"/>
</xsd:sequence>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:redefine>
</xsd:schema>
Однако проверка на widget2.xsd не удалась, и Eclipse сообщает об этой ошибке
Multiple annotations found at this line:
- src-resolve.4.1: Error resolving component 'Widgets'. It was detected that 'Widgets' has no namespace, but components with no target namespace are not referenceable from schema document 'file:///C:/Projects/Test/XMLSchema/Widget/widget2.xsd'. If 'Widgets' is intended to have a namespace, perhaps a prefix needs to be provided. If it is intended that 'Widgets' has no namespace, then an 'import' without a "namespace" attribute should be added to 'file:///C:/Projects/Test/XMLSchema/Widget/widget2.xsd'.
- src-redefine.5.b.d: 'restriction' does not have a 'base' attribute that refers to the redefined element, 'http://www.example.org/widget,Widgets'. <complexType> children of <redefine> elements must have <extension> or <restriction> descendants, with 'base' attributes that refer to themselves.
Я попытался заменить Widgets
в <redefine>
на tns:Widgets
в надеждеизбавиться от ошибки пространства имен, но это тоже не работает.
Что означает эта ошибка?И возможно ли то, что я пытаюсь сделать вообще?