Created
May 9, 2011 21:33
-
-
Save lemonad/963464 to your computer and use it in GitHub Desktop.
Systembolaget XML Schema
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> | |
<xs:annotation> | |
<xs:documentation xml:lang="sv"> | |
Validerar systembolagets sortimentfil: | |
http://www.systembolaget.se/Press/Pressmaterial/Sortimentsfilen/ | |
Exempel i Python: | |
>>> from lxml import etree | |
>>> schema = etree.XMLSchema(file="systembolaget.xsd") | |
>>> parser = etree.XMLParser(schema = schema) | |
>>> tree = etree.parse("systembolaget.xml", parser) | |
</xs:documentation> | |
</xs:annotation> | |
<xs:element name="artiklar"> | |
<xs:complexType> | |
<xs:sequence> | |
<xs:element name="skapad-tid" type="datetime"/> | |
<xs:element name="artikel" type="artikel" maxOccurs="unbounded"/> | |
</xs:sequence> | |
</xs:complexType> | |
</xs:element> | |
<xs:simpleType name="year"> | |
<xs:annotation> | |
<xs:documentation xml:lang="sv"> | |
Defines a year in format "yyyy" (range 1890-2011) | |
</xs:documentation> | |
</xs:annotation> | |
<xs:restriction base="xs:positiveInteger"> | |
<xs:minInclusive value="1890"/> | |
<xs:maxInclusive value="2011"/> | |
</xs:restriction> | |
</xs:simpleType> | |
<xs:simpleType name="date"> | |
<xs:annotation> | |
<xs:documentation xml:lang="sv"> | |
Defines a date in format "yyyymmdd" (year range: 1900-2019) | |
</xs:documentation> | |
</xs:annotation> | |
<xs:restriction base="xs:token"> | |
<xs:pattern value="(19[0-9]{2}|20[0-1][0-9])(0[0-9]|1[0-2])([0-2][0-9]|3[0-1])"/> | |
</xs:restriction> | |
</xs:simpleType> | |
<xs:simpleType name="datetime"> | |
<xs:annotation> | |
<xs:documentation xml:lang="sv"> | |
Defines a datetime in format "yyyy-mm-dd hh:mm" (year range: 1900-2019) | |
</xs:documentation> | |
</xs:annotation> | |
<xs:restriction base="xs:token"> | |
<xs:pattern value="(19[0-9]{2}|20[0-1][0-9])-(0[0-9]|1[0-2])-([0-2][0-9]|3[0-1]) ([0-1][0-9]|2[0-3]):([0-5][0-9])"/> | |
</xs:restriction> | |
</xs:simpleType> | |
<xs:simpleType name="empty"> | |
<xs:annotation> | |
<xs:documentation xml:lang="sv"> | |
Defines an empty string. | |
</xs:documentation> | |
</xs:annotation> | |
<xs:restriction base="xs:string"/> | |
</xs:simpleType> | |
<xs:simpleType name="zero"> | |
<xs:annotation> | |
<xs:documentation xml:lang="sv"> | |
Defines an integer zero. | |
</xs:documentation> | |
</xs:annotation> | |
<xs:restriction base="xs:integer"> | |
<xs:minInclusive value="0"/> | |
<xs:maxInclusive value="0"/> | |
</xs:restriction> | |
</xs:simpleType> | |
<xs:simpleType name="empty_or_year"> | |
<xs:annotation> | |
<xs:documentation xml:lang="sv"> | |
Defines a type that's either empty or contains a year. | |
</xs:documentation> | |
</xs:annotation> | |
<xs:union memberTypes="empty year" /> | |
</xs:simpleType> | |
<xs:simpleType name="zero_or_year"> | |
<xs:annotation> | |
<xs:documentation xml:lang="sv"> | |
Defines a type that's either zero (0) or contains a year. | |
</xs:documentation> | |
</xs:annotation> | |
<xs:union memberTypes="zero year" /> | |
</xs:simpleType> | |
<xs:simpleType name="percent"> | |
<xs:annotation> | |
<xs:documentation xml:lang="sv"> | |
Defines a type that contains a value in percent. | |
Examples: "7%" or "14,3%" | |
</xs:documentation> | |
</xs:annotation> | |
<xs:restriction base="xs:token"> | |
<xs:pattern value="[0-9]{1,2}(,[0-9])?%"/> | |
</xs:restriction> | |
</xs:simpleType> | |
<xs:complexType name="artikel"> | |
<xs:sequence> | |
<xs:element name="namn" type="xs:token"/> | |
<xs:element name="namn2" type="xs:token"/> | |
<xs:element name="prisinklmoms" type="xs:decimal"/> | |
<xs:element name="volymiml" type="xs:decimal"/> | |
<xs:element name="saljstart" type="date"/> | |
<xs:element name="slutlev" type="empty"/> | |
<xs:element name="varugrupp" type="xs:token"/> | |
<xs:element name="ursprung" type="xs:token"/> | |
<xs:element name="ursprunglandnamn" type="xs:token"/> | |
<xs:element name="producent" type="xs:token" minOccurs="0"/> | |
<xs:element name="argang" type="empty_or_year"/> | |
<xs:element name="provadargang" type="zero_or_year"/> | |
<xs:element name="alkoholhalt" type="percent"/> | |
</xs:sequence> | |
<xs:attribute name="nr" type="xs:positiveInteger" use="required"/> | |
</xs:complexType> | |
</xs:schema> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment