ASCII characters

This should cover W3C XML Schema, Relax NG and DTD related problems.
Guest

ASCII characters

Post by Guest » Sat Jan 15, 2005 3:03 am

Hi,
I have a string(6-240 characters) for which I need to check that each of the characters is a valid ASCII character. Any ideas?

Thank You,

Ilan

george
Site Admin
Posts: 2101
Joined: Thu Jan 09, 2003 2:58 pm

Post by george » Mon Jan 17, 2005 8:22 pm

Hi,

You can have something like:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="test" type="test"/>
<xs:simpleType name="test">
<xs:restriction base="xs:string">
<xs:pattern value="(\p{IsBasicLatin})*"/>
<xs:maxLength value="240"/>
<xs:minLength value="6"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
This will accept between 6 and 240 ASCII characters as the content of the test element.

Hope that helps,
George

Post Reply