restrict special characters in my XSD validation , i am able to handle , some characters with this pat开发者_JAVA技巧tern "([a-zA-Z0-9_.' !@#$%^*()_+={}|/:;,>?/`~ ])+"
but not able to handle below :
" & ' < \ ® ™
any ideas ?
also not able to handle them with [^] pattern
You want define a type that extends string and add a restriction with a pattern Something like
<xs:element name="your_element">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[a-zA-Z0-9_.' !@#$%^*()_+={}|/:;,>?/`~ ]"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
Or you can add the escape character \ (backslash) before any special character you want to add to the pattern. For example:
<xs:pattern value="[a-zA-Z 0-9_.,()/=!\[\]"#%&*;<>'+:?-]"/>
where you see the square brackets [ and ] included in the pattern.
I think you need to use character entities. &
for the ampersand, for example, and <
for the less. XML Schema is XML, and you have to live with XML rules. Expanding your question to actually show us the schema context would help.
精彩评论