为什么此断言无效或在错误的位置?

时间:2019-06-14 16:31:00

标签: xsd xsd-validation

我正在帮助xsd的新手。我正在尝试创建一个Assert语句,但到目前为止,我仍然收到错误消息: s4s-elt-invalid-content.1:“#AnonType_CUSTOMERCUSTOMERS”的内容无效。元素“断言”无效,放错位置或发生的次数过多。

为粘贴这么长的xsd文件而道歉,但我想包括所有内容,以便在需要时可以使用整个结构。断言就在尽头。

编辑:仍在寻求帮助。这似乎是一个基本的语法问题,但是我检查了许多示例,看不到哪里出了问题。

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="0.7">
  <xs:simpleType name="nvarlong">
    <xs:restriction base="xs:string">
      <xs:maxLength value="255" />
    </xs:restriction>
  </xs:simpleType>
    <xs:simpleType name="nvar10">
    <xs:restriction base="xs:string">
      <xs:maxLength value="10" />
    </xs:restriction>
  </xs:simpleType>
        <xs:simpleType name="nvar16">
    <xs:restriction base="xs:string">
      <xs:maxLength value="16" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="taxtype">
    <xs:restriction base="xs:string">
      <xs:enumeration value = "ssn"/>
      <xs:enumeration value = "ein"/>
    </xs:restriction>
  </xs:simpleType> 
  <xs:simpleType name="NAICS">
    <xs:restriction base='xs:string'>
      <xs:pattern value='[0-9]{4,6}'/>
      </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="zipcode">
    <xs:restriction base="xs:string">
      <xs:maxLength value="10" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="taxid">
    <xs:restriction base="xs:string">
      <xs:pattern value="[0-9]{3}-[0-9]{2}-[0-9]{4}|[0-9]{2}-[0-9]{7}"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="farmbill">
    <xs:restriction base="xs:string">
      <xs:enumeration value = ""/>
      <xs:enumeration value = "2014"/>
      <xs:enumeration value = "2018"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="switch">
    <xs:restriction base="xs:string">
      <xs:enumeration value = "y"/>
      <xs:enumeration value = "n"/>
    </xs:restriction>
  </xs:simpleType>
    <xs:simpleType name="prohibitedtypes">
    <xs:restriction base="xs:string">
      <xs:enumeration value = "n"/>
      <xs:enumeration value = "p"/>
    </xs:restriction>
  </xs:simpleType>
    <xs:simpleType name="ACHTCAType">
    <xs:restriction base="xs:string">
      <xs:enumeration value = "PCA"/>
      <xs:enumeration value = "FLCA"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:element name="CUSTOMERS">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="CUSTOMER" maxOccurs="unbounded">
          <xs:complexType>
            <xs:all>
              <xs:element name="UniqueCustomerID" type="nvarlong" />
              <xs:element name="EntityLegalName" type="nvarlong" />
              <xs:element name="DBAName" type="nvarlong" />
              <xs:element name="TaxId" type="taxid" />
              <xs:element name="TaxIdType" type="taxtype" />
              <xs:element name="AddressLine1" type="nvarlong" />
              <xs:element minOccurs ="0"  name="AddressLine2" type="nvarlong" />
              <xs:element minOccurs ="0" name="AddressLine3" type="nvarlong" />
              <xs:element minOccurs ="0" name="AddressLine4" type="nvarlong" />
              <xs:element name="City" type="nvarlong" />
              <xs:element name="Zip" type="zipcode" />
              <xs:element name="EffectiveDate" type="xs:date" />
              <xs:element name="IsActive" type="switch" />
              <xs:element name="NAICSCode" type="NAICS" />
              <xs:element name="ProhibitedIndustry" type="prohibitedtypes" />
              <xs:element name="Description" type="nvarlong" />
              <xs:element name="SWBorderOperations" type="switch" />
              <xs:element minOccurs ="0" name="SWBorderOpsDescription" type="nvarlong" />
              <xs:element name="HempIndustryParticipant" type="switch"/>
              <xs:element minOccurs ="0" name="HempIndustryFarmBill" type="farmbill"/>
              <xs:element minOccurs ="0" name="HempIndustryLicenseNumber" type="nvarlong"/>
              <xs:element minOccurs ="0" name="HempIndustryLicenseState" type="nvarlong"/>
              <xs:element minOccurs ="0" name="HempIndustryLicenseExpiration" type="nvarlong"/>
              <xs:element name="KeyIndividualFirstName" type="nvarlong" />
              <xs:element minOccurs ="0" name="KeyIndividualMiddleName" type="nvarlong" />
              <xs:element name="KeyIndividualLastName" type="nvarlong" />
              <xs:element name="KeyIndividualTitle" type="nvarlong" />
              <xs:element name="KeyIndividualDOB" type="xs:date" />
              <xs:element name="KeyIndividualAddressLine1" type="nvarlong" />
              <xs:element minOccurs ="0" name="KeyIndividualAddressLine2" type="nvarlong" />
              <xs:element minOccurs ="0" name="KeyIndividualAddressLine3" type="nvarlong" />
              <xs:element minOccurs ="0" name="KeyIndividualAddressLine4" type="nvarlong" />
              <xs:element name="KeyIndividualCity" type="nvarlong" />
              <xs:element name="KeyIndividualZip" type="zipcode" />
              <xs:element name="KeyIndividualEmployeeAttestingFirstName" type="nvarlong" />
              <xs:element name="KeyIndividualEmployeeAttestingLastName" type="nvarlong" />

              <xs:element name="SERVICES">
                <xs:complexType>
                  <xs:all>
                    <xs:element name="IncomingDomesticACH" type="switch" />
                    <xs:element name="OutgoingDomesticACH" type="switch" />
                    <xs:element name="IncomingDomesticWire" type="switch" />
                    <xs:element name="OutgoingDomesticWire" type="switch" />
                    <xs:element name="RemoteCheckCapture" type="switch" />
                    <xs:element name="MobileRemoteCheckCapture" type="switch" />
                  </xs:all>
                </xs:complexType>
              </xs:element>
              <xs:element name="EmployeeAttestingOwnershipFirstName" type="nvarlong" />
              <xs:element name="EmployeeAttestingOwnershipLastName" type="nvarlong" />
              <xs:element name="OWNERSHIPDETAILS">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element maxOccurs="4" name="OWNER">
                      <xs:complexType>
                        <xs:all>
                          <xs:element name="OwnerLegalName" type="nvarlong" />
                          <xs:element name="PercentOwned" type="xs:decimal" />
                          <xs:element name="ForeignOwner" type="switch" />
                        </xs:all>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="ACCOUNTS">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="ACCOUNT"  maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:all>
                          <xs:element name="AccountNumber" type="nvarlong" />
                          <xs:element name="AccountPurpose" type="nvarlong" />
                          <xs:element name="AccountActive" type="switch" />
                        </xs:all>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
              <xs:element name="ACHDETAILS">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="ACHDETAIL"  maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:all>
                          <xs:element name="ACHID" type="nvar10" />
                          <xs:element name="ACHCompanyName" type="nvar16" />
                          <xs:element name="ACHType" type="ACHTCAType" />
                        </xs:all>
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:all>
            <xs:assert test="(SWBorderOperations='y' and string-length(SWBorderOpsDescription)>0) or SWBorderOperations='n' "/>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

0 个答案:

没有答案