xml - Order of element in an inherited complex type -
i have xsd schema utilize validate xml files.
in xsd schema, created complex type containing attributes grouping , choice, containg "_output", recurring element.
my complex type :
<xs:complextype name="base_action"> <xs:choice minoccurs="0" maxoccurs="unbounded"> <xs:element name="_output" minoccurs="0" maxoccurs="unbounded"/> </xs:choice> <xs:attributegroup ref="action"/> </xs:complextype>
i have other elements (with kid elements of own) inheriting complex type.
an exemple of such inheriting element :
<xs:element name="ex_elem" minoccurs="0"> <xs:complextype> <xs:complexcontent> <xs:extension base="cockpit_base_action"> <xs:choice minoccurs="0" maxoccurs="unbounded"> <xs:element name="to" minoccurs="0"/> <xs:element name="from" minoccurs="0"/> </xs:choice> </xs:extension> </xs:complexcontent> </xs:complextype> </xs:element>
now, in xml, work :
<ex_elem> <_output/> <from>0</from> <to>1</to> </ex_elem>
but not :
<ex_elem> <from>0</from> <_output/> <to>1</to> </ex_elem>
or :
<ex_elem> <from>0</from> <to>1</to> <_output/> </ex_elem>
from understand, selection complex type can't mix selection of inheriting element. problem me, because there sitations want set _output somewhere else @ top.
i want able utilize element without having bother sequence. there way so?
in xsd 1.0, extension of base of operations type creates sequence first fellow member old content model , sec fellow member top of extension's add-on content model. effective content model of extension of cockpit_base_action is
<xs:sequence> <xs:choice minoccurs="0" maxoccurs="unbounded"> <xs:element name="_output" minoccurs="0" maxoccurs="unbounded"/> </xs:choice> <xs:choice minoccurs="0" maxoccurs="unbounded"> <xs:element name="to" minoccurs="0"/> <xs:element name="from" minoccurs="0"/> </xs:choice> </xs:sequence>
in xsd 1.1, can alter base of operations type utilize xs:all, , utilize xs:all in extension, effect want.
or (in either 1.0 or 1.1), can alter extension take language want. should have effect seem desire:
<xs:extension base="cockpit_base_action"> <xs:sequence minoccurs="0"> <xs:choice> <xs:element name="to"> <xs:element name="from"/> </xs:choice> <xs:choice minoccurs="0" maxoccurs="unbounded"> <xs:element name="_output"/> <xs:element name="to"> <xs:element name="from"/> </xs:choice> </xs:sequence> </xs:extension>
i've omitted occurrence indicators on children of selection elements, since have no effect on language accepted: optional when containing selection (or sequence containing it) optional; can repeat without bound, when containing selection can so.
xml xsd complextype
No comments:
Post a Comment