0

I have the following xsd file which is throwing "invalid schema" error. I have done many complex schemas before but cannot seem to figure out what is wrong with this one, which should be very straight forward. I know I need something after

<xsd:element name="ebay">

but what?

XML:
<ebay><userID></userID></ebay>


Schema:
    <?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:element name="ebay">

<xsd:element name="userID">
   <xsd:simpleType>
     <xsd:restriction base="xsd:string">
       <xsd:minLength value="1"/>
       <xsd:maxLength value="255"/>
       <xsd:whiteSpace value="collapse"/> 
     </xsd:restriction>
   </xsd:simpleType>
 </xsd:element>

</xsd:element>
</xsd:schema>
4

2 回答 2

1

您需要将命名空间 xs: 定义为“http://www.w3.org/2001/XMLSchema”,您使用了两个命名空间但只定义了 xsd。你真的应该只使用其中一个。另外我不相信您可以在字符串上使用 minInclusive 值或 maxInclusiveValue 。

于 2012-07-04T09:07:33.850 回答
0

试试这个架构:

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:element name="ebay">
    <xs:complexType>
      <xs:sequence>
        <xsd:element name="userID">
          <xsd:simpleType>
            <xsd:restriction base="xsd:string">
              <xsd:minLength value="1"/>
              <xsd:maxLength value="255"/>
              <xsd:whiteSpace value="collapse"/> 
            </xsd:restriction>
          </xsd:simpleType>
        </xsd:element>
      </xs:sequence>
    </xs:complexType>
  </xsd:element>
</xsd:schema>
于 2012-07-04T10:40:47.090 回答