aspose file tools*
The moose likes XML and Related Technologies and the fly likes Regular Expression in Schema Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Regular Expression in Schema" Watch "Regular Expression in Schema" New topic
Author

Regular Expression in Schema

Sana Ali
Greenhorn

Joined: Oct 08, 2004
Posts: 14
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

Joined: Oct 08, 2004
Posts: 14
sorry for the indenting:s...it just changed here:s
 
wood burning stoves
 
subject: Regular Expression in Schema