Ejemplo n.º 1
0
"""

import sys

from pycopia.XML import POM
from pycopia.aid import partial

Text = POM.Text

# Hand-coded DTD elements for plain text. Note that add_text() is the only
# method that makes sense, but is not enforced.

# indicates any content
ANYCONTENT = POM.ContentModel((True, ))  # can contain other nodes

attribClass = POM.XMLAttribute('class', 8, 12, None)
attribHref = POM.XMLAttribute('href', 1, 12, None)
attribLevel = POM.XMLAttribute('level', 1, 12, None)


def check_object(obj):
    if type(obj) in (str, unicode):
        return POM.Text(obj)
    if isinstance(obj, POM.ElementNode):
        return obj
    raise POM.ValidationError, "bad initializer object"


class InlineMixin(object):
    def _init(self, dtd):
        self.dtd = dtd