Heureka.sk doesn't provide their XSD schema, so I'm trying to "reverse engineer it" based on how they describe it with words and show with examples here.
This is their most complete XML example:
<?xml version="1.0" encoding="utf-8"?>
<SHOP>
<SHOPITEM>
<ITEM_ID>AB123</ITEM_ID>
<PRODUCTNAME>Nokia 5800 XpressMusic</PRODUCTNAME>
<PRODUCT>Nokia 5800 XpressMusic</PRODUCT>
<DESCRIPTION>Klasický s plným dotykovým uživatelským rozhraním</DESCRIPTION>
<URL>http://obchod.cz/mobily/nokia-5800-xpressmusic</URL>
<IMGURL>http://obchod.cz/mobily/nokia-5800-xpressmusic/obrazek.jpg</IMGURL>
<IMGURL_ALTERNATIVE>http://obchod.cz/mobily/nokia-5800-xpressmusic/obrazek2.jpg</IMGURL_ALTERNATIVE>
<PRICE_VAT>6000</PRICE_VAT>
<HEUREKA_CPC>5.8</HEUREKA_CPC>
<MANUFACTURER>NOKIA</MANUFACTURER>
<CATEGORYTEXT>Elektronika | Mobilní telefony</CATEGORYTEXT>
<EAN>6417182041488</EAN>
<PRODUCTNO>RM-559394</PRODUCTNO>
<PARAM>
<PARAM_NAME>Barva</PARAM_NAME>
<VAL>černá</VAL>
</PARAM>
<DELIVERY_DATE>2</DELIVERY_DATE>
<DELIVERY>
<DELIVERY_ID>CESKA_POSTA</DELIVERY_ID>
<DELIVERY_PRICE>120</DELIVERY_PRICE>
<DELIVERY_PRICE_COD>120</DELIVERY_PRICE_COD>
</DELIVERY>
<DELIVERY>
<DELIVERY_ID>PPL</DELIVERY_ID>
<DELIVERY_PRICE>90</DELIVERY_PRICE>
<DELIVERY_PRICE_COD>120</DELIVERY_PRICE_COD>
</DELIVERY>
<ACCESSORY>CD456</ACCESSORY>
<GIFT>Pouzdro zdarma</GIFT>
<EXTENDED_WARRANTY>
<VAL>36</VAL>
<DESC>Záruka na 36 měsíců</DESC>
</EXTENDED_WARRANTY>
<SPECIAL_SERVICE>Aplikace ochranné fólie</SPECIAL_SERVICE>
<SALES_VOUCHER>
<CODE>SLEVA20</CODE>
<DESC>Sleva 20% po zadání kódu do 31.12.2021!</DESC>
</SALES_VOUCHER>
</SHOPITEM>
</SHOP>
And this is what I got so far:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:complexType name="DeliveryType">
<xs:sequence>
<xs:element name="DELIVERY_ID">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="CESKA_POSTA"/>
<xs:enumeration value="CESKA_POSTA_DOPORUCENA_ZASILKA"/>
<xs:enumeration value="CSAD_LOGISTIK_OSTRAVA"/>
<xs:enumeration value="DPD"/>
<xs:enumeration value="DHL"/>
<xs:enumeration value="DSV"/>
<xs:enumeration value="FOFR"/>
<xs:enumeration value="GEBRUDER_WEISS"/>
<xs:enumeration value="GEIS"/>
<xs:enumeration value="GLS"/>
<xs:enumeration value="HDS"/>
<xs:enumeration value="PPL"/>
<xs:enumeration value="SEEGMULLER"/>
<xs:enumeration value="TNT"/>
<xs:enumeration value="TOPTRANS"/>
<xs:enumeration value="UPS"/>
<xs:enumeration value="FEDEX"/>
<xs:enumeration value="RABEN_LOGISTICS"/>
<xs:enumeration value="ZASILKOVNA_NA_ADRESU"/>
<xs:enumeration value="123KURIER"/>
<xs:enumeration value="WEDO_HOME"/>
<xs:enumeration value="RHENUS_LOGISTICS"/>
<xs:enumeration value="MESSENGER"/>
<xs:enumeration value="ZASILKOVNA"/>
<xs:enumeration value="DPD_PICKUP"/>
<xs:enumeration value="BALIKOVNA_DEPOTAPI"/>
<xs:enumeration value="WEDO_POINT"/>
<xs:enumeration value="CESKA_POSTA_NAPOSTU"/>
<xs:enumeration value="PPL_PARCELSHOP"/>
<xs:enumeration value="GLS_PARCELSHOP"/>
<xs:enumeration value="ALZAPOINT"/>
<xs:enumeration value="DPD_BOX"/>
<xs:enumeration value="Z_BOX"/>
<xs:enumeration value="WEDO_BOX"/>
<xs:enumeration value="PPL_PARCELBOX"/>
<xs:enumeration value="BALIKOVNA_BOX"/>
<xs:enumeration value="ALZABOX"/>
<xs:enumeration value="ONLINE"/>
<xs:enumeration value="VLASTNI_PREPRAVA"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="DELIVERY_PRICE" type="xs:decimal"/>
<xs:element name="DELIVERY_PRICE_COD" type="xs:decimal"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ParamType">
<xs:sequence>
<xs:element name="PARAM_NAME" type="xs:string"/>
<xs:element name="VAL" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ExtendedWarrantyType">
<xs:sequence>
<xs:element name="VAL" type="xs:int"/>
<xs:element name="DESC" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="SalesVoucherType">
<xs:sequence>
<xs:element name="CODE" type="xs:string"/>
<xs:element name="DESC" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="SHOP">
<xs:complexType>
<xs:sequence>
<xs:element name="SHOPITEM" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="ITEM_ID" type="xs:string">
<xs:annotation>
<xs:documentation>ITEM_ID can only contain characters: [ _ - 0-9 a-z A-Z ] and be a maximum of 36 characters long.</xs:documentation>
<xs:appinfo>
<xs:pattern value="[a-zA-Z0-9_-]+"/>
<xs:maxLength value="36"/>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="ITEMGROUP_ID" type="xs:string">
<xs:annotation>
<xs:documentation>ITEMGROUP_ID can only contain characters: [ _ - 0-9 a-z A-Z ] and be a maximum of 36 characters long.</xs:documentation>
<xs:appinfo>
<xs:pattern value="[a-zA-Z0-9_-]+"/>
<xs:maxLength value="36"/>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="PRODUCTNAME" type="xs:string">
<xs:annotation>
<xs:documentation>PRODUCTNAME can be a maximum of 200 characters long.</xs:documentation>
<xs:appinfo>
<xs:maxLength value="200"/>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="PRODUCT" type="xs:string" minOccurs="0"/>
<xs:element name="DESCRIPTION" type="xs:string" minOccurs="0"/>
<xs:element name="URL" type="xs:anyURI" minOccurs="0">
<xs:annotation>
<xs:documentation>URL can be a maximum of 255 characters long.</xs:documentation>
<xs:appinfo>
<xs:maxLength value="255"/>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="IMGURL" type="xs:anyURI" minOccurs="0">
<xs:annotation>
<xs:documentation>IMGURL can be a maximum of 255 characters long.</xs:documentation>
<xs:appinfo>
<xs:maxLength value="255"/>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="IMGURL_ALTERNATIVE" type="xs:anyURI" minOccurs="0">
<xs:annotation>
<xs:documentation>IMGURL_ALTERNATIVE can be a maximum of 255 characters long.</xs:documentation>
<xs:appinfo>
<xs:maxLength value="255"/>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="VIDEO_URL" type="xs:anyURI" minOccurs="0"/>
<xs:element name="VAT" type="xs:decimal" minOccurs="0"/>
<xs:element name="PRICE_VAT" type="xs:decimal"/>
<xs:element name="ITEM_TYPE" type="xs:string" minOccurs="0"/>
<xs:element name="PARAM" maxOccurs="unbounded" type="ParamType" minOccurs="0"/>
<xs:element name="MANUFACTURER" type="xs:string" minOccurs="0"/>
<xs:element name="CATEGORYTEXT" type="xs:string"/>
<xs:element name="EAN" type="xs:string" minOccurs="0"/>
<xs:element name="ISBN" type="xs:string" minOccurs="0"/>
<xs:element name="HEUREKA_CPC" type="xs:decimal" minOccurs="0"/>
<xs:element name="DELIVERY_DATE" type="xs:int" minOccurs="0"/>
<xs:element name="DELIVERY" maxOccurs="unbounded" type="DeliveryType" minOccurs="0"/>
<xs:element name="ACCESSORY" type="xs:string" minOccurs="0"/>
<xs:element name="DUES" type="xs:string" minOccurs="0"/>
<xs:element name="GIFT" type="xs:string" minOccurs="0"/>
<xs:element name="GIFT_ID" type="xs:string" minOccurs="0"/>
<xs:element name="EXTENDED_WARRANTY" type="ExtendedWarrantyType" minOccurs="0"/>
<xs:element name="SPECIAL_SERVICE" type="xs:string" minOccurs="0"/>
<xs:element name="SALES_VOUCHER" type="SalesVoucherType" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
When I try to validate them, I cannot get a concrete error that would help me identify what I'm doing wrong. When I try to validate it with libxml2
s bindings for rust, I get:
[StructuredError { message: Some("Element 'PRODUCTNAME': This element is not expected. Expected is ( ITEMGROUP_ID ).\n"), level: Error, filename: Some("heureka-example.xml"), line: Some(5), col: None, domain: 17, code: 1871 }]
And when I try to validate it on this website, I get:
Cvc-complex-type.2.4.a: Invalid Content Was Found Starting With Element 'PRODUCTNAME'. One Of '{ITEMGROUP_ID}' Is Expected., Line '4'【𝟭,𝟮𝟮 𝗺】, Column '18'【𝟱,𝟱 𝗺】.
What am I missing?
I am assuming that your XSD is 1.1
XSD 1.1 became a standard in 2012.
XML has one undefined element. So, I commented it out:
<!--<PRODUCTNO>RM-559394</PRODUCTNO>-->
XSD 1.1 allows to replace <xs:sequence>
with <xs:all>
to allow unpredictable sequential order of XML elements .
XML
<?xml version="1.0" encoding="utf-8"?>
<SHOP xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Heureka.xsd">
<SHOPITEM>
<ITEM_ID>AB123</ITEM_ID>
<PRODUCTNAME>Nokia 5800 XpressMusic</PRODUCTNAME>
<PRODUCT>Nokia 5800 XpressMusic</PRODUCT>
<DESCRIPTION>Klasický s plným dotykovým uživatelským rozhraním</DESCRIPTION>
<URL>http://obchod.cz/mobily/nokia-5800-xpressmusic</URL>
<IMGURL>http://obchod.cz/mobily/nokia-5800-xpressmusic/obrazek.jpg</IMGURL>
<IMGURL_ALTERNATIVE>http://obchod.cz/mobily/nokia-5800-xpressmusic/obrazek2.jpg</IMGURL_ALTERNATIVE>
<PRICE_VAT>6000</PRICE_VAT>
<HEUREKA_CPC>5.8</HEUREKA_CPC>
<MANUFACTURER>NOKIA</MANUFACTURER>
<CATEGORYTEXT>Elektronika | Mobilní telefony</CATEGORYTEXT>
<EAN>6417182041488</EAN>
<!--<PRODUCTNO>RM-559394</PRODUCTNO>-->
<PARAM>
<PARAM_NAME>Barva</PARAM_NAME>
<VAL>černá</VAL>
</PARAM>
<DELIVERY_DATE>2</DELIVERY_DATE>
<DELIVERY>
<DELIVERY_ID>CESKA_POSTA</DELIVERY_ID>
<DELIVERY_PRICE>120</DELIVERY_PRICE>
<DELIVERY_PRICE_COD>120</DELIVERY_PRICE_COD>
</DELIVERY>
<DELIVERY>
<DELIVERY_ID>PPL</DELIVERY_ID>
<DELIVERY_PRICE>90</DELIVERY_PRICE>
<DELIVERY_PRICE_COD>120</DELIVERY_PRICE_COD>
</DELIVERY>
<ACCESSORY>CD456</ACCESSORY>
<GIFT>Pouzdro zdarma</GIFT>
<EXTENDED_WARRANTY>
<VAL>36</VAL>
<DESC>Záruka na 36 měsíců</DESC>
</EXTENDED_WARRANTY>
<SPECIAL_SERVICE>Aplikace ochranné fólie</SPECIAL_SERVICE>
<SALES_VOUCHER>
<CODE>SLEVA20</CODE>
<DESC>Sleva 20% po zadání kódu do 31.12.2021!</DESC>
</SALES_VOUCHER>
</SHOPITEM>
</SHOP>
XSD 1.1
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="DeliveryType">
<xs:all>
<xs:element name="DELIVERY_ID">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="CESKA_POSTA"/>
<xs:enumeration value="CESKA_POSTA_DOPORUCENA_ZASILKA"/>
<xs:enumeration value="CSAD_LOGISTIK_OSTRAVA"/>
<xs:enumeration value="DPD"/>
<xs:enumeration value="DHL"/>
<xs:enumeration value="DSV"/>
<xs:enumeration value="FOFR"/>
<xs:enumeration value="GEBRUDER_WEISS"/>
<xs:enumeration value="GEIS"/>
<xs:enumeration value="GLS"/>
<xs:enumeration value="HDS"/>
<xs:enumeration value="PPL"/>
<xs:enumeration value="SEEGMULLER"/>
<xs:enumeration value="TNT"/>
<xs:enumeration value="TOPTRANS"/>
<xs:enumeration value="UPS"/>
<xs:enumeration value="FEDEX"/>
<xs:enumeration value="RABEN_LOGISTICS"/>
<xs:enumeration value="ZASILKOVNA_NA_ADRESU"/>
<xs:enumeration value="123KURIER"/>
<xs:enumeration value="WEDO_HOME"/>
<xs:enumeration value="RHENUS_LOGISTICS"/>
<xs:enumeration value="MESSENGER"/>
<xs:enumeration value="ZASILKOVNA"/>
<xs:enumeration value="DPD_PICKUP"/>
<xs:enumeration value="BALIKOVNA_DEPOTAPI"/>
<xs:enumeration value="WEDO_POINT"/>
<xs:enumeration value="CESKA_POSTA_NAPOSTU"/>
<xs:enumeration value="PPL_PARCELSHOP"/>
<xs:enumeration value="GLS_PARCELSHOP"/>
<xs:enumeration value="ALZAPOINT"/>
<xs:enumeration value="DPD_BOX"/>
<xs:enumeration value="Z_BOX"/>
<xs:enumeration value="WEDO_BOX"/>
<xs:enumeration value="PPL_PARCELBOX"/>
<xs:enumeration value="BALIKOVNA_BOX"/>
<xs:enumeration value="ALZABOX"/>
<xs:enumeration value="ONLINE"/>
<xs:enumeration value="VLASTNI_PREPRAVA"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="DELIVERY_PRICE" type="xs:decimal"/>
<xs:element name="DELIVERY_PRICE_COD" type="xs:decimal"/>
</xs:all>
</xs:complexType>
<xs:complexType name="ParamType">
<xs:sequence>
<xs:element name="PARAM_NAME" type="xs:string"/>
<xs:element name="VAL" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ExtendedWarrantyType">
<xs:sequence>
<xs:element name="VAL" type="xs:int"/>
<xs:element name="DESC" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="SalesVoucherType">
<xs:sequence>
<xs:element name="CODE" type="xs:string"/>
<xs:element name="DESC" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="SHOP">
<xs:complexType>
<xs:all>
<xs:element name="SHOPITEM" maxOccurs="unbounded">
<xs:complexType>
<xs:all>
<xs:element name="ITEM_ID" type="xs:string">
<xs:annotation>
<xs:documentation>ITEM_ID can only contain characters: [ _ - 0-9 a-z A-Z ] and be a maximum of 36 characters long.</xs:documentation>
<xs:appinfo>
<xs:pattern value="[a-zA-Z0-9_-]+"/>
<xs:maxLength value="36"/>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="ITEMGROUP_ID" type="xs:string"
minOccurs="0">
<xs:annotation>
<xs:documentation>ITEMGROUP_ID can only contain characters: [ _ - 0-9 a-z A-Z ] and be a maximum of 36 characters long.</xs:documentation>
<xs:appinfo>
<xs:pattern value="[a-zA-Z0-9_-]+"/>
<xs:maxLength value="36"/>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="PRODUCTNAME" type="xs:string">
<xs:annotation>
<xs:documentation>PRODUCTNAME can be a maximum of 200 characters long.</xs:documentation>
<xs:appinfo>
<xs:maxLength value="200"/>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="PRODUCT" type="xs:string"
minOccurs="0"/>
<xs:element name="DESCRIPTION" type="xs:string"
minOccurs="0"/>
<xs:element name="URL" type="xs:anyURI"
minOccurs="0">
<xs:annotation>
<xs:documentation>URL can be a maximum of 255 characters long.</xs:documentation>
<xs:appinfo>
<xs:maxLength value="255"/>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="IMGURL" type="xs:anyURI"
minOccurs="0">
<xs:annotation>
<xs:documentation>IMGURL can be a maximum of 255 characters long.</xs:documentation>
<xs:appinfo>
<xs:maxLength value="255"/>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="IMGURL_ALTERNATIVE"
type="xs:anyURI" minOccurs="0">
<xs:annotation>
<xs:documentation>IMGURL_ALTERNATIVE can be a maximum of 255 characters long.</xs:documentation>
<xs:appinfo>
<xs:maxLength value="255"/>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="VIDEO_URL" type="xs:anyURI"
minOccurs="0"/>
<xs:element name="VAT" type="xs:decimal"
minOccurs="0"/>
<xs:element name="PRICE_VAT" type="xs:decimal"/>
<xs:element name="ITEM_TYPE" type="xs:string"
minOccurs="0"/>
<xs:element name="PARAM" type="ParamType"
minOccurs="0"/>
<xs:element name="MANUFACTURER" type="xs:string"
minOccurs="0"/>
<xs:element name="CATEGORYTEXT" type="xs:string"
minOccurs="0"/>
<xs:element name="EAN" type="xs:string"
minOccurs="0"/>
<xs:element name="ISBN" type="xs:string"
minOccurs="0"/>
<xs:element name="HEUREKA_CPC" type="xs:decimal"
minOccurs="0"/>
<xs:element name="DELIVERY_DATE" type="xs:int"
minOccurs="0"/>
<xs:element name="DELIVERY" type="DeliveryType"
minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="ACCESSORY" type="xs:string"
minOccurs="0"/>
<xs:element name="DUES" type="xs:string"
minOccurs="0"/>
<xs:element name="GIFT" type="xs:string"
minOccurs="0"/>
<xs:element name="GIFT_ID" type="xs:string"
minOccurs="0"/>
<xs:element name="EXTENDED_WARRANTY"
type="ExtendedWarrantyType"
minOccurs="0"/>
<xs:element name="SPECIAL_SERVICE" type="xs:string"
minOccurs="0"/>
<xs:element name="SALES_VOUCHER"
type="SalesVoucherType" minOccurs="0"/>
</xs:all>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>