class TestMergeableDoc(MergeableDocumentElement): __tag__ = 'merge-test' multi_text = Text('multi-text', multiple=True) text = Text('text') attr = Attribute('attr') unique_entities = Child('unique-entity', TestUniqueEntity, multiple=True) rev_entities = Child('rev-multi-entity', TestRevisedEntity, multiple=True) rev_entity = Child('rev-single-entity', TestRevisedEntity) nullable = Child('nullable-entity', TestUniqueEntity)
class VTElement(Element): req_attr = Attribute('a', required=True) attr = Attribute('b') req_child = Child('c', TextElement, required=True) child = Child('d', TextElement) def __repr__(self): return 'VTElement(req_attr={0!r}, req_child={1!r})'.format( self.req_attr, self.req_child)
class VTElement(Element): req_attr = Attribute('a', required=True) attr = Attribute('b') req_child = Child('c', TextElement, required=True) child = Child('d', TextElement) req_text = Text('e', required=True) text = Text('f') def __repr__(self): fmt = 'VTElement(req_attr={0!r}, req_child={1!r}, req_text={2!r})' return fmt.format(self.req_attr, self.req_child, self.req_text)
class VTDoc(DocumentElement): __tag__ = 'vtest' req_attr = Attribute('a', required=True) attr = Attribute('b') req_child = Child('c', VTElement, required=True) child = Child('d', VTElement) multi = Child('e', VTElement, multiple=True) def __repr__(self): return 'VTDoc(req_attr={0!r}, req_child={1!r})'.format( self.req_attr, self.req_child)
class VTDoc(DocumentElement): __tag__ = 'vtest' req_attr = Attribute('a', required=True) attr = Attribute('b') req_child = Child('c', VTElement, required=True) child = Child('d', VTElement) multi = Child('e', VTElement, multiple=True) req_text = Text('f', required=True) text = Text('g') def __repr__(self): fmt = 'VTDoc(req_attr={0!r}, req_child={1!r}, req_text={2!r})' return fmt.format(self.req_attr, self.req_child, self.req_text)
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)
class SelfReferentialChild(Element): self_ref = Child('self-ref', 'SelfReferentialChild')
class ChildDescriptorConflictElement(Element): child = Child('same-tag', TextElement) text = Text('same-tag')
class InspectXmlnsSetElement(Element): a = Child('child', XmlnsDoc, xmlns='http://dahlia.kr/')
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/')
class ELConsumeBufferRegressionTestDoc(DocumentElement): __tag__ = 'a' b = Child('b', ELConsumeBufferRegressionTestB, multiple=True)
class ELConsumeBufferRegressionTestB(Element): c = Child('c', ELConsumeBufferRegressionTestC, multiple=True)
class ELConsumeBufferRegressionTestC(Element): d = Child('d', ELConsumeBufferRegressionTestD)
class PartialLoadTestDoc(DocumentElement): __tag__ = 'partial-load-test' __xmlns__ = 'http://example.com/' entry = Child('entry', PartialLoadTestEntry, xmlns=__xmlns__)