Package qm :: Module xmlutil
[hide private]
[frames] | no frames]

Module xmlutil

source code

Functions [hide private]
 
make_public_id(name)
Return a public ID for the DTD with the given 'name'.
source code
 
make_system_id(name)
Return a system ID for the DTD with the given 'name'.
source code
 
load_xml_file(path)
Return a DOM document loaded from the XML file 'path'.
source code
 
load_xml(file)
Return a DOM document loaded from the XML file object 'file'.
source code
 
get_dom_text(node)
Return the text contained in DOM 'node'.
source code
 
child_tag_predicate(child_tag)
Return a predicate function for finding element nodes by tag.
source code
 
get_child(node, child_tag)
Return the child element node of 'node' whose tag is 'child_tag'.
source code
 
get_child_text(node, child_tag, default=None)
Return the text contained in a child of DOM 'node'.
source code
 
get_child_texts(node, child_tag)
Return a sequence of text contents of children.
source code
 
create_dom_text_element(document, tag, text)
Return a DOM element containing a single text node.
source code
 
create_dom_document(public_id, document_element_tag)
Create a DOM document.
source code
 
__hyphen_replacement(match) source code
 
sanitize_text_for_comment(text)
Return 'text' modified so that it is valid for an XML comment.
source code
Variables [hide private]
  __dom_implementation = xml.dom.minidom.getDOMImplementation()
  __hyphen_regex = re.compile(r'(--+)')
  __package__ = 'qm'
Function Details [hide private]

make_public_id(name)

source code 

Return a public ID for the DTD with the given 'name'.

'name' -- The name of the DTD.

returns -- A public ID for the DTD.

make_system_id(name)

source code 

Return a system ID for the DTD with the given 'name'.

'name' -- The name of the DTD, as a relative UNIX path.

returns -- A URL for the DTD.

load_xml(file)

source code 

Return a DOM document loaded from the XML file object 'file'.

'file' -- A file object, opened for reading.

returns -- The DOM document contained in 'file'.

This function closes 'file', whether or not reading the document was successful.

get_dom_text(node)

source code 

Return the text contained in DOM 'node'.

'node' -- A DOM element node.

prerequisites -- 'node' is an element node with exactly one child, which is a text node.

child_tag_predicate(child_tag)

source code 

Return a predicate function for finding element nodes by tag.

returns -- A predicate function that takes a node as its argument and returns true if the node is an element node whose tag is 'child_tag'.

get_child(node, child_tag)

source code 

Return the child element node of 'node' whose tag is 'child_tag'.

'node' -- A DOM node. It must have exactly one element child with the tag 'child_tag'.

'child_tag' -- The desired element tag.

returns -- A child DOM node of 'node'.

raises -- 'KeyError' if 'node' has no element child with tag 'child_tag', or more than one..

get_child_text(node, child_tag, default=None)

source code 

Return the text contained in a child of DOM 'node'.

'child_tag' -- The tag of the child node whose text is to be retrieved.

'default' -- If 'node' has no child element with tag 'child_tag', returns 'default', unless 'default' is 'None'.

raises -- 'KeyError' if 'default' is 'None' and 'node' has no child element with tag 'child_tag'.

get_child_texts(node, child_tag)

source code 

Return a sequence of text contents of children.

'node' -- A DOM node.

returns -- The list containing all child nodes of 'node' which have tag 'child_tag'. Each child must have exactly one child of its own, which must be a text node.

create_dom_text_element(document, tag, text)

source code 

Return a DOM element containing a single text node.

'document' -- The containing DOM document.

'tag' -- The element tag.

'text' -- The text contents of the text node.

create_dom_document(public_id, document_element_tag)

source code 

Create a DOM document.

'public_id' -- The (partial) public ID for the DTD.

'document_element_tag' -- The tag of the main document element.

returns -- A DOM document node.