Last active
December 11, 2015 18:38
-
-
Save kornicameister/4643021 to your computer and use it in GitHub Desktop.
Text only (restricion included) with attributes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
################################################################# | |
--> | |
<xs:annotation> | |
<xs:documentation> | |
This is the way to declare an element that may | |
contain text based child only along with attached | |
numerous of attributes. | |
Tke key is to define simpleType that defines | |
how the content of our element may look like | |
And when defining text only element provide mentioned | |
simpleType as the base for <xs:extension/> element | |
</xs:documentation> | |
</xs:annotation> | |
<xs:simpleType name="phoneNumberFormat"> | |
<xs:restriction base="xs:string"> | |
<xs:pattern value="\+\([0-9]{2}\)(-?[0-9]{2,3}){3}"/> | |
</xs:restriction> | |
</xs:simpleType> | |
<xs:element name="phone"> | |
<xs:complexType> | |
<xs:simpleContent> | |
<xs:extension base="f:phoneNumberFormat"> | |
<xs:attribute name="type" use="required"> | |
<xs:simpleType> | |
<xs:restriction base="xs:token"> | |
<xs:enumeration value="home"/> | |
<xs:enumeration value="office"/> | |
</xs:restriction> | |
</xs:simpleType> | |
</xs:attribute> | |
</xs:extension> | |
</xs:simpleContent> | |
</xs:complexType> | |
</xs:element> | |
<!-- | |
################################################################# | |
--> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
works perfectly ;-)