paterns for phones' numbers

R

Ruthless

Hello.

I've got a question how to make a patern in XML Schema for e.g. phones'
numbers like this: 111-222-333 etc.

thanx in advance
greetings R
 
J

Janwillem Borleffs

Ruthless said:
Hello.

I've got a question how to make a patern in XML Schema for e.g. phones'
numbers like this: 111-222-333 etc.

<!-- matches 111-222-333 formatted phone numbers -->
<xs:simpleType name="phoneType">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{3}(-[0-9]{3}){2}" />
</xs:restriction>
</xs:simpleType>

You will have to re-specify the pattern with other formats.


HTH,
JW
 
R

Ruthless

thnx very much

greetings R

U¿ytkownik "Janwillem Borleffs said:
Ruthless said:
Hello.

I've got a question how to make a patern in XML Schema for e.g. phones'
numbers like this: 111-222-333 etc.

<!-- matches 111-222-333 formatted phone numbers -->
<xs:simpleType name="phoneType">
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]{3}(-[0-9]{3}){2}" />
</xs:restriction>
</xs:simpleType>

You will have to re-specify the pattern with other formats.


HTH,
JW
 
A

Andy Dingley

I've got a question how to make a patern in XML Schema for e.g. phones'
numbers like this: 111-222-333 etc.

Don't ! Phone numbers don't need structure - you just dial them and
they work. Trying to impose a structure like this causes no end of
problems (I used to write commercial desktop apps - I learned this
_years_ ago).

There's also the problem that different countries use different
format, and that one country may often change an existing format. If
you really must have formatted numbers, just do it at the display
stage.
 
G

Gargamil

Take for example Australia where landline phones are now 01 2345 6789 and
mobiles phones are 0412 345 678. The list could be endless. Content
yourself with formatting the field as text and checking if there are enough
characters to create a meaningful phone number.

Gargamil
 
E

Ed Beroset

Gargamil said:
Take for example Australia where landline phones are now 01 2345 6789 and
mobiles phones are 0412 345 678. The list could be endless. Content
yourself with formatting the field as text and checking if there are enough
characters to create a meaningful phone number.

Recently, I purchased international plane tickets via the web. Several
minutes later, I got an email from the travel agent complaining of an
invalid number. Their software evidently was looking for a number with
the typical US format of 987-654-3210, but I had put a "1" in front of
my US number out of habit because that's the country code. The effect
is that the software incorrectly rejected my valid number. That's bad
design.

Ed
 
P

Peter Flynn

Andy said:
Don't ! Phone numbers don't need structure - you just dial them and
they work. Trying to impose a structure like this causes no end of
problems (I used to write commercial desktop apps - I learned this
_years_ ago).

Right. But *do* allow the user to type non-digits:

a. optional + at the start to symbolize your international access code
b. spaces between groups of digits
c. hyphens (dashes) between groups of digits
d. slashes...
e. parentheses...
f. periods...
g. etc

I believe the maximum length of a phone number is currently 18 digits
(max 4 for country code, max 6 for area code, max 8 for number) plus
up to 6 more for direct in-dial extensions, and whatever you consider
reasonable for punctuation (say 8), giving a total for your overall
length of 32.

Formatting is tempting, because at least 15% of respondents will get
their own phone number wrong, IMHE. But it's too complex to model in
a Schema: the ITU will supply you with the standard formats for each
country if you really want them, but you'll spend the next year making
them work as patterns.

///Peter
 
J

Julian Reschke

Peter said:
...

a. optional + at the start to symbolize your international access code
...

So any number that doesn't start with a "+" is in which country?

Julian
 
R

Richard Tobin

(Oops, I think I just contrived to send a reply to this to xml-dev by mistake.)

Don't ! Phone numbers don't need structure - you just dial them and
they work. Trying to impose a structure like this causes no end of
problems (I used to write commercial desktop apps - I learned this
_years_ ago).
[/QUOTE]

Really? It used to be the case that in Britain that dialling the full
"long-distance" version of a local number *didn't* work; you had to
extract the local part. I think it now generally works, but I wouldn't
bet on that being the case everywhere.

-- Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top