XML Schema restriction
I need a schema restriction satisfying the following conditions:
List of locations, prefixed by + or – and separated b开发者_如何学Goy a space character
Ex: +Z*1 +FR –PAR
Possible location types:
- Area: Z*1,Z*2, Z*3
- ATPCo Zone: 3 numerics
- Country: 2 alphanums
- City: 3 alphanums
- State/province: 2 alphas/2 alphas
- Region: 5 alphas or 4 alpha + 1 num from 1 to 5
- IATA subarea: 2 numerics
The xsd list type allows for spaces seperated items. The following will allow all words:
<simpleType name='locations'>
<list itemType='string'/>
</simpleType>
You could use a regular expression to restrict all strings to starting with + or -
<simpleType name='location'>
<restriction base='string'>
<pattern value='[\+\-]\w'/>
</restriction>
</simpleType>
<simpleType name='locations'>
<list itemType='location'/>
</simpleType>
精彩评论