XSD alphanumerical, reg_exp

Discussion in 'XML' started by Ruthless, Dec 27, 2003.

  1. Ruthless

    Ruthless Guest

    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


    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.554 / Virus Database: 346 - Release Date: 03-12-20
    Ruthless, Dec 27, 2003
    #1
    1. Advertising

  2. 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.
    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Dec 28, 2003
    #2
    1. Advertising

  3. Ruthless

    Ruthless Guest

    > > 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


    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.554 / Virus Database: 346 - Release Date: 03-12-20
    Ruthless, Dec 28, 2003
    #3
  4. In article <bsmr0n$djn$>,
    Ruthless <ruthless@NO_SPAM.poczta.onet.pl> wrote:
    % > > 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>

    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.

    --

    Patrick TJ McPhee
    East York Canada
    Patrick TJ McPhee, Dec 29, 2003
    #4
  5. Ruthless

    Ruthless Guest

    thanx

    greetings R

    U¿ytkownik "Patrick TJ McPhee" <> napisa³ w wiadomo¶ci
    news:bso76g$mol$...
    > In article <bsmr0n$djn$>,
    > Ruthless <ruthless@NO_SPAM.poczta.onet.pl> wrote:
    > % > > how can i write pattern for e-mail addres. pseudocode like this:
    > % > > [alpha_num]'@'[alpha_num]'.com.pl'




    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.554 / Virus Database: 346 - Release Date: 03-12-20
    Ruthless, Dec 29, 2003
    #5
  6. Patrick TJ McPhee wrote:

    > In article <bsmr0n$djn$>,
    > Ruthless <ruthless@NO_SPAM.poczta.onet.pl> wrote:
    > % > > 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'
    > %



    >
    > 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



    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Dec 29, 2003
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Markus
    Replies:
    1
    Views:
    1,097
    Markus
    Nov 22, 2005
  2. Rick Razzano

    XSD document for XSD defintion

    Rick Razzano, Sep 26, 2003, in forum: XML
    Replies:
    1
    Views:
    484
    C. M. Sperberg-McQueen
    Sep 26, 2003
  3. Replies:
    1
    Views:
    854
    Martin Honnen
    Jan 14, 2004
  4. thellper

    Shrink large file according to REG_EXP

    thellper, Jan 16, 2008, in forum: Perl Misc
    Replies:
    12
    Views:
    242
    John Bokma
    Jan 18, 2008
  5. Zvonko Bi¹kup

    reg_exp and croatian special characters

    Zvonko Bi¹kup, Mar 16, 2007, in forum: Javascript
    Replies:
    1
    Views:
    81
    marss
    Mar 16, 2007
Loading...

Share This Page