在 XSD 中允许除 # 和 $ 之外的所有字符

Allow all characters except # and $ in XSD

我们要求允许除#、$ 和 space 之外的所有字符(包括特殊字符)进入 XSD 元素。

我试过 [^$#\s]* 的正则表达式,但没有用。你能帮忙解决一下吗,我想不通。

我在 XSD 中尝试了你的正则表达式,它按预期工作。

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://Scratch.SO53903548" targetNamespace="http://Scratch.SO53903548" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Root">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="SpecialString2">
          <xs:simpleType>
            <xs:restriction base="xs:string">
              <xs:pattern value="[^$#\s]*" />
            </xs:restriction>
          </xs:simpleType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

将很乐意验证以下内容,但在 $、# 或 space

上失败
<ns0:Root xmlns:ns0="http://Scratch.SO53903548">
 <SpecialString2>thequickbrownfoxjumpedoverthelazydog@THEQUICKBROWNFOXJUMPEDOVERTHELAZYDOG!~`@%^&amp;*()-_+=</SpecialString2>
</ns0:Root>