"Matthet" <ma*****@polbox.com> wrote in message
news:bk**********@foka1.acn.pl...
I've got simpleType restricted by pattern
one element uses this simpleType
and I would like
another element to use this SimpleType
but with one extra pattern.
How to do it?
There are two ways to do this. Derive a second simple type as a restriction
of the first and put the pattern there, then use the second type for the
other element, as in e2 below. Or define the second type anonymously in the
definition of the element, as in e3 below.
<xs:schema elementFormDefault="qualified" xml:lang="EN"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:simpleType name="t1">
<xs:restriction base="xs:string">
<xs:pattern value=".+"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="t2">
<xs:restriction base="t1">
<xs:pattern value="[0-9]*"/>
</xs:restriction>
</xs:simpleType>
<xs:element name="e1" type="t1"/>
<xs:element name="e2" type="t2"/>
<xs:element name="e3">
<xs:simpleType>
<xs:restriction base="t1">
<xs:pattern value="[0-9]*"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:schema>
In the example, type t1 disallows empty string contents, while type t2
additionally restricts contents to the digits 0-9.
Bob Foster
http://www.xmlbuddy.com/