Как пропустить проверку определенных полей в схеме XSD

#xsd #schema #xsd-validation

Вопрос:

У меня есть файл XSD схемы, основной.xsd и дочерний.xsd.

Main.xsd:

 lt;?xml version="1.0" encoding="UTF-8"?gt; lt;xsd:schema xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" targetNamespace="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" elementFormDefault="qualified" attributeFormDefault="unqualified"gt;  lt;xsd:import namespace="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" schemaLocation="Child.xsd"/gt;  lt;xsd:element name="Invoice"gt;  lt;xsd:complexTypegt;  lt;xsd:sequencegt;  lt;xsd:any namespace="##any" processContents="skip"/gt;  lt;xsd:element ref="cbc:UBLVersionID" minOccurs="0"/gt;  lt;xsd:element ref="cbc:CustomizationID"/gt;  lt;xsd:element ref="cbc:ProfileID"/gt;  lt;xsd:any namespace="##any" processContents="skip" maxOccurs="unbounded"/gt;  lt;/xsd:sequencegt;  lt;/xsd:complexTypegt;  lt;/xsd:elementgt; lt;/xsd:schemagt;  

Ребенок.xsd:

 lt;?xml version="1.0" encoding="UTF-8"?gt; lt;xsd:schema xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" elementFormDefault="qualified" attributeFormDefault="unqualified"gt;  lt;xsd:element name="UBLVersionID" type="cbc:UBLVersionIDType"/gt;  lt;xsd:element name="CustomizationID" type="cbc:CustomizationIDType"/gt;  lt;xsd:element name="ProfileID" type="cbc:ProfileIDType"/gt;  lt;xsd:complexType name="UBLVersionIDType"gt;  lt;xsd:simpleContentgt;  lt;xsd:extension base="xsd:string"gt;  lt;xsd:anyAttribute namespace="##any" processContents="skip"/gt;  lt;/xsd:extensiongt;  lt;/xsd:simpleContentgt;  lt;/xsd:complexTypegt;  lt;xsd:simpleType name="CustomizationIDType"gt;  lt;xsd:restriction base="xsd:string"gt;  lt;xsd:enumeration value="urn:cen.eu:en16931:2017#compliant#urn:fdc:nen.nl:nlcius:v1.0"/gt;  lt;/xsd:restrictiongt;  lt;/xsd:simpleTypegt;  lt;xsd:simpleType name="ProfileIDType"gt;  lt;xsd:restriction base="xsd:string"gt;  lt;xsd:enumeration value="urn:fdc:peppol.eu:2017:poacc:billing:01:1.0"/gt;  lt;/xsd:restrictiongt;  lt;/xsd:simpleTypegt; lt;/xsd:schemagt;  

Как вы можете видеть в Main.xsd, мы проверяем UBLVersionID, который является необязательным, CustomizationID и ProfileID, оба являются обязательными. xsd:любой оператор перед UBLVersionID и после ProfileID, чтобы пропустить любые элементы или поля, потому что нам просто нужно проверить поля, определенные в Main.xsd. Дочерний файл.xsd содержит определенные поля, правила и т.д…

МОИ XSD-диски отлично работают со всеми 2 XML-файлами, которые у меня есть: A.xml, B.xml:

A.XML: имеет UBLExtensions и UBLVersionID

 lt;Invoice xmlns:ns2="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"gt;  lt;ext:UBLExtensions xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"gt;  lt;ext:UBLExtensiongt;  lt;ext:ExtensionContentgt;  lt;seef:SEEFExtensionWrapper xmlns:seef="urn:www.energie-efactuur.nl:profile:invoice:ver1.0"gt;  lt;seef:UtilityConsumptionPointgt;  lt;cbc:ID xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;871685920003767063lt;/cbc:IDgt;  lt;seef:Addressgt;  lt;cac:Address xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"gt;  lt;cbc:StreetName xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;Zuider IJdijk 46lt;/cbc:StreetNamegt;  lt;cbc:CityName xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;AMSTERDAMlt;/cbc:CityNamegt;  lt;cbc:PostalZone xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;1095 KNlt;/cbc:PostalZonegt;  lt;cac:Countrygt;  lt;cbc:IdentificationCode xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;NLlt;/cbc:IdentificationCodegt;  lt;/cac:Countrygt;  lt;/cac:Addressgt;  lt;/seef:Addressgt;  lt;/seef:UtilityConsumptionPointgt;  lt;/seef:SEEFExtensionWrappergt;  lt;/ext:ExtensionContentgt;  lt;/ext:UBLExtensiongt;  lt;/ext:UBLExtensionsgt;  lt;cbc:UBLVersionID xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;2.1lt;/cbc:UBLVersionIDgt;  lt;cbc:CustomizationID xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;urn:cen.eu:en16931:2017#compliant#urn:fdc:nen.nl:nlcius:v1.0lt;/cbc:CustomizationIDgt;  lt;cbc:ProfileID xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;urn:fdc:peppol.eu:2017:poacc:billing:01:1.0lt;/cbc:ProfileIDgt;  lt;cbc:ID xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;41014619807lt;/cbc:IDgt;  lt;cbc:IssueDate xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;2021-11-10lt;/cbc:IssueDategt;  lt;cbc:DueDate xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;2021-11-24lt;/cbc:DueDategt;  lt;cbc:InvoiceTypeCode xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;380lt;/cbc:InvoiceTypeCodegt;  lt;cbc:Note xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;Zuider IJdijk 46, 1095 KN AMSTERDAM; Voor de algemene voorwaarden, zie: https://www.liander.nl/algemene-voorwaarden.lt;/cbc:Notegt;  lt;cbc:DocumentCurrencyCode xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;EURlt;/cbc:DocumentCurrencyCodegt;  lt;cbc:BuyerReference xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;28224654lt;/cbc:BuyerReferencegt; lt;/Invoicegt;  

