?/`~ ])+\"" />
开发者

Special Characters Restriction Rule in XSD

开发者 https://www.devze.com 2022-12-30 04:37 出处:网络
restrict special characters in my XSD validation , i am able to handle , some characters with this pat开发者_JAVA技巧tern\"([a-zA-Z0-9_.\' !@#$%^*()_+={}|/:;,>?/`~ ])+\"

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_.,()/=!\[\]&quot;#%&amp;*;&lt;&gt;&apos;+:?-]"/>

where you see the square brackets [ and ] included in the pattern.


I think you need to use character entities. &amp; for the ampersand, for example, and &lt; 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消