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: Warning

Base class for all warning classes in this module.

exception ll.xist.sims.EmptyElementWithContentWarning[source]

Bases: SIMSWarning

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

exception ll.xist.sims.WrongElementWarning[source]

Bases: SIMSWarning

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

exception ll.xist.sims.ElementWarning[source]

Bases: SIMSWarning

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

exception ll.xist.sims.IllegalTextWarning[source]

Bases: SIMSWarning

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

exception ll.xist.sims.AnyWarning[source]

Bases: SIMSWarning

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

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.

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.

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.

validate(path)[source]

check that the content of node is valid.

class ll.xist.sims.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.

validate(path)[source]

check that the content of node is valid.

class ll.xist.sims.ElementsOrText[source]

Bases: 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.

validate(path)[source]

Check that the content of node is valid.

class ll.xist.sims.NotElements[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.

class ll.xist.sims.All[source]

Bases: object

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

class ll.xist.sims.Any[source]

Bases: object

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