Home | Trees | Index | Help |
|
---|
Package CedarBackup2 :: Module xmlutil |
|
Provides general XML-related functionality.
What I'm trying to do here is abstract much of the functionality that directly accesses the DOM tree. This is not so much to "protect" the other code from the DOM, but to standardize the way it's used. It will also help extension authors write code that easily looks more like the rest of Cedar Backup.Author: Kenneth J. Pronovici <pronovic@ieee.org>
Classes | |
---|---|
Serializer |
XML serializer class. |
Function Summary | |
---|---|
Creates a DOM tree based on reading an XML string. | |
Creates a DOM tree used for writing an XML document. | |
Serializes a DOM tree and returns the result in a string. | |
Returns True or False depending on whether the XML node is an element node. | |
Returns a list of nodes with a given name immediately beneath the parent. | |
Returns the first child with a given name immediately beneath the parent. | |
Returns a list of the string contents associated with nodes with a given name immediately beneath the parent. | |
Returns string contents of the first child with a given name immediately beneath the parent. | |
Returns integer contents of the first child with a given name immediately beneath the parent. | |
Returns boolean contents of the first child with a given name immediately beneath the parent. | |
Adds a container node as the next child of a parent node. | |
Adds a text node as the next child of a parent, to contain a string. | |
Adds a text node as the next child of a parent, to contain an integer. | |
Adds a text node as the next child of a parent, to contain a boolean. | |
| |
| |
Handles normalization and some intelligence about quoting. |
Variable Summary | |
---|---|
list |
TRUE_BOOLEAN_VALUES : List of boolean values in XML representing True . |
list |
FALSE_BOOLEAN_VALUES : List of boolean values in XML representing False . |
list |
VALID_BOOLEAN_VALUES : List of valid boolean values in XML. |
Logger |
logger = <logging.Logger instance at 0x4054e50c>
|
Function Details |
---|
createInputDom(xmlData, name='cb_config')Creates a DOM tree based on reading an XML string.
|
createOutputDom(name='cb_config')Creates a DOM tree used for writing an XML document.
|
serializeDom(xmlDom, indent=3)Serializes a DOM tree and returns the result in a string.
|
isElement(node)Returns True or False depending on whether the XML node is an element node. |
readChildren(parent, name)Returns a list of nodes with a given name immediately beneath the parent. By "immediately beneath" the parent, we mean from among nodes that are direct children of the passed-in parent node. Underneath, we use the PythongetElementsByTagName
method, which is pretty cool, but which (surprisingly?) returns a list
of all children with a given name below the parent, at any level. We
just prune that list to include only children whose
parentNode matches the passed-in parent.
|
readFirstChild(parent, name)Returns the first child with a given name immediately beneath the parent. By "immediately beneath" the parent, we mean from among nodes that are direct children of the passed-in parent node.
|
readStringList(parent, name)Returns a list of the string contents associated with nodes with a given name immediately beneath the parent. By "immediately beneath" the parent, we mean from among nodes that are direct children of the passed-in parent node. First, we find all of the nodes usingreadChildren , and then we retrieve the
"string contents" of each of those nodes. The returned list
has one entry per matching node. We assume that string contents of a
given node belong to the first TEXT_NODE child of that
node. Nodes which have no TEXT_NODE children are not
represented in the returned list.
|
readString(parent, name)Returns string contents of the first child with a given name immediately beneath the parent. By "immediately beneath" the parent, we mean from among nodes that are direct children of the passed-in parent node. We assume that string contents of a given node belong to the firstTEXT_NODE child of that node.
|
readInteger(parent, name)Returns integer contents of the first child with a given name immediately beneath the parent. By "immediately beneath" the parent, we mean from among nodes that are direct children of the passed-in parent node.
|
readBoolean(parent, name)Returns boolean contents of the first child with a given name immediately beneath the parent. By "immediately beneath" the parent, we mean from among nodes that are direct children of the passed-in parent node. The string value of the node must be one of the values inVALID_BOOLEAN_VALUES .
|
addContainerNode(xmlDom, parentNode, nodeName)Adds a container node as the next child of a parent node.
|
addStringNode(xmlDom, parentNode, nodeName, nodeValue)Adds a text node as the next child of a parent, to contain a string. If thenodeValue is None, then the node will be
created, but will be empty (i.e. will contain no text node child).
|
addIntegerNode(xmlDom, parentNode, nodeName, nodeValue)Adds a text node as the next child of a parent, to contain an integer. If the addStringNode .
|
addBooleanNode(xmlDom, parentNode, nodeName, nodeValue)Adds a text node as the next child of a parent, to contain a boolean. If the True , or anything else interpreted as
True by Python, will be converted to a string
"Y". Anything else will be converted to a string
"N". The result is added to the document via addStringNode .
|
_encodeText(text, encoding)
|
_translateCDATA(characters, encoding='UTF-8', prev_chars='', markupSafe=0)
|
_translateCDATAAttr(characters)Handles normalization and some intelligence about quoting.
|
Variable Details |
---|
TRUE_BOOLEAN_VALUESList of boolean values in XML representingTrue .
|
FALSE_BOOLEAN_VALUESList of boolean values in XML representingFalse .
|
VALID_BOOLEAN_VALUESList of valid boolean values in XML.
|
logger
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Mon Dec 18 22:53:30 2006 | http://epydoc.sf.net |