Reference

loader

Load OCX schemas from a local file, folder, or remote URL into xsdata Schema objects.

ocx_schema_parser.loader.load(source, download_folder=None)[source]

Load source and return one parsed xsd.Schema per XSD file.

Parameters:
  • source – A local .xsd file, a folder of .xsd files, or an http(s) URL.

  • download_folder – Where remote schemas are downloaded. Defaults to a temporary folder. The folder is cleared before downloading.

Raises:

OcxParserError – If the source is missing, empty, or fails to parse.

Return type:

list[Schema]

resolver

ocx_schema_parser.resolver.resolve(schemas)[source]

Resolve parsed schemas into the immutable OcxSchema model.

Raises:

OcxParserError – If schemas is empty.

Return type:

OcxSchema

model

Typed, immutable data model of a resolved OCX schema (Pydantic v2).

class ocx_schema_parser.model.Attribute(**data)[source]

Bases: FrozenModel

A resolved XML attribute of a global element or complex type.

default: Optional[str]
description: str
fixed: Optional[str]
model_config: ClassVar[ConfigDict] = {'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str
prefix: str
type: str
use: Literal['required', 'optional']
class ocx_schema_parser.model.Cardinality(**data)[source]

Bases: FrozenModel

Occurrence bounds of an element. upper=None means unbounded.

lower: int
model_config: ClassVar[ConfigDict] = {'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

upper: Optional[int]
class ocx_schema_parser.model.ChildElement(**data)[source]

Bases: FrozenModel

A resolved child element (particle) of a global element or complex type.

cardinality: Cardinality
description: str
from_substitution_group: Optional[str]
inherited_from: Optional[str]
is_choice: bool
model_config: ClassVar[ConfigDict] = {'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str
prefix: str
type: str
class ocx_schema_parser.model.ComplexType(**data)[source]

Bases: FrozenModel

A named complex type declared in the schema.

abstract: bool
attributes: list[Attribute]
children: list[ChildElement]
description: str
model_config: ClassVar[ConfigDict] = {'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str
parents: list[str]
prefix: str
tag: str
class ocx_schema_parser.model.EnumType(**data)[source]

Bases: FrozenModel

A simple type restricted to an enumeration.

description: str
model_config: ClassVar[ConfigDict] = {'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str
prefix: str
tag: str
values: list[EnumValue]
class ocx_schema_parser.model.EnumValue(**data)[source]

Bases: FrozenModel

One enumeration facet value.

description: str
model_config: ClassVar[ConfigDict] = {'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

value: str
class ocx_schema_parser.model.FrozenModel(**data)[source]

Bases: BaseModel

Base model: immutable after construction.

model_config: ClassVar[ConfigDict] = {'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ocx_schema_parser.model.GlobalElement(**data)[source]

Bases: FrozenModel

A global element declaration with its fully flattened content model.

abstract: bool
attributes: list[Attribute]
cardinality: Cardinality
children: list[ChildElement]
description: str
model_config: ClassVar[ConfigDict] = {'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str
parents: list[str]
prefix: str
substitution_group: Optional[str]
tag: str
type: str
class ocx_schema_parser.model.OcxSchema(**data)[source]

Bases: FrozenModel

The fully resolved OCX schema.

attribute_groups: dict[str, list[Attribute]]
complex_types: list[ComplexType]
elements: list[GlobalElement]
enumerations: list[EnumType]
get(name)[source]

Look up a global element by name or prefix:name.

Return type:

Optional[GlobalElement]

model_config: ClassVar[ConfigDict] = {'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

namespaces: dict[str, str]
schema_changes: list[SchemaChange]
schema_version: str
simple_types: list[SimpleType]
substitution_groups: dict[str, list[str]]
target_namespace: str
class ocx_schema_parser.model.SchemaChange(**data)[source]

Bases: FrozenModel

A SchemaChange appinfo record.

author: str
date: str
description: str
model_config: ClassVar[ConfigDict] = {'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

version: str
class ocx_schema_parser.model.SimpleType(**data)[source]

Bases: FrozenModel

A non-enumeration simple type with its restriction facets.

base: str
description: str
model_config: ClassVar[ConfigDict] = {'frozen': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name: str
prefix: str
restriction: dict[str, str]
tag: str

downloader

class ocx_schema_parser.downloader.SchemaDownloader(output)[source]

Bases: Downloader

Downloader specialisation: writes all referenced schemas into one folder.

Parameters:

output – The path to the schema download folder.

wget(uri, location=None)[source]

Download uri (remote URI or local file path) with circular protection.

Raises:

OcxParserError – If the source cannot be fetched or parsed.

write_file(uri, location, content)[source]

Write a downloaded schema into the single download folder.

cli

Command line interface: export the OCX schema model as JSON or list its entities.

errors

class ocx_schema_parser.errors.OcxParserError[source]

Bases: Exception

Raised when loading or resolving an OCX schema fails.