XSD - what's a difference ?

Discussion in 'XML' started by Matthet, Sep 22, 2003.

  1. Matthet

    Matthet Guest

    Hi,

    Is there any difference if I write sth like this:

    <xsd:simpleType name="Name">
    <xsd:restriction base="xsd:string">
    <xsd:minLength value="1">
    <xsd:maxLength value="10">
    </xsd:restriction>
    </xsd:simpleType>

    and this:

    <xsd:simpleType name="Name">
    <xsd:restriction base="xsd:string">
    <xsd:pattern value=".{1,10}">
    </xsd:restriction>
    </xsd:simpleType>

    Thx for any help
    MAciek
    Matthet, Sep 22, 2003
    #1
    1. Advertising

  2. Matthet

    Martin Boehm Guest

    "Matthet" <> wrote in message
    news:bknd6f$1ad$

    > Is there any difference if I write sth like this:
    >
    > [xsd:string restricted by minLength and maxLength]
    >
    > and this:
    >
    > [xsd:string restricted by regex pattern]


    The effect of both restrictions is that you must have a string with at
    least one and at most 10 characters. The only difference may be in
    execution speed. Determinig the length of a string is faster than
    matching it against a regular expression, be it as simple as it may.

    If all you want to do is restricting string-length, you should stick
    with minLenth and maxLength.

    Martin
    Martin Boehm, Sep 22, 2003
    #2
    1. Advertising

  3. Matthet

    Matthet Guest

    "Martin Boehm" wrote
    >
    > If all you want to do is restricting string-length, you should stick
    > with minLenth and maxLength.
    >


    Thanks
    I thought so but I wasn't sure.
    I needed some expert opinion.

    MAciek
    Matthet, Sep 22, 2003
    #3
  4. "Matthet" <> writes:

    > Is there any difference if I write sth like this:
    >
    > <xsd:simpleType name="Name">
    > <xsd:restriction base="xsd:string">
    > <xsd:minLength value="1">
    > <xsd:maxLength value="10">
    > </xsd:restriction>
    > </xsd:simpleType>
    >
    > and this:
    >
    > <xsd:simpleType name="Name">
    > <xsd:restriction base="xsd:string">
    > <xsd:pattern value=".{1,10}">
    > </xsd:restriction>
    > </xsd:simpleType>


    The first matches any string with at least one and at most
    ten characters. Since '.' is defined as matching any character
    except linefeed or carriage return, the second matches the same
    set of strings, minus those which contain a linefeed or carriage
    return as one of their characters; it is equivalent to
    "[^\n\r]{1,10}".

    I hope this helps.

    -C. M. Sperberg-McQueen
    World Wide Web Consoritium
    C. M. Sperberg-McQueen, Sep 23, 2003
    #4
    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,079
    Markus
    Nov 22, 2005
  2. Rick Razzano

    XSD document for XSD defintion

    Rick Razzano, Sep 26, 2003, in forum: XML
    Replies:
    1
    Views:
    465
    C. M. Sperberg-McQueen
    Sep 26, 2003
  3. Replies:
    1
    Views:
    845
    Martin Honnen
    Jan 14, 2004
  4. Peter Aberline

    xsd:any as a child of xsd:all

    Peter Aberline, Apr 5, 2004, in forum: XML
    Replies:
    0
    Views:
    771
    Peter Aberline
    Apr 5, 2004
  5. Bernd Oninger
    Replies:
    1
    Views:
    514
    Henry S. Thompson
    Jun 30, 2004
Loading...

Share This Page