Chapter 21¶
Schema design and documentation¶
Example 21-1 Schema for Russian Doll approach¶
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datypic.com/prod" targetNamespace="http://datypic.com/prod" elementFormDefault="qualified">
<xs:element name="catalog">
<xs:complexType>
<xs:sequence>
<xs:element name="product" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="number" type="xs:integer" />
<xs:element name="name" type="xs:string" />
<xs:element name="size">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="2" />
<xs:maxInclusive value="18" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
<xs:attribute name="dept" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
from dataclasses import dataclass, field
from typing import List, Optional
__NAMESPACE__ = "http://datypic.com/prod"
@dataclass
class Catalog:
"""
:ivar product:
"""
class Meta:
name = "catalog"
namespace = "http://datypic.com/prod"
product: List["Catalog.Product"] = field(
default_factory=list,
metadata=dict(
type="Element",
min_occurs=1,
max_occurs=9223372036854775807
)
)
@dataclass
class Product:
"""
:ivar number:
:ivar name:
:ivar size:
:ivar dept:
"""
number: Optional[int] = field(
default=None,
metadata=dict(
type="Element",
required=True
)
)
name: Optional[str] = field(
default=None,
metadata=dict(
type="Element",
required=True
)
)
size: Optional[int] = field(
default=None,
metadata=dict(
type="Element",
required=True,
min_inclusive=2.0,
max_inclusive=18.0
)
)
dept: Optional[str] = field(
default=None,
metadata=dict(
type="Attribute"
)
)
Example 21-2 Schema for Salami Slice approach¶
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datypic.com/prod" targetNamespace="http://datypic.com/prod" elementFormDefault="qualified">
<xs:element name="catalog">
<xs:complexType>
<xs:sequence>
<xs:element ref="product" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="product">
<xs:complexType>
<xs:sequence>
<xs:element ref="number" />
<xs:element ref="name" />
<xs:element ref="size" />
</xs:sequence>
<xs:attribute name="dept" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:element name="number" type="xs:integer" />
<xs:element name="name" type="xs:string" />
<xs:element name="size">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="2" />
<xs:maxInclusive value="18" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:schema>
from dataclasses import dataclass, field
from typing import List, Optional
__NAMESPACE__ = "http://datypic.com/prod"
@dataclass
class Name:
"""
:ivar value:
"""
class Meta:
name = "name"
namespace = "http://datypic.com/prod"
value: Optional[str] = field(
default=None,
metadata=dict(
required=True
)
)
@dataclass
class Number:
"""
:ivar value:
"""
class Meta:
name = "number"
namespace = "http://datypic.com/prod"
value: Optional[int] = field(
default=None,
metadata=dict(
required=True
)
)
@dataclass
class Size:
"""
:ivar value:
"""
class Meta:
name = "size"
namespace = "http://datypic.com/prod"
value: Optional[int] = field(
default=None,
metadata=dict(
min_inclusive=2.0,
max_inclusive=18.0
)
)
@dataclass
class Product:
"""
:ivar number:
:ivar name:
:ivar size:
:ivar dept:
"""
class Meta:
name = "product"
namespace = "http://datypic.com/prod"
number: Optional[Number] = field(
default=None,
metadata=dict(
type="Element",
required=True
)
)
name: Optional[Name] = field(
default=None,
metadata=dict(
type="Element",
required=True
)
)
size: Optional[Size] = field(
default=None,
metadata=dict(
type="Element",
required=True
)
)
dept: Optional[str] = field(
default=None,
metadata=dict(
type="Attribute"
)
)
@dataclass
class Catalog:
"""
:ivar product:
"""
class Meta:
name = "catalog"
namespace = "http://datypic.com/prod"
product: List[Product] = field(
default_factory=list,
metadata=dict(
type="Element",
min_occurs=1,
max_occurs=9223372036854775807
)
)
Example 21-3 Schema for Venetian Blind approach¶
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datypic.com/prod" targetNamespace="http://datypic.com/prod" elementFormDefault="qualified">
<xs:element name="catalog" type="CatalogType" />
<xs:complexType name="CatalogType">
<xs:sequence>
<xs:element name="product" type="ProductType" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="ProductType">
<xs:sequence>
<xs:element name="number" type="xs:integer" />
<xs:element name="name" type="xs:string" />
<xs:element name="size" type="SizeType" />
</xs:sequence>
<xs:attribute name="dept" type="xs:string" />
</xs:complexType>
<xs:simpleType name="SizeType">
<xs:restriction base="xs:integer">
<xs:minInclusive value="2" />
<xs:maxInclusive value="18" />
</xs:restriction>
</xs:simpleType>
</xs:schema>
from dataclasses import dataclass, field
from typing import List, Optional
__NAMESPACE__ = "http://datypic.com/prod"
@dataclass
class ProductType:
"""
:ivar number:
:ivar name:
:ivar size:
:ivar dept:
"""
number: Optional[int] = field(
default=None,
metadata=dict(
type="Element",
namespace="http://datypic.com/prod",
required=True
)
)
name: Optional[str] = field(
default=None,
metadata=dict(
type="Element",
namespace="http://datypic.com/prod",
required=True
)
)
size: Optional[int] = field(
default=None,
metadata=dict(
type="Element",
namespace="http://datypic.com/prod",
required=True,
min_inclusive=2.0,
max_inclusive=18.0
)
)
dept: Optional[str] = field(
default=None,
metadata=dict(
type="Attribute"
)
)
@dataclass
class CatalogType:
"""
:ivar product:
"""
product: List[ProductType] = field(
default_factory=list,
metadata=dict(
type="Element",
namespace="http://datypic.com/prod",
min_occurs=1,
max_occurs=9223372036854775807
)
)
@dataclass
class Catalog(CatalogType):
class Meta:
name = "catalog"
namespace = "http://datypic.com/prod"
Example 21-4 Schema for Garden of Eden approach¶
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datypic.com/prod" targetNamespace="http://datypic.com/prod" elementFormDefault="qualified">
<xs:element name="catalog" type="CatalogType" />
<xs:complexType name="CatalogType">
<xs:sequence>
<xs:element ref="product" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<xs:element name="product" type="ProductType" />
<xs:complexType name="ProductType">
<xs:sequence>
<xs:element ref="number" />
<xs:element ref="name" />
<xs:element ref="size" />
</xs:sequence>
<xs:attribute name="dept" type="xs:string" />
</xs:complexType>
<xs:element name="number" type="xs:integer" />
<xs:element name="name" type="xs:string" />
<xs:element name="size" type="SizeType" />
<xs:simpleType name="SizeType">
<xs:restriction base="xs:integer">
<xs:minInclusive value="2" />
<xs:maxInclusive value="18" />
</xs:restriction>
</xs:simpleType>
</xs:schema>
from dataclasses import dataclass, field
from typing import List, Optional
__NAMESPACE__ = "http://datypic.com/prod"
@dataclass
class Name:
"""
:ivar value:
"""
class Meta:
name = "name"
namespace = "http://datypic.com/prod"
value: Optional[str] = field(
default=None,
metadata=dict(
required=True
)
)
@dataclass
class Number:
"""
:ivar value:
"""
class Meta:
name = "number"
namespace = "http://datypic.com/prod"
value: Optional[int] = field(
default=None,
metadata=dict(
required=True
)
)
@dataclass
class Size:
"""
:ivar value:
"""
class Meta:
name = "size"
namespace = "http://datypic.com/prod"
value: Optional[int] = field(
default=None,
metadata=dict(
required=True,
min_inclusive=2.0,
max_inclusive=18.0
)
)
@dataclass
class ProductType:
"""
:ivar number:
:ivar name:
:ivar size:
:ivar dept:
"""
number: Optional[Number] = field(
default=None,
metadata=dict(
type="Element",
namespace="http://datypic.com/prod",
required=True
)
)
name: Optional[Name] = field(
default=None,
metadata=dict(
type="Element",
namespace="http://datypic.com/prod",
required=True
)
)
size: Optional[Size] = field(
default=None,
metadata=dict(
type="Element",
namespace="http://datypic.com/prod",
required=True
)
)
dept: Optional[str] = field(
default=None,
metadata=dict(
type="Attribute"
)
)
@dataclass
class Product(ProductType):
class Meta:
name = "product"
namespace = "http://datypic.com/prod"
@dataclass
class CatalogType:
"""
:ivar product:
"""
product: List[Product] = field(
default_factory=list,
metadata=dict(
type="Element",
namespace="http://datypic.com/prod",
min_occurs=1,
max_occurs=9223372036854775807
)
)
@dataclass
class Catalog(CatalogType):
class Meta:
name = "catalog"
namespace = "http://datypic.com/prod"
Example 21-8 Same namespace in a schema¶
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datypic.com/all" targetNamespace="http://datypic.com/all" elementFormDefault="qualified">
<xs:include schemaLocation="example21082.xsd" />
<xs:include schemaLocation="example21083.xsd" />
<xs:element name="order" type="OrderType" />
<xs:complexType name="OrderType">
<xs:sequence>
<xs:element name="customer" type="CustomerType" />
<xs:element name="items" type="ItemsType" />
</xs:sequence>
</xs:complexType>
</xs:schema>
from dataclasses import dataclass, field
from typing import Optional
from tests.fixtures.defxmlschema.chapter21.example21083 import (
CustomerType,
)
from tests.fixtures.defxmlschema.chapter21.example21082 import (
ItemsType,
)
__NAMESPACE__ = "http://datypic.com/all"
@dataclass
class OrderType:
"""
:ivar customer:
:ivar items:
"""
customer: Optional[CustomerType] = field(
default=None,
metadata=dict(
type="Element",
namespace="http://datypic.com/all",
required=True
)
)
items: Optional[ItemsType] = field(
default=None,
metadata=dict(
type="Element",
namespace="http://datypic.com/all",
required=True
)
)
@dataclass
class Order(OrderType):
class Meta:
name = "order"
namespace = "http://datypic.com/all"
Example 21-8 Same namespace in a schema¶
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datypic.com/all" targetNamespace="http://datypic.com/all" elementFormDefault="qualified">
<xs:complexType name="ItemsType">
<xs:sequence maxOccurs="unbounded">
<xs:element name="product" type="ProductType" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="ProductType">
<xs:sequence>
<xs:element name="number" type="xs:integer" />
</xs:sequence>
</xs:complexType>
</xs:schema>
from dataclasses import dataclass, field
from typing import List, Optional
__NAMESPACE__ = "http://datypic.com/all"
@dataclass
class ProductType:
"""
:ivar number:
"""
number: Optional[int] = field(
default=None,
metadata=dict(
type="Element",
namespace="http://datypic.com/all",
required=True
)
)
@dataclass
class ItemsType:
"""
:ivar product:
"""
product: List[ProductType] = field(
default_factory=list,
metadata=dict(
type="Element",
namespace="http://datypic.com/all",
min_occurs=1,
max_occurs=9223372036854775807
)
)
Example 21-8 Same namespace in a schema¶
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datypic.com/all" targetNamespace="http://datypic.com/all" elementFormDefault="qualified">
<xs:complexType name="CustomerType">
<xs:sequence>
<xs:element name="name" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
from dataclasses import dataclass, field
from typing import Optional
__NAMESPACE__ = "http://datypic.com/all"
@dataclass
class CustomerType:
"""
:ivar name:
"""
name: Optional[str] = field(
default=None,
metadata=dict(
type="Element",
namespace="http://datypic.com/all",
required=True
)
)
Example 21-10 Different namespaces in a schema¶
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:prod="http://datypic.com/prod" xmlns:cust="http://datypic.com/cust" xmlns="http://datypic.com/ord" targetNamespace="http://datypic.com/ord" elementFormDefault="qualified">
<xs:import schemaLocation="example21102.xsd" namespace="http://datypic.com/prod" />
<xs:import schemaLocation="example21103.xsd" namespace="http://datypic.com/cust" />
<xs:element name="order" type="OrderType" />
<xs:complexType name="OrderType">
<xs:sequence>
<xs:element name="customer" type="cust:CustomerType" />
<xs:element name="items" type="prod:ItemsType" />
</xs:sequence>
</xs:complexType>
</xs:schema>
from dataclasses import dataclass, field
from typing import Optional
from tests.fixtures.defxmlschema.chapter21.example21103 import (
CustomerType,
)
from tests.fixtures.defxmlschema.chapter21.example21102 import (
ItemsType,
)
__NAMESPACE__ = "http://datypic.com/ord"
@dataclass
class OrderType:
"""
:ivar customer:
:ivar items:
"""
customer: Optional[CustomerType] = field(
default=None,
metadata=dict(
type="Element",
namespace="http://datypic.com/ord",
required=True
)
)
items: Optional[ItemsType] = field(
default=None,
metadata=dict(
type="Element",
namespace="http://datypic.com/ord",
required=True
)
)
@dataclass
class Order(OrderType):
class Meta:
name = "order"
namespace = "http://datypic.com/ord"
Example 21-10 Different namespaces in a schema¶
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datypic.com/prod" targetNamespace="http://datypic.com/prod" elementFormDefault="qualified">
<xs:complexType name="ItemsType">
<xs:sequence maxOccurs="unbounded">
<xs:element name="product" type="ProductType" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="ProductType">
<xs:sequence>
<xs:element name="number" type="xs:integer" />
</xs:sequence>
</xs:complexType>
</xs:schema>
from dataclasses import dataclass, field
from typing import List, Optional
__NAMESPACE__ = "http://datypic.com/prod"
@dataclass
class ProductType:
"""
:ivar number:
"""
number: Optional[int] = field(
default=None,
metadata=dict(
type="Element",
namespace="http://datypic.com/prod",
required=True
)
)
@dataclass
class ItemsType:
"""
:ivar product:
"""
product: List[ProductType] = field(
default_factory=list,
metadata=dict(
type="Element",
namespace="http://datypic.com/prod",
min_occurs=1,
max_occurs=9223372036854775807
)
)
Example 21-10 Different namespaces in a schema¶
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datypic.com/cust" targetNamespace="http://datypic.com/cust" elementFormDefault="qualified">
<xs:complexType name="CustomerType">
<xs:sequence>
<xs:element name="name" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
from dataclasses import dataclass, field
from typing import Optional
__NAMESPACE__ = "http://datypic.com/cust"
@dataclass
class CustomerType:
"""
:ivar name:
"""
name: Optional[str] = field(
default=None,
metadata=dict(
type="Element",
namespace="http://datypic.com/cust",
required=True
)
)
Example 21-13 Chameleon namespaces in a schema¶
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datypic.com/ord" targetNamespace="http://datypic.com/ord" elementFormDefault="qualified">
<xs:include schemaLocation="example21132.xsd" />
<xs:include schemaLocation="example21133.xsd" />
<xs:element name="order" type="OrderType" />
<xs:complexType name="OrderType">
<xs:sequence>
<xs:element name="customer" type="CustomerType" />
<xs:element name="items" type="ItemsType" />
</xs:sequence>
</xs:complexType>
</xs:schema>
from dataclasses import dataclass, field
from typing import Optional
from tests.fixtures.defxmlschema.chapter21.example21133 import (
CustomerType,
)
from tests.fixtures.defxmlschema.chapter21.example21132 import (
ItemsType,
)
__NAMESPACE__ = "http://datypic.com/ord"
@dataclass
class OrderType:
"""
:ivar customer:
:ivar items:
"""
customer: Optional[CustomerType] = field(
default=None,
metadata=dict(
type="Element",
namespace="http://datypic.com/ord",
required=True
)
)
items: Optional[ItemsType] = field(
default=None,
metadata=dict(
type="Element",
namespace="http://datypic.com/ord",
required=True
)
)
@dataclass
class Order(OrderType):
class Meta:
name = "order"
namespace = "http://datypic.com/ord"
Example 21-13 Chameleon namespaces in a schema¶
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:complexType name="ItemsType">
<xs:sequence maxOccurs="unbounded">
<xs:element name="product" type="ProductType" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="ProductType">
<xs:sequence>
<xs:element name="number" type="xs:integer" />
</xs:sequence>
</xs:complexType>
</xs:schema>
from dataclasses import dataclass, field
from typing import List, Optional
@dataclass
class ProductType:
"""
:ivar number:
"""
number: Optional[int] = field(
default=None,
metadata=dict(
type="Element",
required=True
)
)
@dataclass
class ItemsType:
"""
:ivar product:
"""
product: List[ProductType] = field(
default_factory=list,
metadata=dict(
type="Element",
min_occurs=1,
max_occurs=9223372036854775807
)
)
Example 21-13 Chameleon namespaces in a schema¶
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:complexType name="CustomerType">
<xs:sequence>
<xs:element name="name" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
from dataclasses import dataclass, field
from typing import Optional
@dataclass
class CustomerType:
"""
:ivar name:
"""
name: Optional[str] = field(
default=None,
metadata=dict(
type="Element",
required=True
)
)
Example 21-16 Schema for qualified local element names¶
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:prod="http://datypic.com/prod" xmlns="http://datypic.com/ord" targetNamespace="http://datypic.com/ord" elementFormDefault="qualified">
<xs:import schemaLocation="example21162.xsd" namespace="http://datypic.com/prod" />
<xs:element name="order" type="OrderType" />
<xs:complexType name="OrderType">
<xs:sequence>
<xs:element name="number" type="xs:integer" />
<xs:element name="items" type="prod:ItemsType" />
</xs:sequence>
</xs:complexType>
</xs:schema>
from dataclasses import dataclass, field
from typing import Optional
from tests.fixtures.defxmlschema.chapter21.example21162 import (
ItemsType,
)
__NAMESPACE__ = "http://datypic.com/ord"
@dataclass
class OrderType:
"""
:ivar number:
:ivar items:
"""
number: Optional[int] = field(
default=None,
metadata=dict(
type="Element",
namespace="http://datypic.com/ord",
required=True
)
)
items: Optional[ItemsType] = field(
default=None,
metadata=dict(
type="Element",
namespace="http://datypic.com/ord",
required=True
)
)
@dataclass
class Order(OrderType):
class Meta:
name = "order"
namespace = "http://datypic.com/ord"
Example 21-16 Schema for qualified local element names¶
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://datypic.com/prod" targetNamespace="http://datypic.com/prod" elementFormDefault="qualified">
<xs:complexType name="ItemsType">
<xs:sequence maxOccurs="unbounded">
<xs:element name="product" type="ProductType" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="ProductType">
<xs:sequence>
<xs:element name="number" type="xs:integer" />
</xs:sequence>
</xs:complexType>
</xs:schema>
from dataclasses import dataclass, field
from typing import List, Optional
__NAMESPACE__ = "http://datypic.com/prod"
@dataclass
class ProductType:
"""
:ivar number:
"""
number: Optional[int] = field(
default=None,
metadata=dict(
type="Element",
namespace="http://datypic.com/prod",
required=True
)
)
@dataclass
class ItemsType:
"""
:ivar product:
"""
product: List[ProductType] = field(
default_factory=list,
metadata=dict(
type="Element",
namespace="http://datypic.com/prod",
min_occurs=1,
max_occurs=9223372036854775807
)
)
Example 21-18 Documentation¶
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:doc="http://datypic.com/doc">
<xs:include schemaLocation="../chapter01/example0102.xsd" />
<xs:element name="product" type="ProductType">
<xs:annotation>
<xs:documentation xml:lang="en" source="http://datypic.com/prod.html#product">
<doc:description>This element represents a product.</doc:description>
</xs:documentation>
</xs:annotation>
</xs:element>
</xs:schema>
from dataclasses import dataclass
from tests.fixtures.defxmlschema.chapter01.example0102 import (
ProductType,
)
@dataclass
class Product(ProductType):
"""<doc:description>This element represents a product.</doc:description>"""
class Meta:
name = "product"
Example 21-19 ISO 11179-based type definition¶
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:doc="http://datypic.com/doc">
<xs:simpleType name="CountryType">
<xs:annotation>
<xs:documentation>
<doc:name>Country identifier</doc:name>
<doc:identifier>3166</doc:identifier>
<doc:version>1990</doc:version>
<doc:registrationAuthority>ISO</doc:registrationAuthority>
<doc:definition>A code for the names of countries of the world.</doc:definition>
<doc:keyword>geopolitical entity</doc:keyword>
<doc:keyword>country</doc:keyword>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token" />
</xs:simpleType>
<xs:element name="Country" type="CountryType" />
</xs:schema>
from dataclasses import dataclass, field
from typing import Optional
@dataclass
class Country:
"""
:ivar value:
"""
value: Optional[str] = field(
default=None,
metadata=dict(
required=True
)
)
Example 21-20 Code documentation¶
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:doc="http://datypic.com/doc">
<xs:simpleType name="CountryType">
<xs:annotation>
<xs:documentation>
<doc:author>Priscilla Walmsley</doc:author>
<doc:version>1.1</doc:version>
<doc:since>1.0</doc:since>
<doc:see>
<doc:label>Country Code Listings</doc:label>
<doc:link>http://datypic.com/countries.html</doc:link>
</doc:see>
<doc:deprecated>false</doc:deprecated>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token" />
</xs:simpleType>
<xs:element name="Country" type="CountryType" />
</xs:schema>
from dataclasses import dataclass, field
from typing import Optional
@dataclass
class Country:
"""
:ivar value:
"""
value: Optional[str] = field(
default=None,
metadata=dict(
required=True
)
)
Example 21-21 Section identifiers¶
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:annotation>
<xs:documentation>
<sectionHeader>********* Product-Related Element Declarations ***************</sectionHeader>
</xs:documentation>
</xs:annotation>
<xs:include schemaLocation="../chapter01/example0102.xsd" />
<xs:include schemaLocation="../chapter17/chapter17.xsd" />
<xs:element name="product" type="ProductType" />
<xs:element name="size" type="SizeType" />
<xs:annotation>
<xs:documentation>
<sectionHeader>********* Order-Related Element Declarations *****************</sectionHeader>
</xs:documentation>
</xs:annotation>
<xs:element name="order" type="OrderType" />
<xs:element name="items" type="ItemsType" />
</xs:schema>
from dataclasses import dataclass, field
from typing import Optional
from tests.fixtures.defxmlschema.chapter17.chapter17 import (
ItemsType,
OrderType,
ProductType,
)
@dataclass
class Size:
"""
:ivar value:
"""
class Meta:
name = "size"
value: Optional[int] = field(
default=None,
metadata=dict(
required=True,
min_inclusive=2.0,
max_inclusive=18.0
)
)
@dataclass
class Items(ItemsType):
class Meta:
name = "items"
@dataclass
class Order(OrderType):
class Meta:
name = "order"
@dataclass
class Product(ProductType):
class Meta:
name = "product"
Example 21-22 Application information¶
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:app="http://datypic.com/app">
<xs:include schemaLocation="../chapter01/example0102.xsd" />
<xs:element name="product" type="ProductType">
<xs:annotation>
<xs:appinfo>
<app:dbmapping>
<app:tb>PRODUCT_MASTER</app:tb>
</app:dbmapping>
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:schema>
from dataclasses import dataclass
from tests.fixtures.defxmlschema.chapter01.example0102 import (
ProductType,
)
@dataclass
class Product(ProductType):
class Meta:
name = "product"
Samples Source
Definitive XML Schema by Priscilla Walmsley (c) 2012 Prentice Hall PTR