• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regular Expression in Schema

 
Sana Ali
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My schema can hold phone where phone can be land line phone/mobile. The phone can be from any country.

a few examples i got in the sample xml file were

<phone type="home">+61 2 9345 6789</phone>
<phone type="work">+61 2 9514 1803</phone>
<phone type="fax">+61 2 9514 1807</phone>
<phone type="mobile">+61 4 1234 5678</phone>

<phone type="home">+44 (0) 8701 608123</phone>

the regular expression i think is suitable is:

value="+[\d" "()-]*"

Also,
since i have more than one types, i.e home, work, fax, mobile

in my schema i am using xs:union so the results in xml file match the schema

[q]
<xs:attributeGroup name="phone.attributes">
<xs:attribute name="type">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="home"/>
<xs:enumeration value="work"/>
<xs:enumeration value="fax"/>
<xs:enumeration value="mobile"/>
<xs:enumeration value="other"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:attributeGroup>
<xs:simpleType name="type">
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs attern value="\(\d\)\s*\d\s*\d"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs attern value="\d\s*\d\s*\d"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
[/q]
this seems a bit dodgy, does any 1 here have a clue?

 
Sana Ali
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry for the indenting:s...it just changed here:s
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic