Is there a way to restrict ASCII string to XSD only?

Although the XML file described by the XSD schema can contain any Unicode characters in general, there are some fields in which only ASCII is allowed. (Since these strings will be passed to another system that only accepts ASCII.)

Is there a way to specify this in XSD?

A regex with all possible ASCII characters would be possible I suppose, but I believe there must be a better way.


source to share

2 answers

You can try this:

<xs:simpleType name="basicLatin">
    <xs:restriction base="xs:string">
        <xs:pattern value="\p{IsBasicLatin}*"/>




Unfortunately there is no template-free usage limit for your requirement.



All Articles