I am trying to define an XSD template for the following:
<template_data>
<given_name lang="ENG">Zluty</given_name>
<given_name lang="CES">Žlutý</given_name>
</template_data>
So far, I've come up with
<xs:complexType name="attribute_CES">
<xs:attribute name="lang" type="xs:string" use="required" fixed="CES"/>
</xs:complexType>
<xs:complexType name="attribute_ENG">
<xs:attribute name="lang" type="xs:string" use="required" fixed="ENG"/>
</xs:complexType>
<xs:element name="template_data">
<xs:complexType>
<xs:sequence>
<xs:element name="given_name" type="attribute_CES"/>
<xs:element name="given_name" type="attribute_ENG"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Problem is, this defines an element with one and the same name two times, each time with a different type, to which any XSD validator I've found protests.
As far as I know, you can require an attribute to have a specific value with the fixed
option, and that is included in the definition of a (complex) type. So if you want the attribute with a different value, you would have to define a new type.
What I need is the template_data
to include both given_name
s, exactly once with lang="CES"
, and exactly once with lang="ENG"
. Is there a way to write an xsd validation schema for that, or is that impossible (for example if the xml input doesn't conform to standards)?
restriction
(w3schools.com/schema/schema_facets.asp) and withfixed
in attributes (w3schools.com/schema/schema_simple_attributes.asp), or with types. – Humungus