What is the meaning of xs: mixed without elements?

I received the next XSD bit from the client. This is part of an outdated scheme that spans dozens of files.

<xs:element name="stateProvinceName"> <xs:complexType mixed="true"> <xs:attributeGroup ref="xml:attlist.global-attributes"/> </xs:complexType> </xs:element> 

I'm trying to figure out what they really want. There are no sub-elements, so what does this "xs: mixed" mean? should it be simpleContent or without content?

I told them that they should use a more standard design like

 <xs:element name="stateProvinceName"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attributeGroup ref="xml:attlist.global-attributes"/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> 

But they are not sure that it means the same thing. Both schemes accept

 <stateProvinceName ID="345643">California</stateProvinceName> 

and

 <stateProvinceName ID="345643"/> 
+2
source share
3 answers

Two types may be equivalent on the surface, but their extensibility is different. Using a simple content type of the xs: string string allows you to refine the type by restricting the string to, for example, a regular expression, and using a mixed complex content type without elements allows you to refine by adding elements to the model.

+5
source

Using mixed with an empty content model is completely standard. If you do not like their content model, you will need another argument.

In the general case, mixed="true" means that the content of characters is allowed among children in a given complex type; in this case, since there are no children in the content model, the only legal content of the parent element will be character data, comments, and processing instructions. The result is that the element declaration accepts the same set of elements as if the element was typed using a complex type with simple content declared as an xs:string extension.

The choice between mixed content and line is a design decision. In general, mixed content is better for natural prose, even if the original design of the element does not foresee the need for sub-elements. In the general case, xs:string easier to use if as a basis for limiting the set of expected values. (If you want to restrict stateProvinceName to only accept codes defined by specific mail services, xs:string is a better basis for your work than mixed content.)

+2
source

This means that you have an element named stateProvinceName that has one or more attributes (as defined by xml:attlist.global-attributes ) whose contents are a string. As in any case, it is no different from the structure you recommended.

Their difference in potential , however, is their extensibility, as @Michael Kay noted .

0
source

Source: https://habr.com/ru/post/888727/


All Articles