开发者

Having two different types for creating an XML schema

开发者 https://www.devze.com 2023-03-15 23:54 出处:网络
Hi i am working on making a basic shipping xml schema and i was wondering if there was a way to have the schema restrictions to work for both canadian and american postal codes:

Hi i am working on making a basic shipping xml schema and i was wondering if there was a way to have the schema restrictions to work for both canadian and american postal codes:

 <xs:simpleType name="postalCode">
<xs:restriction base="xs:string" >
  <xs:pattern value="\d{3}-\d{3}"/>
</xs:restriction>

is there a way to have an "开发者_如何学Cor" in there so i could have the american postal code of just numbers work aswell?

Any comments or suggestions are appreciated. Thanks


Try with | character to provide second (OR) option in your pattern e.g. (additional parentheses aren't necessary in here):

<xs:simpleType>
    <xs:restriction base="xs:string" >
        <xs:pattern value="\d{3}-\d{3}|\d{5}"/>
    </xs:restriction>
</xs:simpleType>
0

精彩评论

暂无评论...
验证码 换一张
取 消