B.XML: Has UBLVersionID and not UBLExtensions:

 lt;Invoice xmlns:ns2="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"gt;  lt;cbc:UBLVersionID xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;2.1lt;/cbc:UBLVersionIDgt;  lt;cbc:CustomizationID xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;urn:cen.eu:en16931:2017#compliant#urn:fdc:nen.nl:nlcius:v1.0lt;/cbc:CustomizationIDgt;  lt;cbc:ProfileID xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;urn:fdc:peppol.eu:2017:poacc:billing:01:1.0lt;/cbc:ProfileIDgt;  lt;cbc:ID xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;41014619807lt;/cbc:IDgt;  lt;cbc:IssueDate xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;2021-11-10lt;/cbc:IssueDategt;  lt;cbc:DueDate xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;2021-11-24lt;/cbc:DueDategt;  lt;cbc:InvoiceTypeCode xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;380lt;/cbc:InvoiceTypeCodegt;  lt;cbc:Note xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;Zuider IJdijk 46, 1095 KN AMSTERDAM; Voor de algemene voorwaarden, zie: https://www.liander.nl/algemene-voorwaarden.lt;/cbc:Notegt;  lt;cbc:DocumentCurrencyCode xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;EURlt;/cbc:DocumentCurrencyCodegt;  lt;cbc:BuyerReference xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;28224654lt;/cbc:BuyerReferencegt; lt;/Invoicegt;  

My C.XML is producing validation error because that do not have UBLExtensions and UBLVersionID segments. As you can see, xsd:any and UBLVersionID in schema, both are optional.

C.XML:

 lt;Invoice xmlns:ns2="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"gt;  lt;cbc:CustomizationID xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;urn:cen.eu:en16931:2017#compliant#urn:fdc:nen.nl:nlcius:v1.0lt;/cbc:CustomizationIDgt;  lt;cbc:ProfileID xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;urn:fdc:peppol.eu:2017:poacc:billing:01:1.0lt;/cbc:ProfileIDgt;  lt;cbc:ID xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;41014619807lt;/cbc:IDgt;  lt;cbc:IssueDate xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;2021-11-10lt;/cbc:IssueDategt;  lt;cbc:DueDate xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;2021-11-24lt;/cbc:DueDategt;  lt;cbc:InvoiceTypeCode xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;380lt;/cbc:InvoiceTypeCodegt;  lt;cbc:Note xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;Zuider IJdijk 46, 1095 KN AMSTERDAM; Voor de algemene voorwaarden, zie: https://www.liander.nl/algemene-voorwaarden.lt;/cbc:Notegt;  lt;cbc:DocumentCurrencyCode xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;EURlt;/cbc:DocumentCurrencyCodegt;  lt;cbc:BuyerReference xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;28224654lt;/cbc:BuyerReferencegt; lt;/Invoicegt;  

I tried a lot, what should I change in my schema so that it works with all 3 my xmls. Please help.

Ответ №1:

The error message is

The element ‘Invoice’ in namespace ‘urn:oasis:names:specification:ubl:schema:xsd:Invoice-2’ has invalid child element ‘ProfileID’ in namespace ‘urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2’. List of possible elements expected: ‘UBLVersionID, CustomizationID’ in namespace ‘urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2’.

What that is telling you that either either expects UBLVersionID or, as UBLVersionID is optional, it is expecting CustomizationID. Which of course would strike you as strange as it is actually there.

