英文:
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 :
<?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>
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论