XSD alphanumerical, reg_exp

R

Ruthless

Hello.

As a greenhorn i've got some new questions...

Is there any type in XSD for alphanumerical strings?
if not:
What is XSD pattern for alphanumerical strings?
E.g. password: alphanumerical and lenght=6(at least)

And second thing(sorry ;D)

how can i write pattern for e-mail addres. pseudocode like this:
[alpha_num]'@'[alpha_num]'.com.pl'

thanks in advance
and once again sorry

greetings R
 
M

Martin Honnen

Ruthless wrote:

Is there any type in XSD for alphanumerical strings?
if not:
What is XSD pattern for alphanumerical strings?
E.g. password: alphanumerical and lenght=6(at least)

Well, if alphanumerical means A-Z0-9 then the following is a way to
express that

<xs:element name="password" type="passwordType" />

<xs:simpleType name="passwordType">
<xs:restriction base="xs:string">
<xs:minLength value="6" />
<xs:pattern value="[a-zA-Z0-9]{6,}" />
</xs:restriction>
</xs:simpleType>


However many languages have more letters than A-Z so you might need to
extend the pattern, for instance with the letter ż

<xs:element name="password" type="passwordType" />

<xs:simpleType name="passwordType">
<xs:restriction base="xs:string">
<xs:minLength value="6" />
<xs:pattern value="[a-zA-Z0-9ż]{6,}" />
</xs:restriction>
</xs:simpleType>

Make sure you use an editor that is Unicode capable when you author the
XML schema file.

how can i write pattern for e-mail addres. pseudocode like this:
[alpha_num]'@'[alpha_num]'.com.pl'

While regular expressions are powerful I think they are not powerful
enough to write one that really matches all the possibilities the RFC
for email adresses allows.
 
R

Ruthless

how can i write pattern for e-mail addres. pseudocode like this:
[alpha_num]'@'[alpha_num]'.com.pl'

While regular expressions are powerful I think they are not powerful
enough to write one that really matches all the possibilities the RFC
for email adresses allows.

OK but for the example pattern with '@' and ending: 'com.pl'

how it would be? I don't know regular expresions at all and i'm beginner in
XML

Maybe sth like this:
<xs:simpleType name="mail-type">
<xs:restriction base="xs:string">
<xs:pattern value="[a-zA-Z0-9]{1,}[@][a-zA-Z0-9]{1,}['com.pl']" />
</xs:restriction>
</xs:simpleType>
?

thanks in advance
greetings R
 
P

Patrick TJ McPhee

% > > [alpha_num]'@'[alpha_num]'.com.pl'
% >
% > While regular expressions are powerful I think they are not powerful
% > enough to write one that really matches all the possibilities the RFC
% > for email adresses allows.
%
% OK but for the example pattern with '@' and ending: 'com.pl'
%
% how it would be? I don't know regular expresions at all and i'm beginner in
% XML
%
% Maybe sth like this:
% <xs:simpleType name="mail-type">
% <xs:restriction base="xs:string">
% <xs:pattern value="[a-zA-Z0-9]{1,}[@][a-zA-Z0-9]{1,}['com.pl']" />
% </xs:restriction>
% </xs:simpleType>

This is no good. It doesn't allow, for instance, dots. It doesn't
append com.pl correctly. There are probably other problems. You could have

[a-zA-Z0-9._]+@[a-zA-Z0-9._]+com.pl

but it might be better to have

[^@\p{Z}]+@[^@\p{Z}]+com.pl

[^@\p{Z}] is the set of all characters except @ and space-type characters.
 
M

Martin Honnen

Patrick said:
% > > [alpha_num]'@'[alpha_num]'.com.pl'
% >
% > While regular expressions are powerful I think they are not powerful
% > enough to write one that really matches all the possibilities the RFC
% > for email adresses allows.
%
% OK but for the example pattern with '@' and ending: 'com.pl'
%


This is no good. It doesn't allow, for instance, dots. It doesn't
append com.pl correctly. There are probably other problems. You could have

[a-zA-Z0-9._]+@[a-zA-Z0-9._]+com.pl

It depends on what the original poster wants but I suspect the dot
between com.pl needs to be escaped
com\.pl
 

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,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top