If you add CustomizationID again like below, it will actually validate.

 lt;Invoice xmlns:ns2="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"gt;  lt;cbc:CustomizationID xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;urn:cen.eu:en16931:2017#compliant#urn:fdc:nen.nl:nlcius:v1.0lt;/cbc:CustomizationIDgt;  lt;cbc:CustomizationID xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;urn:cen.eu:en16931:2017#compliant#urn:fdc:nen.nl:nlcius:v1.0lt;/cbc:CustomizationIDgt;  lt;cbc:ProfileID xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;urn:fdc:peppol.eu:2017:poacc:billing:01:1.0lt;/cbc:ProfileIDgt;  lt;cbc:ID xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;41014619807lt;/cbc:IDgt;  lt;cbc:IssueDate xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;2021-11-10lt;/cbc:IssueDategt;  lt;cbc:DueDate xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;2021-11-24lt;/cbc:DueDategt;  lt;cbc:InvoiceTypeCode xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;380lt;/cbc:InvoiceTypeCodegt;  lt;cbc:Note xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;Zuider IJdijk 46, 1095 KN AMSTERDAM; Voor de algemene voorwaarden, zie: https://www.liander.nl/algemene-voorwaarden.lt;/cbc:Notegt;  lt;cbc:DocumentCurrencyCode xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;EURlt;/cbc:DocumentCurrencyCodegt;  lt;cbc:BuyerReference xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"gt;28224654lt;/cbc:BuyerReferencegt; lt;/Invoicegt;  

Это указывает lt;xsd:any namespace="##any" processContents="skip" /gt; на то, что идентификатор настройки соответствует идентификатору настройки.

Что вам нужно, так это фактически определить другие поля, но как необязательные.

Main.xml

 lt;?xml version="1.0" encoding="utf-16"?gt; lt;xs:schema xmlns:ns2="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:seef="urn:www.energie-efactuur.nl:profile:invoice:ver1.0" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2" xmlns:xs="http://www.w3.org/2001/XMLSchema"gt;  lt;xs:import schemaLocation=".A1.xsd" namespace="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" /gt;  lt;xs:import schemaLocation=".A3.xsd" namespace="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" /gt;  lt;xs:annotationgt;  lt;xs:appinfogt;  lt;references xmlns="http://schemas.microsoft.com/BizTalk/2003"gt;  lt;reference targetNamespace="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" /gt;  lt;reference targetNamespace="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" /gt;  lt;reference targetNamespace="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" /gt;  lt;reference targetNamespace="urn:www.energie-efactuur.nl:profile:invoice:ver1.0" /gt;  lt;/referencesgt;  lt;/xs:appinfogt;  lt;/xs:annotationgt;  lt;xs:element name="Invoice"gt;  lt;xs:complexTypegt;  lt;xs:sequencegt;  lt;xs:element minOccurs="0" ref="ext:UBLExtensions" /gt;  lt;xs:element minOccurs="0" ref="cbc:UBLVersionID" /gt;  lt;xs:element ref="cbc:CustomizationID" /gt;  lt;xs:element ref="cbc:ProfileID" /gt;  lt;xs:element ref="cbc:ID" /gt;  lt;xs:element ref="cbc:IssueDate" /gt;  lt;xs:element ref="cbc:DueDate" /gt;  lt;xs:element ref="cbc:InvoiceTypeCode" /gt;  lt;xs:element ref="cbc:Note" /gt;  lt;xs:element ref="cbc:DocumentCurrencyCode" /gt;  lt;xs:element ref="cbc:BuyerReference" /gt;  lt;/xs:sequencegt;  lt;/xs:complexTypegt;  lt;/xs:elementgt; lt;/xs:schemagt;  

Child1.xml

 lt;?xml version="1.0" encoding="utf-16"?gt; lt;xs:schema xmlns:tns="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:xs="http://www.w3.org/2001/XMLSchema"gt;  lt;xs:import schemaLocation=".Child2.xsd" namespace="urn:www.energie-efactuur.nl:profile:invoice:ver1.0" /gt;  lt;xs:element name="UBLExtensions"gt;  lt;xs:complexTypegt;  lt;xs:sequencegt;  lt;xs:element name="UBLExtension"gt;  lt;xs:complexTypegt;  lt;xs:sequencegt;  lt;xs:element name="ExtensionContent"gt;  lt;xs:complexTypegt;  lt;xs:sequencegt;  lt;xs:element xmlns:q1="urn:www.energie-efactuur.nl:profile:invoice:ver1.0" ref="q1:SEEFExtensionWrapper" /gt;  lt;/xs:sequencegt;  lt;/xs:complexTypegt;  lt;/xs:elementgt;  lt;/xs:sequencegt;  lt;/xs:complexTypegt;  lt;/xs:elementgt;  lt;/xs:sequencegt;  lt;/xs:complexTypegt;  lt;/xs:elementgt; lt;/xs:schemagt;  

