我如何通过读取 XSD 文件知道我的 XML 命名空间应该是什么?

How do I know what my XML namespace should be from reading the XSD files?

我在使用此文档的根元素时遇到命名空间问题。我的 XML 声明与文档文件匹配,但我认为架构可能已更新但未更新文档。

我在基本架构中看到有一个元素 EFilingMegabatchXML 包含 EFilingBatchXMLEFilingBatchXML 也在 Base Schema 文件中定义。有问题吗?

我的错误:

Error: cvc-elt.1.a: Cannot find the declaration of element 'fc2:EFilingBatchXML'.

我的XML:

<?xml version="1.0" encoding="UTF-8"?>
<fc2:EFilingBatchXML xmlns:fc2="www.fincen.gov/base"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="www.fincen.gov/base https://www.fincen.gov/sites/default/files/schema/base/EFL_CTRXBatchSchema.xsd"
ActivityCount="10" TotalAmount="100000" PartyCount="60">

此处的文档:https://bsaefiling.fincen.treas.gov/docs/XMLUserGuide_FinCENCTR.pdf

此处的基本架构:www.fincen.gov/base

这里的批处理模式:https://www.fincen.gov/base/EFL_CTRXBatchSchema.xsd

批处理模式摘录:

<xsd:schema xmlns="www.fincen.gov/base" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning" targetNamespace="www.fincen.gov/base" elementFormDefault="qualified" attributeFormDefault="unqualified" vc:minVersion="1.1">

<xsd:redefine schemaLocation="BSA_XML_2.0.xsd">
...
</xsd:redefine>

<xsd:element name="EFilingBatchXML">
...
</xsd:element>

...

</xsd:schema>

How do I know what my XML namespace should be from reading the XSD files?

XML 文档的根元素的 XML 命名空间应该匹配管理 XSD.

targetNamespace 属性值

I see in the Base Schema there is an element EFilingMegabatchXML which encloses EFilingBatchXML. EFilingBatchXML is also defined in the Base Schema file. Is that a problem?

根元素必须在关联的 XSD 的顶层定义,因此您将无法使具有 EFilingBatchXML 根元素的 XML 文档验证基本模式,因为它在顶层没有这样的元素。

根据您 post 编辑的内容(假设它代表您的实际情况),fc2:EFilingBatchXML 作为 XML 文档的根元素 fc2根据您的 xsi:schemaLocation 属性值,绑定到 www.fincen.gov/base 的名称空间前缀应该与 https://www.fincen.gov/sites/default/files/schema/base/EFL_CTRXBatchSchema.xsd 相关联。它是在 top-level 那里定义的,因此对于它是根元素的文档应该可以访问它。

示例有效 XML

XSD 似乎受到 paper-form 时代的要求,例如至少六个 fc2:Party 元素,所以这个“最小”示例有点长,但是下面的 XML 对 xsi:schemaLocation 属性中指示的 XSD 有效。

<?xml version="1.0" encoding="UTF-8"?>
<fc2:EFilingBatchXML TotalAmount="35000" PartyCount="6" ActivityCount="1"
  xsi:schemaLocation="www.fincen.gov/base
  https://www.fincen.gov/sites/default/files/schema/base/EFL_CTRXBatchSchema.xsd"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:fc2="www.fincen.gov/base">
  <fc2:FormTypeCode>CTRX</fc2:FormTypeCode>
  <fc2:Activity SeqNum="1">
    <fc2:EFilingPriorDocumentNumber>0</fc2:EFilingPriorDocumentNumber>
    <fc2:FilingDateText>20200804</fc2:FilingDateText>
    <fc2:ActivityAssociation SeqNum="2">
      <fc2:CorrectsAmendsPriorReportIndicator></fc2:CorrectsAmendsPriorReportIndicator>
      <fc2:FinCENDirectBackFileIndicator></fc2:FinCENDirectBackFileIndicator>
      <fc2:InitialReportIndicator></fc2:InitialReportIndicator>
    </fc2:ActivityAssociation>
    <fc2:Party SeqNum="3">
      <fc2:ActivityPartyTypeCode>35</fc2:ActivityPartyTypeCode>
      <fc2:PartyName SeqNum="4"></fc2:PartyName>
    </fc2:Party>
    <fc2:Party SeqNum="5">
      <fc2:ActivityPartyTypeCode>35</fc2:ActivityPartyTypeCode>
      <fc2:PartyName SeqNum="6"></fc2:PartyName>
    </fc2:Party>
    <fc2:Party SeqNum="7">
      <fc2:ActivityPartyTypeCode>35</fc2:ActivityPartyTypeCode>
      <fc2:PartyName SeqNum="8"></fc2:PartyName>
    </fc2:Party>
    <fc2:Party SeqNum="9">
      <fc2:ActivityPartyTypeCode>35</fc2:ActivityPartyTypeCode>
      <fc2:PartyName SeqNum="10"></fc2:PartyName>
    </fc2:Party>
    <fc2:Party SeqNum="11">
      <fc2:ActivityPartyTypeCode>35</fc2:ActivityPartyTypeCode>
      <fc2:PartyName SeqNum="12"></fc2:PartyName>
    </fc2:Party>
    <fc2:Party SeqNum="13">
      <fc2:ActivityPartyTypeCode>35</fc2:ActivityPartyTypeCode>
      <fc2:PartyName SeqNum="14"></fc2:PartyName>
    </fc2:Party>
    <fc2:CurrencyTransactionActivity SeqNum="15">
      <fc2:AggregateTransactionIndicator></fc2:AggregateTransactionIndicator>
      <fc2:ArmoredCarServiceIndicator></fc2:ArmoredCarServiceIndicator>
      <fc2:ATMIndicator></fc2:ATMIndicator>
      <fc2:MailDepositShipmentIndicator></fc2:MailDepositShipmentIndicator>
      <fc2:NightDepositIndicator></fc2:NightDepositIndicator>
      <fc2:SharedBranchingIndicator></fc2:SharedBranchingIndicator>
      <fc2:TotalCashInReceiveAmountText></fc2:TotalCashInReceiveAmountText>
      <fc2:TotalCashOutAmountText></fc2:TotalCashOutAmountText>
      <fc2:TransactionDateText>20200804</fc2:TransactionDateText>
      <fc2:CurrencyTransactionActivityDetail SeqNum="16">
        <fc2:CurrencyTransactionActivityDetailTypeCode>55</fc2:CurrencyTransactionActivityDetailTypeCode>
        <fc2:DetailTransactionAmountText></fc2:DetailTransactionAmountText>
        <fc2:OtherCurrencyTransactionActivityDetailText></fc2:OtherCurrencyTransactionActivityDetailText>
        <fc2:OtherForeignCurrencyCountryText></fc2:OtherForeignCurrencyCountryText>
      </fc2:CurrencyTransactionActivityDetail>
    </fc2:CurrencyTransactionActivity>
  </fc2:Activity>
</fc2:EFilingBatchXML>

如果本指南不能引导您根据 xsd:schemaLocation 属性中的 XSD 成功验证您的 XML,那么 post a Minimum Complete Example 未能验证进一步的帮助。

另见