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.

+3


source to share


2 answers


You can try this:



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

      

+5


source


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



+2


source







All Articles