Given two simple data types, say, restricted strings type1
, type2
, is there a possibility to define type3
describing all strings formed by concatenating one type1
string plus one type2
string?
For example, consider
<xsd:simpleType name="type1">
<xsd:restriction base="xsd:string">
<xsd:pattern value="[A-Z]"></xsd:pattern>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="type2">
<xsd:restriction base="xsd:string">
<xsd:pattern value="[0-9]"></xsd:pattern>
</xsd:restriction>
</xsd:simpleType>
Then I would like to define type3
such that
A0 -> valid
B1 -> valid
AA -> invalid
etc...
Note that this example is just for illustration, I know how to combine the regex patterns, but my question is how to combine the types via XSD.
XML Schema only allows construction of new simple types by:
type1
could be restricted to vowels)type1
would haveA B D D E
in its lexical space)A
,0
,C
,2
, etc)It is always risky to give the answer "not possible", but I am afraid that the only way to build a "concatenated type" is thus to construct a new simple type by restricting
xs:string
with the concatenated regular expressions.I think that the reason why XML Schema does not provide a general mechanism for concatenating simple types is that, while concatenation makes sense on the lexical space of two simple data types, it is not necessarily meaningful nor straightforward to define on their value spaces, besides the specific use case at hand involving strings and the pattern facet.