sims – Simple schema validation

This module contains classes for a very simple validation model.

Validation is specified like this:

class inner(xsc.Element):
        model = sims.NoElements()

class outer(xsc.Element):
        model = sims.Elements(inner)

With this configuration inner elements may only contain text and outer elements may only contain inner elements. Everything else will issue warnings when parsing or publishing.

exception ll.xist.sims.SIMSWarning[source]

Bases: ll.xist.xsc.Warning

Base class for all warning classes in this module.

__hash__()[source]

Return hash(self).

__eq__(other)[source]

Return self==value.

exception ll.xist.sims.EmptyElementWithContentWarning(path)[source]

Bases: ll.xist.sims.SIMSWarning

Warning that is issued when an element has content, but it shouldn’t (i.e. model is Empty)

__init__(path)[source]

Initialize self. See help(type(self)) for accurate signature.

__str__()[source]

Return str(self).

exception ll.xist.sims.WrongElementWarning(path, badnode)[source]

Bases: ll.xist.sims.SIMSWarning

Warning that is issued when an element contains another element of a certain type, but shouldn’t.

__init__(path, badnode)[source]

Initialize self. See help(type(self)) for accurate signature.

__str__()[source]

Return str(self).

exception ll.xist.sims.ElementWarning(path, badnode)[source]

Bases: ll.xist.sims.SIMSWarning

Warning that is issued when an element contains another element but shouldn’t contain any.

__init__(path, badnode)[source]

Initialize self. See help(type(self)) for accurate signature.

__str__()[source]

Return str(self).

exception ll.xist.sims.IllegalTextWarning(path, badnode)[source]

Bases: ll.xist.sims.SIMSWarning

Warning that is issued when an element contains a text node but shouldn’t.

__init__(path, badnode)[source]

Initialize self. See help(type(self)) for accurate signature.

__str__()[source]

Return str(self).

exception ll.xist.sims.AnyWarning(path, warnings)[source]

Bases: ll.xist.sims.SIMSWarning

Warning that is issued when an element contains a text node but shouldn’t.

__init__(path, warnings)[source]

Initialize self. See help(type(self)) for accurate signature.

__str__()[source]

Return str(self).

ll.xist.sims.badtext(node)[source]

Return whether node is a text node (i.e. ll.xist.xsc.Text that does not consist of whitespace only).

class ll.xist.sims.Empty[source]

Bases: object

This validator checks that an element has no content.

__repr__()[source]

Return repr(self).

class ll.xist.sims.Transparent[source]

Bases: object

This validator implements the “transparent” content model of HTML5.

class ll.xist.sims.NoElements[source]

Bases: object

This validator checks that an element does not have child elements from the same namespace.

__repr__()[source]

Return repr(self).

validate(path)[source]

check that the content of node is valid.

class ll.xist.sims.NoElementsOrText[source]

Bases: object

This validator checks that an element does have neither child elements from the same namespace nor real (i.e. not-whitespace) text nodes.

__repr__()[source]

Return repr(self).

validate(path)[source]

check that the content of node is valid.

class ll.xist.sims.Elements(*elements)[source]

Bases: object

This validator checks that an element does have neither child elements from any of the namespaces of those elements specified in the constructor except for those elements itself nor real (i.e. not-whitespace) text nodes.

__init__(*elements)[source]

Every element in elements may be in the content of the node to which this validator is attached. Any other element from one of the namespaces of those elements is invalid. Elements from other namespaces are OK.

__repr__()[source]

Return repr(self).

validate(path)[source]

check that the content of node is valid.

class ll.xist.sims.ElementsOrText(*elements)[source]

Bases: ll.xist.sims.Elements

This validator checks that an element doesn’t have child elements from the same namespace except those specified in the constructor.

__init__(*elements)[source]

Every element in elements may be in the content of the node to which this validator is attached. Any other element from one of the namespaces of those elements is invalid. Elements from other namespaces are OK.

__repr__()[source]

Return repr(self).

validate(path)[source]

Check that the content of node is valid.

class ll.xist.sims.NotElements(*elements)[source]

Bases: object

This validator checks that an element doesn’t contain any of the specified elements.

__init__(*elements)[source]

Every element in elements may not be in the content of the node to which this validator is attached.

__repr__()[source]

Return repr(self).

class ll.xist.sims.All(*validators)[source]

Bases: object

This meta validator checks that all its child validators declare the content of the element to be valid.

__init__(*validators)[source]

Initialize self. See help(type(self)) for accurate signature.

__repr__()[source]

Return repr(self).

class ll.xist.sims.Any(*validators)[source]

Bases: object

This meta validator checks that at least one of its child validators declares the content of the element to be valid.

__init__(*validators)[source]

Initialize self. See help(type(self)) for accurate signature.

__repr__()[source]

Return repr(self).