0

Quite new at XSD validations. Is there any way at all to validate string values - to allow all values a user may enter except certain values that contain a keyword.

For example, I have a system that users can submit their names. I want to allow any name that comes through except for strings that contain 'Joh'

i.e. Allow Mary, Eric, Simon, etc and reject John, Johan, Bjohn, Benjoh, etc

So in my understanding (coming from PHP), 'Not Equal To' is '!=' but this wouldn't work here. And wildcards wouldn't work as for any values that contain 'joh' as '%joh%'

<xs:element name="Names">
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:enumeration value!="%joh%"/>
        </xs:restriction>
    </xs:simpleType> 
</xs:element>

Is there anyway around this?

Eli Skywalker
  • 43
  • 1
  • 2
  • 7
  • 1
    Duplicate of [XML schema restriction pattern for not allowing specific string](http://stackoverflow.com/questions/37563199/xml-schema-restriction-pattern-for-not-allowing-specific-string). See C. M. Sperberg-McQueen's excellent and very thorough answer there. – kjhughes Jun 30 '16 at 16:18
  • Thanks, @kjhughes I have tried to work at it. So far this is what I have - however this still doesn't work. Sure I'm missing something here. – Eli Skywalker Jul 05 '16 at 11:52

0 Answers0