|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
XSD validation |
« View previous topic :: View next topic » |
Author |
Message
|
samchenchu |
Posted: Thu Aug 29, 2013 10:51 pm Post subject: XSD validation |
|
|
Novice
Joined: 13 Aug 2013 Posts: 22
|
Hi Friends,
In my XSD one attribute has the pattern value as below.
<xs:attribute name="ItemNumber" use="required">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:pattern value="^.{1,9}$" />
<xs:minInclusive value="0" />
<xs:maxInclusive value="999999999" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
In my code I am sending "6715126" value to the ItemNumber.This item number is valid as per pattern.
while validating with XSD its giving below exception "cvc-pattern-valid: The value "6715126" is not valid with respect to the pattern facet for type "#Anonymous"."
javascript:emoticon(' ') |
|
Back to top |
|
 |
darioo |
Posted: Fri Aug 30, 2013 12:59 am Post subject: |
|
|
Novice
Joined: 19 Mar 2009 Posts: 15
|
This is the source of your problems:
Code: |
<xs:pattern value="^.{1,9}$" /> |
Since you've already specified that "xs:integer" is the desired type, your regex is redundant. Oh, and it's wrong.
Not every language defines and implements regular expressions the same way. For example, in XSD, "^" doesn't mean "start of line", it just negates whatever comes after it. Also, "$" isn't used.
Using
Code: |
<xs:pattern value=".{1,9}" /> |
would be fine, but once again, it's redundant (and slower) since you've already specified that it's an integer and that the minimum inclusive value is 0, while the maximum inclusive value is 999999999.
The solution: get rid of
Code: |
<xs:pattern value="^.{1,9}$" /> |
and you should be fine. |
|
Back to top |
|
 |
samchenchu |
Posted: Fri Aug 30, 2013 2:18 am Post subject: |
|
|
Novice
Joined: 13 Aug 2013 Posts: 22
|
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|