Я хочу переопределить / ограничить сложный тип из схемы Oasis XML DSig.
xmldsig-core-schema.xsd
<complexType name="TransformType" mixed="true">
<choice minOccurs="0" maxOccurs="unbounded">
<any namespace="##other" processContents="lax"/>
<!-- (1,1) elements from (0,unbounded) namespaces -->
<element name="XPath" type="string"/>
</choice>
<attribute name="Algorithm" type="anyURI" use="required"/>
</complexType>
I хотите разрешить только один явный тип элемента из пространства имен ##other
.
xmldsig-limited.xsd
(1) Это работает :
<xs:redefine schemaLocation="xmldsig-core-schema.xsd">
<xs:complexType name="TransformType">
<xs:complexContent>
<xs:restriction base="ds:TransformType">
<xs:choice minOccurs="1" maxOccurs="1"> <!--diff-->
<xs:element name="XPath" type="xs:string"/>
<!--<xs:any namespace="##other" processContents="lax"/>-->
</xs:choice>
<xs:attribute name="Algorithm" type="xs:anyURI" use="required"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:redefine>
(2) Это также работает:
<xs:redefine schemaLocation="xmldsig-core-schema.xsd">
<xs:complexType name="TransformType">
<xs:complexContent>
<xs:restriction base="ds:TransformType">
<xs:choice minOccurs="0" maxOccurs="unbounded">
<!--<xs:element name="XPath" type="xs:string"/>-->
<xs:any namespace="##other" processContents="lax"/>
</xs:choice>
<xs:attribute name="Algorithm" type="xs:anyURI" use="required"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:redefine>
(3) Это НЕ работает:
<xs:redefine schemaLocation="xmldsig-core-schema.xsd">
<xs:complexType name="TransformType">
<xs:complexContent>
<xs:restriction base="ds:TransformType">
<xs:choice minOccurs="1" maxOccurs="1"> <!--diff-->
<!--<xs:element name="XPath" type="xs:string"/>-->
<xs:any namespace="##other" processContents="lax"/>
</xs:choice>
<xs:attribute name="Algorithm" type="xs:anyURI" use="required"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:redefine>
Ошибка:
cos-particle-restrict.2: Forbidden particle restriction: 'choice:all,sequence,elt'.
(4) Это (желаемое определение) также НЕ работает:
<xs:redefine schemaLocation="xmldsig-core-schema.xsd">
<xs:complexType name="TransformType">
<xs:complexContent>
<xs:restriction base="ds:TransformType">
<xs:choice minOccurs="1" maxOccurs="1"> <!--diff-->
<!--<xs:element name="XPath" type="xs:string"/>-->
<!--<xs:any namespace="##other" processContents="lax"/>-->
<xs:element name="InclusiveNamespaces" type="ec:InclusiveNamespaces"/> <!--diff-->
</xs:choice>
<xs:attribute name="Algorithm" type="xs:anyURI" use="required"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:redefine>
Ошибка:
rcase-RecurseLax.2: There is not a complete functional mapping between the particles.
(1) показывает, что ограничение choice
в порядке
(2) показывает, что использование только any
тип в порядке
(3) показывает, что при объединении any
и choice
должно быть особое поведение, возможно, в отношении пространств имен?
(4) похоже, что данный элемент не является подмножеством типа any
(что неверно)
Поведение (3) также подразумевается исходной схемой, которая имеет эти комментарии для choice
и sequence
:
<choice minOccurs="0" maxOccurs="unbounded">
<any namespace="##other" processContents="lax"/>
<!-- (1,1) elements from (0,unbounded) namespaces -->
</choice>
<sequence>
<any namespace="##other" minOccurs="0" maxOccurs="unbounded"/>
<!-- (0,unbounded) elements from (1,1) external namespace -->
</sequence>
Итак, что это означает и как должно быть ограничение определено?
РЕДАКТИРОВАТЬ
(2) / (3) Ограничение также в порядке, если установить choice
на minOccurs=0 maxOccurs=1
или minOccurs=1 maxOccurs=unbounded
. Но почему «ровно один» не является допустимым ограничением «любого числа»? Тем не менее, если не использовать тип any
, мы имеем (1) .