Example #1
0
    if e.xml_follow:
        e.xml_follow = unicode(e.xml_follow, 'utf-8')
    else:
        e.xml_follow = None


if __name__ == '__main__':
    import os, sys, time
    sys.stderr.write('Allegra XML/UTF-8 Validator'
                     ' - Copyright 2005 Laurent A.V. Szyster\n')
    if os.name == 'nt':
        allegra_time = time.clock
    else:
        allegra_time = time.time

    def more():
        return sys.stdin.read(4096)

    t_parse = allegra_time()
    dom = xml_dom.parse_more(more, unicoding=0)
    t_parsed = allegra_time() - t_parse
    sys.stderr.write('loaded in %f sec:\n\n' % t_parsed)
    if dom.xml_root != None:
        t_serialize = allegra_time()
        data = xml_document(dom.xml_root, dom)
        t_serialized = allegra_time() - t_serialize
        sys.stdout.write(data)
        sys.stderr.write('\n\nserialized in %f sec\n' % t_serialized)
    if dom.xml_error:
        sys.stderr.write('%s\n' % dom.xml_error)
Example #2
0
        if e.xml_follow:
                e.xml_follow = unicode (e.xml_follow, 'utf-8')
        else:
                e.xml_follow = None


if __name__ == '__main__':
        import os, sys, time
        sys.stderr.write (
                'Allegra XML/UTF-8 Validator'
                ' - Copyright 2005 Laurent A.V. Szyster\n'
                )
        if os.name == 'nt':
                allegra_time = time.clock
        else:
                allegra_time = time.time
        def more ():
                return sys.stdin.read (4096)
        t_parse = allegra_time ()
        dom = xml_dom.parse_more (more, unicoding=0)
        t_parsed = allegra_time () - t_parse
        sys.stderr.write ('loaded in %f sec:\n\n' % t_parsed)
        if dom.xml_root != None:
                t_serialize = allegra_time () 
                data = xml_document (dom.xml_root, dom)
                t_serialized = allegra_time () - t_serialize
                sys.stdout.write (data)
                sys.stderr.write ('\n\nserialized in %f sec\n' % t_serialized)
        if dom.xml_error:
                sys.stderr.write ('%s\n' % dom.xml_error)
    sys.stderr.write('Allegra XML/UNICODE Validator'
                     ' - Copyright 2005 Laurent A.V. Szyster\n')
    if os.name == 'nt':
        allegra_time = time.clock
    else:
        allegra_time = time.time
    if len(sys.argv) > 1:
        encoding = sys.argv[1]
    else:
        encoding = 'ASCII'

    def more():
        return sys.stdin.read(4096)

    t_parse = allegra_time()
    dom = xml_dom.parse_more(more)
    t_parsed = allegra_time() - t_parse
    sys.stderr.write('loaded in %f sec\n\n' % t_parsed)
    if dom.xml_root != None:
        t_serialize = allegra_time()
        data = xml_document(dom.xml_root, dom, encoding)
        t_serialized = allegra_time() - t_serialize
        sys.stdout.write(data)
        sys.stderr.write('\n\nserialized in %f sec\n' % t_serialized)
    if dom.xml_error:
        sys.stderr.write('%s\n' % dom.xml_error)

# Note about this implementation
#
# This is, quite litteraly, a transcription of the interfaces and algorithms
# found in xml_utf8.py but for an UNICODE output of the XML parser.
        sys.stderr.write (
                'Allegra XML/UNICODE Validator'
                ' - Copyright 2005 Laurent A.V. Szyster\n'
                )
        if os.name == 'nt':
                allegra_time = time.clock
        else:
                allegra_time = time.time
        if len (sys.argv) > 1:
                encoding = sys.argv[1]
        else:
                encoding = 'ASCII'
        def more ():
                return sys.stdin.read (4096)
        t_parse = allegra_time ()
        dom = xml_dom.parse_more (more)
        t_parsed = allegra_time () - t_parse
        sys.stderr.write ('loaded in %f sec\n\n' % t_parsed)
        if dom.xml_root != None:
                t_serialize = allegra_time () 
                data = xml_document (dom.xml_root, dom, encoding)
                t_serialized = allegra_time () - t_serialize
                sys.stdout.write (data)
                sys.stderr.write ('\n\nserialized in %f sec\n' % t_serialized)
        if dom.xml_error:
                sys.stderr.write ('%s\n' % dom.xml_error)
                
                
# Note about this implementation
#
# This is, quite litteraly, a transcription of the interfaces and algorithms