def xml_producer_utf8 (root, prefixes, pi=None, globbing=16384):
        head = '<?xml version="1.0" encoding="UTF-8"?>'
        if pi:
                head += xml_utf8.xml_pi (pi)
        return producer.Composite (
                head, xml_utf8.xml_prefixed (
                        root, prefixes, xml_utf8.xml_ns (prefixes)
                        ), globbing
                )
Example #2
0
def statement_utf8(model, prefixes):
    e, children = pns_to_xml_utf8(model)
    if children:
        e.xml_children = []
        for child in netstring.decode(children):
            subject, name = netstring.decode(child)
            if subject:
                e.xml_children.append(
                    '<%s pns="%s"/>' %
                    (''.join(xml_utf8.xml_prefix_FQN(
                        name, prefixes)), xml_utf8.xml_attr(subject)))
            else:
                e.xml_children.append('<%s />' %
                                      xml_utf8.xml_prefix_FQN(name, prefixes))
    return xml_utf8.xml_prefixed(e, prefixes,
                                 ' context="%s"' % xml_utf8.xml_attr(model[3]))
Example #3
0
def statement_utf8 (model, prefixes):
        e, children = pns_to_xml_utf8 (model)
        if children:
                e.xml_children = []
                for child in netstring.decode (children):
                        subject, name = netstring.decode (child)
                        if subject:
                                e.xml_children.append ('<%s pns="%s"/>' % (
                                        ''.join (xml_utf8.xml_prefix_FQN (
                                                name, prefixes
                                                )),
                                        xml_utf8.xml_attr (subject)
                                        ))
                        else:
                                e.xml_children.append (
                                        '<%s />' % xml_utf8.xml_prefix_FQN (
                                                name, prefixes
                                                )
                                        )
        return xml_utf8.xml_prefixed (
                e, prefixes, 
                ' context="%s"' % xml_utf8.xml_attr (model[3])
                )