(xml_data=None, *, out=None, from_file=None, **options)
return sio.getvalue() if sio is not None else None
Convert XML to its C14N 2.0 serialised form.

    If *out* is provided, it must be a file or file-like object that receives
    the serialised canonical XML output (text, not bytes) through its ``.write()``
    method.  To write to a file, open it in text mode with encoding "utf-8".
    If *out* is not provided, this function returns the output as text string.

    Either *xml_data* (an XML string) or *from_file* (a file path or
    file-like object) must be provided as input.

    The configuration options are the same as for the ``C14NWriterTarget``.
Convert XML to its C14N 2.0 serialised form.
Convert XML to its C14N 2 . 0 serialised form .
def canonicalize(xml_data=None, *, out=None, from_file=None, **options):
    """Convert XML to its C14N 2.0 serialised form.

    If *out* is provided, it must be a file or file-like object that receives
    the serialised canonical XML output (text, not bytes) through its ``.write()``
    method.  To write to a file, open it in text mode with encoding "utf-8".
    If *out* is not provided, this function returns the output as text string.

    Either *xml_data* (an XML string) or *from_file* (a file path or
    file-like object) must be provided as input.

    The configuration options are the same as for the ``C14NWriterTarget``.
    """
    if xml_data is None and from_file is None:
        raise ValueError("Either 'xml_data' or 'from_file' must be provided as input")
    sio = None
    if out is None:
        sio = out = io.StringIO()

    parser = XMLParser(target=C14NWriterTarget(out.write, **options))

    if xml_data is not None:
        parser.feed(xml_data)
        parser.close()
    elif from_file is not None:
        parse(from_file, parser=parser)

    return sio.getvalue() if sio is not None else None
def canonicalize ( xml_data = None , * , out = None , from_file = None , * * options ) : if xml_data is None and from_file is None : raise ValueError ( "Either 'xml_data' or 'from_file' must be provided as input" ) sio = None if out is None : sio = out = io . StringIO ( ) parser = XMLParser ( target = C14NWriterTarget ( out . write , * * options ) ) if xml_data is not None : parser . feed ( xml_data ) parser . close ( ) elif from_file is not None : parse ( from_file , parser = parser ) return sio . getvalue ( ) if sio is not None else None