Child2.xml

 lt;?xml version="1.0" encoding="utf-16"?gt; lt;xs:schema xmlns:tns="urn:www.energie-efactuur.nl:profile:invoice:ver1.0" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:www.energie-efactuur.nl:profile:invoice:ver1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"gt;  lt;xs:import schemaLocation=".Child3.xsd" namespace="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" /gt;  lt;xs:import schemaLocation=".Child4.xsd" namespace="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" /gt;  lt;xs:element name="SEEFExtensionWrapper"gt;  lt;xs:complexTypegt;  lt;xs:sequencegt;  lt;xs:element name="UtilityConsumptionPoint"gt;  lt;xs:complexTypegt;  lt;xs:sequencegt;  lt;xs:element xmlns:q1="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" ref="q1:ID" /gt;  lt;xs:element name="Address"gt;  lt;xs:complexTypegt;  lt;xs:sequencegt;  lt;xs:element xmlns:q2="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" ref="q2:Address" /gt;  lt;/xs:sequencegt;  lt;/xs:complexTypegt;  lt;/xs:elementgt;  lt;/xs:sequencegt;  lt;/xs:complexTypegt;  lt;/xs:elementgt;  lt;/xs:sequencegt;  lt;/xs:complexTypegt;  lt;/xs:elementgt; lt;/xs:schemagt;  

Child3.xml

 lt;?xml version="1.0" encoding="utf-16"?gt; lt;xs:schema xmlns:tns="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:xs="http://www.w3.org/2001/XMLSchema"gt;  lt;xs:element name="ID" type="xs:unsignedLong" /gt;  lt;xs:element name="StreetName" type="xs:string" /gt;  lt;xs:element name="CityName" type="xs:string" /gt;  lt;xs:element name="PostalZone" type="xs:string" /gt;  lt;xs:element name="IdentificationCode" type="xs:string" /gt;  lt;xs:element name="UBLVersionID" type="xs:decimal" /gt;  lt;xs:element name="CustomizationID" type="xs:string" /gt;  lt;xs:element name="ProfileID" type="xs:string" /gt;  lt;xs:element name="IssueDate" type="xs:date" /gt;  lt;xs:element name="DueDate" type="xs:date" /gt;  lt;xs:element name="InvoiceTypeCode" type="xs:unsignedShort" /gt;  lt;xs:element name="Note" type="xs:string" /gt;  lt;xs:element name="DocumentCurrencyCode" type="xs:string" /gt;  lt;xs:element name="BuyerReference" type="xs:unsignedInt" /gt; lt;/xs:schemagt;  

Child4.xml

 lt;?xml version="1.0" encoding="utf-16"?gt; lt;xs:schema xmlns:tns="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:xs="http://www.w3.org/2001/XMLSchema"gt;  lt;xs:import schemaLocation=".Child3.xsd" namespace="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" /gt;  lt;xs:element name="Address"gt;  lt;xs:complexTypegt;  lt;xs:sequencegt;  lt;xs:element xmlns:q1="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" ref="q1:StreetName" /gt;  lt;xs:element xmlns:q2="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" ref="q2:CityName" /gt;  lt;xs:element xmlns:q3="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" ref="q3:PostalZone" /gt;  lt;xs:element name="Country"gt;  lt;xs:complexTypegt;  lt;xs:sequencegt;  lt;xs:element xmlns:q4="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" ref="q4:IdentificationCode" /gt;  lt;/xs:sequencegt;  lt;/xs:complexTypegt;  lt;/xs:elementgt;  lt;/xs:sequencegt;  lt;/xs:complexTypegt;  lt;/xs:elementgt; lt;/xs:schemagt;  

Комментарии:

1. Можно ли игнорировать все, что предшествует UBLVersionID, вместо того, чтобы объявлять их? Но я действительно ценю ваш ответ на это.

2. @user1441279 Нет, так как это делает вещи неоднозначными в схеме, а затем не может их разобрать. Когда я попытался обновить любой узел до нескольких, я получил предупреждение в Visual Studio, в котором говорится, что это сделает его неоднозначным.

3. P.S. Почему вы все равно создаете эти схемы вручную, а не используете официальные схемы из Oasis?

4. Я также использую официальные схемы, но в нашей системе мы должны создавать небольшие схемы для определенной цели. У системы есть такое требование. Но да, я соглашусь с решением, которое вы предоставили.