我想要一个xsd来保存包含文件元素的xml,但在xsd中有错误
警告1通配符'## any'允许元素'http://www.irica.com/ECEP/1383-12/SendSchema:Attachments',并导致内容模型变得模糊不清。必须形成内容模型,使得在元素信息项序列的验证期间,可以在不检查元素信息项序列的内容或属性的情况下,直接地,间接地或隐含地包含在其中依次用于尝试验证序列中的每个项目的粒子。该项目,并且没有关于序列其余部分中的项目的任何信息。 ECEP_Letter.xsd 204 18
请帮帮我
这是我的xsd:
<xs:schema targetNamespace="http://www.irica.com/ECEP/1383-12/SendSchema" xmlns:irecetns="http://www.irica.com/ECEP/1383-12/SendSchema" xmlns="http://www.irica.com/ECEP/1383-12/SendSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="qualified" version="1.01">
<xs:element name="Letter">
<xs:complexType>
<xs:sequence>
<xs:element name="Protocol" nillable="false" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:attribute name="Name" type="xs:string" use="required" form="unqualified"/>
<xs:attribute name="Version" type="xs:string" use="required" form="unqualified"/>
<xs:anyAttribute namespace="##any" processContents="skip"/>
</xs:complexType>
</xs:element>
<xs:element name="Software" nillable="false" maxOccurs="1" minOccurs="1">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="SoftwareDeveloper" type="xs:string" use="required" form="unqualified"/>
<xs:attribute name="Version" type="xs:string" use="optional" form="unqualified"/>
<xs:attribute name="GUID" type="xs:string" use="required" form="unqualified"/>
<xs:anyAttribute namespace="##any" processContents="skip"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="Sender" nillable="false" maxOccurs="1" minOccurs="1">
<xs:complexType>
<xs:attribute name="Organization" type="xs:string" use="required" form="unqualified"/>
<xs:attribute name="Department" type="xs:string" use="optional" form="unqualified"/>
<xs:attribute name="Position" type="xs:string" use="optional" form="unqualified"/>
<xs:attribute name="Name" type="xs:string" use="optional" form="unqualified"/>
<xs:attribute name="Code" type="xs:string" use="required" form="unqualified"/>
<xs:anyAttribute namespace="##any" processContents="skip"/>
</xs:complexType>
</xs:element>
<xs:element name="Receiver" nillable="false" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:attribute name="Organization" type="xs:string" use="required" form="unqualified"/>
<xs:attribute name="Department" type="xs:string" use="optional" form="unqualified"/>
<xs:attribute name="Position" type="xs:string" use="optional" form="unqualified"/>
<xs:attribute name="Name" type="xs:string" use="optional" form="unqualified"/>
<xs:attribute name="Code" type="xs:string" use="required" form="unqualified"/>
<xs:attribute name="ReceiveType" type="irecetns:ReceiveType" use="required" form="unqualified"/>
<xs:anyAttribute namespace="##any" processContents="skip"/>
</xs:complexType>
</xs:element>
<xs:element name="OtherReceivers" nillable="false" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="OtherReceiver" nillable="false" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="Organization" type="xs:string" use="required" form="unqualified"/>
<xs:attribute name="Department" type="xs:string" use="optional" form="unqualified"/>
<xs:attribute name="Position" type="xs:string" use="optional" form="unqualified"/>
<xs:attribute name="Name" type="xs:string" use="optional" form="unqualified"/>
<xs:attribute name="Code" type="xs:string" use="required" form="unqualified"/>
<xs:attribute name="ReceiveType" type="irecetns:ReceiveType" use="required" form="unqualified"/>
<xs:anyAttribute namespace="##any" processContents="skip"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="LetterNo" nillable="false" maxOccurs="1" minOccurs="1">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:anyAttribute namespace="##any" processContents="skip"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="LetterDateTime" nillable="false" maxOccurs="1" minOccurs="1">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:dateTime">
<xs:attribute name="ShowAs" type="irecetns:DateType" use="required" form="unqualified"/>
<xs:anyAttribute namespace="##any" processContents="skip"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="RelatedLetters" minOccurs="0" maxOccurs="1" nillable="false">
<xs:complexType>
<xs:sequence>
<xs:element name="RelatedLetter" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:all>
<xs:element name="RelationType" nillable="false" maxOccurs="1" minOccurs="1">
<xs:complexType>
<xs:attribute name="Name" type="xs:string" use="required" form="unqualified"/>
<xs:attribute name="Code" type="xs:string" use="required" form="unqualified"/>
<xs:anyAttribute namespace="##any" processContents="skip"/>
</xs:complexType>
</xs:element>
<xs:element name="RelatedLetterNo" nillable="false" maxOccurs="1" minOccurs="1">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:anyAttribute namespace="##any" processContents="skip"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="RelatedLetterDateTime" nillable="false" maxOccurs="1" minOccurs="1">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:dateTime">
<xs:attribute name="ShowAs" type="irecetns:DateType" use="required" form="unqualified"/>
<xs:anyAttribute namespace="##any" processContents="skip"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="RelatedLetterSender" nillable="false" maxOccurs="1" minOccurs="1">
<xs:complexType>
<xs:attribute name="Organization" type="xs:string" use="required" form="unqualified"/>
<xs:attribute name="Department" type="xs:string" use="optional" form="unqualified"/>
<xs:attribute name="Position" type="xs:string" use="optional" form="unqualified"/>
<xs:attribute name="Name" type="xs:string" use="optional" form="unqualified"/>
<xs:attribute name="Code" type="xs:string" use="required" form="unqualified"/>
<xs:anyAttribute namespace="##any" processContents="skip"/>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Subject" minOccurs="0" maxOccurs="1" nillable="true">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:anyAttribute namespace="##any" processContents="skip"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="Priority" nillable="false" maxOccurs="1" minOccurs="1">
<xs:complexType>
<xs:attribute name="Name" type="xs:string" use="required" form="unqualified"/>
<xs:attribute name="Code" type="xs:string" use="required" form="unqualified"/>
<xs:anyAttribute namespace="##any" processContents="skip"/>
</xs:complexType>
</xs:element>
<xs:element name="Classification" nillable="false" maxOccurs="1" minOccurs="1">
<xs:complexType>
<xs:attribute name="Name" type="xs:string" use="required" form="unqualified"/>
<xs:attribute name="Code" type="xs:string" use="required" form="unqualified"/>
<xs:anyAttribute namespace="##any" processContents="skip"/>
</xs:complexType>
</xs:element>
<xs:element name="Keywords" nillable="false" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="Keyword" nillable="false" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:anyAttribute namespace="##any" processContents="skip"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Origins" nillable="false" minOccurs="1" maxOccurs="1">
<xs:complexType>
<xs:sequence>
<xs:element name="Origin" nillable="false" maxOccurs="unbounded" minOccurs="1">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:base64Binary">
<xs:attribute name="ContentType" type="irecetns:FileType" use="required" form="unqualified"/>
<xs:attribute name="Extension" type="xs:string" use="optional" form="unqualified"/>
<xs:attribute name="Description" type="xs:string" use="optional" form="unqualified"/>
<xs:anyAttribute namespace="##any" processContents="skip"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Attachments" minOccurs="0" maxOccurs="1" nillable="false">
<xs:complexType>
<xs:sequence>
<xs:element name="Attachment" nillable="true" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:base64Binary">
<xs:attribute name="ContentType" type="xs:string" use="required" form="unqualified"/>
<xs:attribute name="Extension" type="xs:string" use="optional" form="unqualified"/>
<xs:attribute name="Description" type="xs:string" use="optional" form="unqualified"/>
<xs:anyAttribute namespace="##any" processContents="skip"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:any minOccurs="0" maxOccurs="unbounded" processContents="lax" namespace="##any"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:simpleType name="FileType">
<xs:restriction base="xs:string">
<xs:enumeration value="image/jpeg"/>
<xs:enumeration value="image/tiff"/>
<xs:enumeration value="image/gif"/>
<xs:enumeration value="image/png"/>
<xs:enumeration value="application/msword"/>
<xs:enumeration value="application/pdf"/>
<xs:enumeration value="text/plain"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="DateType">
<xs:restriction base="xs:string">
<xs:enumeration value="gregorian"/>
<xs:enumeration value="Ahmadi"/>
<xs:enumeration value="hijri"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ReceiveType">
<xs:restriction base="xs:string">
<xs:enumeration value="Origin"/>
<xs:enumeration value="Copy"/>
<xs:enumeration value="Refer"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
什么是正确的XSD文件?
答案 0 :(得分:3)
您有一个可选的附件元素,后跟一个xs:any,它还允许附件元素。因此,如果解析器遇到Attachments元素,它就不知道是根据您的Attachments声明还是针对通配符来验证它。
此规则在XSD 1.1中消失:如果输入可以匹配特定元素声明或通配符,它会自动选择特定元素声明。
在XSD 1.0中,通常的解决方案是设置通配符,以便它只允许不同命名空间中的名称。