Home | Trees | Indices | Help |
|
---|
|
|
|||
XPathTree |
|
|||
|
|||
|
|||
|
|||
|
Imports: etree, base, accepts, Self, IsCallable, IsOneOf, Any, Number
|
Split an xpath component into a tag-index tuple. >>> split_xpath_component('{urn:oasis:names:tc:opendocument:xmlns:office:1.0}document-content[0]') ('{urn:oasis:names:tc:opendocument:xmlns:office:1.0}document-content', 0).
|
Split an 'xpath' string separated by / into a reversed list of its components. Thus: >>> split_xpath('document-content[1]/body[2]/text[3]/p[4]') [('p', 4), ('text', 3), ('body', 2), ('document-content', 1)] The list is reversed so that it can be used as a stack, where the top of the stack is the first component.
|
Walk down the tree rooted a node, and follow nodes which correspond to the components of xpath_components. When reaching the end of xpath_components, set the reference of the node to unit. With reference to the tree diagram in build_unit_tree: add_unit_to_tree(node, [('p', 2), ('text', 3), ('body', 2), ('document-content', 1)], unit) would begin by popping ('document-content', 1) from the path and following the node marked ('document-content', 1) in the tree. Likewise, will descend down the nodes marked ('body', 2) and ('text', 3). Since the node marked ('text', 3) has no child node marked ('p', 2), this node is created. Then the add_unit_to_tree descends down this node. When this happens, there are no xpath components left to pop. Thus, node.unit = unit is executed.
|
Enumerate a translation store and build a tree with XPath components as nodes and where a node contains a unit if a path from the root of the tree to the node containing the unit, is equal to the XPath of the unit. The tree looks something like this: root `- ('document-content', 1) `- ('body', 2) |- ('text', 1) | `- ('p', 1) | `- <reference to a unit> |- ('text', 2) | `- ('p', 1) | `- <reference to a unit> `- ('text', 3) `- ('p', 1) `- <reference to a unit>
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Thu Oct 15 13:53:52 2009 | http://epydoc.sourceforge.net |