Gsf.XMLOut

g GObject.Object GObject.Object Gsf.XMLOut Gsf.XMLOut GObject.Object->Gsf.XMLOut

Subclasses:

Gsf.ODFOut

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new (output)

add_base64 (id, data)

add_bool (id, val)

add_color (id, r, g, b)

add_cstr (id, val_utf8)

add_cstr_unchecked (id, val_utf8)

add_enum (id, etype, val)

add_float (id, val, precision)

add_gvalue (id, val)

add_int (id, val)

add_uint (id, val)

end_element ()

get_output ()

get_pretty_print ()

set_doc_type (type)

set_pretty_print (pp)

simple_element (id, content)

simple_float_element (id, val, precision)

simple_int_element (id, val)

start_element (id)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

pretty-print

bool

r/w

Should the output auto-indent elements to make reading easier?

sink

Gsf.Output

r/w/co

The destination for writes

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

base

GObject.Object

r

output

Gsf.Output

r

priv

object

r

Class Details

class Gsf.XMLOut(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Gsf.XMLOutClass

classmethod new(output)
Parameters:

output (Gsf.Output) – Gsf.Output

Returns:

Gsf.XMLOut

Return type:

Gsf.XMLOut

Create an XML output stream.

add_base64(id, data)
Parameters:
  • id (str or None) – tag id, or None for node content

  • data (bytes) – Data to be written

Dump len bytes in data into the content of node id using base64

add_bool(id, val)
Parameters:
  • id (str or None) – tag id, or None for node content

  • val (bool) – a boolean

dump boolean value val to an attribute named id or as the nodes content Use ‘1’ or ‘0’ to simplify import

add_color(id, r, g, b)
Parameters:
  • id (str or None) – tag id, or None for node content

  • r (int) – Red value

  • g (int) – Green value

  • b (int) – Blue value

dump Color r.`g`.`b` to an attribute named id or as the nodes content

add_cstr(id, val_utf8)
Parameters:
  • id (str or None) – tag id, or None for node content

  • val_utf8 (str or None) – a utf8 encoded string

dump val_utf8 to an attribute named id or as the nodes content escaping characters as necessary. If val_utf8 is None do nothing (no warning, no output)

add_cstr_unchecked(id, val_utf8)
Parameters:
  • id (str or None) – tag id, or None for node content

  • val_utf8 (str or None) – a utf8 encoded string to export

dump val_utf8 to an attribute named id without checking to see if the content needs escaping. A useful performance enhancement when the application knows that structure of the content well. If val_utf8 is None do nothing (no warning, no output)

add_enum(id, etype, val)
Parameters:

Output the name of value val of enumeration type etype.

add_float(id, val, precision)
Parameters:
  • id (str or None) – tag id, or None for node content

  • val (float) – the value

  • precision (int) – the number of significant digits to use, -1 meaning “enough”.

dump float value val to an attribute named id or as the nodes content with precision precision. The number will be formattted according to the “C” locale.

add_gvalue(id, val)
Parameters:

Output the value of val as a string. Does NOT store any type information with the string, just thevalue.

add_int(id, val)
Parameters:
  • id (str or None) – tag id, or None for node content

  • val (int) – the value

dump integer value val to an attribute named id or as the nodes content

add_uint(id, val)
Parameters:
  • id (str or None) – tag id, or None for node content

  • val (int) – the value

dump unsigned integer value val to an attribute named id or as the nodes content

end_element()
Returns:

the element that has been closed.

Return type:

str

Closes/ends an XML element.

get_output()
Returns:

Gsf.Input

Return type:

Gsf.Output or None

Get the Gsf.Output we are writing to..

get_pretty_print()
Returns:

the current state of the pretty-print flag. Note, that Gsf.XMLOut.set_pretty_print will return the same value.

Return type:

bool

set_doc_type(type)
Parameters:

type (str) – the document type declaration

Store some optional <!DOCTYPE .. > content

set_pretty_print(pp)
Parameters:

pp (bool) – new state of pretty-print flag.

Returns:

the previous state of the pretty-print flag.

Return type:

bool

simple_element(id, content)
Parameters:
  • id (str) – Element name

  • content (str) – Content of the element

Convenience routine to output a simple id element with content content.

simple_float_element(id, val, precision)
Parameters:
  • id (str) – Element name

  • val (float) – Element value

  • precision (int) – the number of significant digits to use, -1 meaning “enough”.

Convenience routine to output an element id with float value val using precision significant digits.

simple_int_element(id, val)
Parameters:
  • id (str) – Element name

  • val (int) – Element value

Convenience routine to output an element id with integer value val.

start_element(id)
Parameters:

id (str) – Element name

Output a start element id, if necessary preceeded by an XML declaration.

Property Details

Gsf.XMLOut.props.pretty_print
Name:

pretty-print

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE

Should the output auto-indent elements to make reading easier?

Gsf.XMLOut.props.sink
Name:

sink

Type:

Gsf.Output

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The destination for writes