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.

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.

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.

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.

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.

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.

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.

validate(path)[source]

Check that the content of node is valid.

class ll.xist.sims.Empty[source]

Bases: object

This validator checks that an element has no content.

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)

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.

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

exception ll.xist.sims.SIMSWarning[source]

Bases: ll.xist.xsc.Warning

Base class for all warning classes in this module.

class ll.xist.sims.Transparent[source]

Bases: object

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

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.

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).