XSD - what's a difference ?

M

Matthet

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
 
M

Martin Boehm

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
 
M

Matthet

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
 
C

C. M. Sperberg-McQueen

Matthet said:
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
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top