Jump to content

Disregarding control characters in XSD - MaxLength.


Guest PazitGazit

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.

Link to comment
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.

Link to comment
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

Link to comment
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?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...