Ejemplo n.º 1
0
def statement_unicode (model, prefixes, encoding='ASCII'):
        e, children = pns_to_xml_unicode (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_unicode.xml_prefix_FQN (
                                                unicode (name, 'utf-8'), 
                                                prefixes, encoding
                                                )),
                                        xml_unicode.xml_attr (
                                                unicode (subject, 'utf-8'), 
                                                encoding
                                                )
                                        ))
                        else:
                                e.xml_children.append (
                                        '<%s%s'
                                        ' />' % xml_unicode.xml_prefix_FQN (
                                                unicode (name, 'utf-8'), 
                                                prefixes, encoding
                                                )
                                        )
        return xml_unicode.xml_prefixed (
                e, prefixes, 
                ' context="%s"' % xml_unicode.xml_attr (
                        unicode (model[3], 'utf-8'), encoding
                        ), encoding
                )
Ejemplo n.º 2
0
def xml_producer_unicode (
        root, prefixes, 
        pi=None, encoding='ASCII', globbing=16384
        ):
        head = '<?xml version="1.0" encoding="%s"?>' % encoding
        if pi:
                head += xml_unicode.xml_pi (pi, encoding)
        return producer.Composite (
                head, xml_unicode.xml_prefixed (
                        root, prefixes, xml_unicode.xml_ns (prefixes), 
                        encoding
                        ), globbing
                )
Ejemplo n.º 3
0
def statement_unicode(model, prefixes, encoding='ASCII'):
    e, children = pns_to_xml_unicode(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_unicode.xml_prefix_FQN(unicode(name, 'utf-8'),
                                                   prefixes, encoding)),
                     xml_unicode.xml_attr(unicode(subject, 'utf-8'),
                                          encoding)))
            else:
                e.xml_children.append(
                    '<%s%s'
                    ' />' % xml_unicode.xml_prefix_FQN(unicode(name, 'utf-8'),
                                                       prefixes, encoding))
    return xml_unicode.xml_prefixed(
        e, prefixes, ' context="%s"' %
        xml_unicode.xml_attr(unicode(model[3], 'utf-8'), encoding), encoding)