Exemple #1
0
 class AdhocElement(Element):
     format_version = Attribute('version')
     name = Text('name-e')
     url = Child('url-e', AdhocTextElement, multiple=True)
     dob = Child('dob-e', AdhocTextElement, xmlns='http://example.com/')
Exemple #2
0
class InspectXmlnsSetElement(Element):

    a = Child('child', XmlnsDoc, xmlns='http://dahlia.kr/')
Exemple #3
0
class ELConsumeBufferRegressionTestDoc(DocumentElement):

    __tag__ = 'a'
    b = Child('b', ELConsumeBufferRegressionTestB, multiple=True)
Exemple #4
0
class TestDoc(DocumentElement):

    __tag__ = 'test'
    attr_attr = Attribute('attr')
    attr_decoder = Attribute('attr-decoder', decoder=lambda s: s.lower())
    attr_decoder_decorator = Attribute('attr-decoder-decorator')
    title_attr = Child('title', TextElement, required=True)
    content_attr = Child('content', TextElement, required=True)
    multi_attr = Child('multi', TextElement, multiple=True)
    sorted_children = Child('s-multi',
                            TextElement,
                            multiple=True,
                            sort_key=lambda e: e.value)
    text_content_attr = Text('text-content')
    text_multi_attr = Text('text-multi', multiple=True)
    sorted_texts = Text('s-text-multi',
                        multiple=True,
                        sort_key=lambda t: t,
                        sort_reverse=True)
    text_decoder = Text('text-decoder', decoder=float, encoder=str)
    text_decoder_decorator = Text('text-decoder-decorator')
    text_combined_decoder = Text('text-combined-decoder',
                                 decoder=int,
                                 encoder=lambda i: i and i / 100)
    ns_element_attr = Child('ns-element',
                            TextElement,
                            xmlns='http://earthreader.github.io/')
    ns_text_attr = Text('ns-text', xmlns='http://earthreader.github.io/')
    content_decoder = Child('content-decoder', TextDecoderElement)

    @attr_decoder_decorator.decoder
    def attr_decoder_decorator(self, value):
        return value[::-1]

    @attr_decoder_decorator.encoder
    def attr_decoder_decorator(self, value):
        return value and value[::-1]

    @text_decoder_decorator.decoder
    def text_decoder_decorator(self, text):
        return int(text[::-1])

    @text_decoder_decorator.encoder
    def text_decoder_decorator(self, value):
        if value is not None:
            return str(value)[::-1]

    @text_combined_decoder.decoder
    def text_combined_decoder(self, value):
        return value * 100

    @text_combined_decoder.decoder
    def text_combined_decoder(self, value):
        return -value

    @text_combined_decoder.encoder
    def text_combined_decoder(self, value):
        if value is not None:
            return -value

    @text_combined_decoder.encoder
    def text_combined_decoder(self, value):
        if value is not None:
            if value % 1 <= 0:
                value = int(value)
            return str(value)
Exemple #5
0
class ELConsumeBufferRegressionTestB(Element):

    c = Child('c', ELConsumeBufferRegressionTestC, multiple=True)
Exemple #6
0
class ELConsumeBufferRegressionTestC(Element):

    d = Child('d', ELConsumeBufferRegressionTestD)
Exemple #7
0
class PartialLoadTestDoc(DocumentElement):

    __tag__ = 'partial-load-test'
    __xmlns__ = 'http://example.com/'
    entry = Child('entry', PartialLoadTestEntry, xmlns=__xmlns__)
Exemple #8
0
class SelfReferentialChild(Element):

    self_ref = Child('self-ref', 'SelfReferentialChild')
Exemple #9
0
class ChildDescriptorConflictElement(Element):

    child = Child('same-tag', TextElement)
    text = Text('same-tag')