如果在UBL中的元素中,miniOccurs=”0″,那么如何确定该元素是否是必需的?

huangapple go评论88阅读模式
英文:

How to know what element is mandatory if it has miniOccurs="0" in UBL

问题

以下是我的XML测试代码:

<?xml version="1.0" encoding="UTF-8"?>
<Invoice xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" xmlns:ccts="urn:oasis:names:specification:ubl:schema:xsd:CoreComponentParameters-2" xmlns:stat="urn:oasis:names:specification:ubl:schema:xsd:DocumentStatusCode-1.0" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:udt="urn:un:unece:uncefact:data:draft:UnqualifiedDataTypesSchemaModule:2" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
    <cbc:ID>A00095678</cbc:ID>
    <cbc:IssueDate>2005-06-21</cbc:IssueDate>
    <cac:AccountingSupplierParty>
    </cac:AccountingSupplierParty>
    <cac:AccountingCustomerParty>
    </cac:AccountingCustomerParty>
    <cac:LegalMonetaryTotal>
        <cbc:PayableAmount currencyID="GBP">107.50</cbc:PayableAmount>
    </cac:LegalMonetaryTotal>
    <cac:InvoiceLine>
        <cbc:ID>A</cbc:ID>
        <cbc:LineExtensionAmount currencyID="GBP">100.00</cbc:LineExtensionAmount>
        <cac:Item>
        </cac:Item>
    </cac:InvoiceLine>
</Invoice>

我只放入了在UBL.xsd文件中具有minOccurs="1"的必需元素。

当我尝试在此网站上验证我的XML时,出现以下错误:

[BR-01]-发票应具有规范标识符(BT-24)。
[BR-04]-发票应具有发票类型代码(BT-3)。
[BR-05]-发票应具有发票货币代码(BT-5)。
[BR-06]-发票应包含卖方名称(BT-27)。
[BR-07]-发票应包含买方名称(BT-44)。
[BR-08]-发票应包含卖方邮政地址。
[BR-10]-发票应包含买方邮政地址(BG-8)。
[BR-CO-18]-发票至少应具有一个增值税分组(BG-23)。

我理解错误的含义,我的问题更多是:UBL.xsd文件是如何指定这些元素是必需的?我将需要根据其他.xsd文件生成文件,我想了解哪些元素是必需的。

英文:

Here is my XML test code :

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;Invoice xmlns:qdt=&quot;urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2&quot; xmlns:ccts=&quot;urn:oasis:names:specification:ubl:schema:xsd:CoreComponentParameters-2&quot; xmlns:stat=&quot;urn:oasis:names:specification:ubl:schema:xsd:DocumentStatusCode-1.0&quot; xmlns:cbc=&quot;urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2&quot; xmlns:cac=&quot;urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2&quot; xmlns:udt=&quot;urn:un:unece:uncefact:data:draft:UnqualifiedDataTypesSchemaModule:2&quot; xmlns=&quot;urn:oasis:names:specification:ubl:schema:xsd:Invoice-2&quot;&gt;
	&lt;cbc:ID&gt;A00095678&lt;/cbc:ID&gt;
	&lt;cbc:IssueDate&gt;2005-06-21&lt;/cbc:IssueDate&gt;
	&lt;cac:AccountingSupplierParty&gt;
	&lt;/cac:AccountingSupplierParty&gt;
	&lt;cac:AccountingCustomerParty&gt;
	&lt;/cac:AccountingCustomerParty&gt;
	&lt;cac:LegalMonetaryTotal&gt;
		&lt;cbc:PayableAmount currencyID=&quot;GBP&quot;&gt;107.50&lt;/cbc:PayableAmount&gt;
	&lt;/cac:LegalMonetaryTotal&gt;
	&lt;cac:InvoiceLine&gt;
		&lt;cbc:ID&gt;A&lt;/cbc:ID&gt;
		&lt;cbc:LineExtensionAmount currencyID=&quot;GBP&quot;&gt;100.00&lt;/cbc:LineExtensionAmount&gt;
		&lt;cac:Item&gt;
		&lt;/cac:Item&gt;
	&lt;/cac:InvoiceLine&gt;
&lt;/Invoice&gt;

I put the only elements that were required due to having minOccurs="1" in the UBL.xsd file.

When I try to validate my XML on this site

[BR-01]-An Invoice shall have a Specification identifier (BT-24).
[BR-04]-An Invoice shall have an Invoice type code (BT-3).
[BR-05]-An Invoice shall have an Invoice currency code (BT-5).
[BR-06]-An Invoice shall contain the Seller name (BT-27).
[BR-07]-An Invoice shall contain the Buyer name (BT-44).
[BR-08]-An Invoice shall contain the Seller postal address.
[BR-10]-An Invoice shall contain the Buyer postal address (BG-8).
[BR-CO-18]-An Invoice shall at least have one VAT breakdown group (BG-23).

I understand what the error mean, my question is more :
What is the UBL.xsd file is saying that these elements are mandatory? I will have to generate files regarding other .xsd files and I'd like to understand what elements are mandatory.

答案1

得分: 1

我认为这些错误是来自Schematron验证,例如参考https://github.com/ConnectingEurope/eInvoicing-EN16931/blob/validation-1.3.10/ubl/schematron/preprocessed/EN16931-UBL-validation-preprocessed.sch#L79。

英文:

I think these errors are from Schematron validation, see e.g. https://github.com/ConnectingEurope/eInvoicing-EN16931/blob/validation-1.3.10/ubl/schematron/preprocessed/EN16931-UBL-validation-preprocessed.sch#L79.

huangapple
  • 本文由 发表于 2023年8月9日 05:00:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/76863164.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定