Jump to content
Sign in to follow this  
Guest PazitGazit

Disregarding control characters in XSD - MaxLength.

Recommended Posts

Guest PazitGazit

Hi everyone,I'm trying to find a way to limit a string using the MaxLength restriction in an XSD. This string contains a control character in UTF8, the right to left character. I want the count not to include this charachter.If any one has any ideas, please tell me.Thanks alot.

Share this post


Link to post
Share on other sites

You could use a regular expression (xs:pattern) for that. How exactly would such a regular expression be made is another question which I can't figure out though.

Share this post


Link to post
Share on other sites

You could try something like the following. I don't know why it wouldn't work, but perhaps it would fail. <xsd:simpleType name="limitedString"> <xsd:restriction base="xsd:string"> <xsd:minLength value="0"/> <xsd:maxLength value="3"/> </xsd:restriction> </xsd:simpleType><xsd:simpleType name="yourString"> <xsd:restriction base="limitedString"> <xsd:pattern value="\x00[A-Za-z]*"/> </xsd:restriction></xsd:simpleType>Where \x00 is your control character's value. Basically, first you restrict the string to the length you want. Then you restrict the string to being unicode following by digits (or whatever pattern you want).You also have the alternative (ugly) approach of:(\x00[A-Za-z][A-Za-z][A-Za-z] | \x00[A-Za-z][A-Za-z] | \x00[A-Za-z] | \x00)which would match your control character and then a string of length 0, 1, 2, and 3. - Charles

Share this post


Link to post
Share on other sites
You could try something like the following. I don't know why it wouldn't work, but perhaps it would fail. <xsd:simpleType name="limitedString"> <xsd:restriction base="xsd:string"> <xsd:minLength value="0"/> <xsd:maxLength value="3"/> </xsd:restriction> </xsd:simpleType><xsd:simpleType name="yourString"> <xsd:restriction base="limitedString"> <xsd:pattern value="\x00[A-Za-z]*"/> </xsd:restriction></xsd:simpleType>Where \x00 is your control character's value. Basically, first you restrict the string to the length you want. Then you restrict the string to being unicode following by digits (or whatever pattern you want).You also have the alternative (ugly) approach of:(\x00[A-Za-z][A-Za-z][A-Za-z] | \x00[A-Za-z][A-Za-z] | \x00[A-Za-z] | \x00)which would match your control character and then a string of length 0, 1, 2, and 3. - Charles
Wouldn't
\x00[A-Za-z]{1,3}

work just as fine (where of course you'll replace "3" with the desired maxLength)? Also, what I didn't understood from the start is - Should the control character be searched for (and not counter for) in the whole string or it it known to always be in the beginning?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...