Guest PazitGazit Posted June 19, 2007 Report Share Posted June 19, 2007 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. Quote Link to post Share on other sites
boen_robot 107 Posted June 19, 2007 Report Share Posted June 19, 2007 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. Quote Link to post Share on other sites
eight968 0 Posted June 20, 2007 Report Share Posted June 20, 2007 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 Quote Link to post Share on other sites
boen_robot 107 Posted June 21, 2007 Report Share Posted June 21, 2007 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. - CharlesWouldn'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? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.