This module contains classes for a very simple validation model.
class SIMSWarning(ll.xist.xsc.Warning):
Base class for all warning classes in this module.
class EmptyElementWithContentWarning(SIMSWarning):
Warning that is issued when an element has content, but it shouldn't
(i.e. model is Empty)
def __init__(self, node):
selfdef __str__(self):
selfclass WrongElementWarning(SIMSWarning):
Warning that is issued when an element contains another element of a certain type, but shouldn't.
def __init__(self, node, badnode, elements):
selfdef __str__(self):
selfclass ElementWarning(SIMSWarning):
Warning that is issued when an element contains another element but shouldn't contain any.
def __init__(self, node, badnode):
selfdef __str__(self):
selfclass IllegalTextWarning(SIMSWarning):
Warning that is issued when an element contains a text node but shouldn't.
def __init__(self, node, badnode):
selfdef __str__(self):
selfdef badtext(node):
Return whether node is a text node (i.e. ll.xist.xsc.Text
that does not consist of whitespace only).
class Empty(object):
This validator checks that an element has no content.
def __repr__(self):
selfdef checkvalid(self, node):
selfcheck that the content of node is valid.
class NoElements(object):
This validator checks that an element does not have child elements from the same namespace.
def __repr__(self):
selfdef checkvalid(self, node):
selfcheck that the content of node is valid.
class NoElementsOrText(object):
This validator checks that an element does have neither child elements from the same namespace nor real (i.e. not-whitespace) text nodes.
def __repr__(self):
selfdef checkvalid(self, node):
selfcheck that the content of node is valid.
class Elements(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.
def __init__(self, *elements):
selfEvery 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.
def __repr__(self):
selfdef checkvalid(self, node):
selfcheck that the content of node is valid.
class ElementsOrText(Elements):
This validator checks that an element doesn't have child elements from the same namespace except those specified in the constructor.
def __init__(self, *elements):
selfEvery 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.
def __repr__(self):
selfdef checkvalid(self, node):
selfCheck that the content of node is valid.
class Any(object):
This validator declares any content to be valid.
def __repr__(self):
selfdef checkvalid(self, node):
selfCheck that the content of node is valid. This method does nothing
as anything is valid.