Home | Trees | Indices | Help |
|
---|
|
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
Imports: etree, base, accepts, IsCallable, Any, misc, extract, unit_tree, XmlNamer
|
Return a dictionary indexed by child tag names, where each tag is associated with an array of all the child nodes with matching the tag name, in the order in which they appear as children of dom_node. >>> xml = '<a><b></b><c></c><b></b><d/></a>' >>> element = etree.fromstring(xml) >>> get_tag_arrays(element) {'b': [<Element a at 84df144>, <Element a at 84df148>], 'c': [<Element a at 84df120>], 'd': [<Element a at 84df152>]}
|
|
|
See Also: find_placeable_dom_tree_roots |
For an inline placeable, find the root DOM node for the placeable in its parent. Consider the diagram. In this pseudo-ODF example, there is an inline span element. However, the span is contained in other tags (which we never process). When splicing the template DOM tree (that is, the DOM which comes from the XML document we're using to generate a translated XML document), we'll need to move DOM sub-trees around and we need the roots of these sub-trees: <p> This is text \/ <- Paragraph containing an inline placeable <blah> <- Inline placeable's root (which we want to find) ... <- Any number of intermediate DOM nodes <span> bold text <- The inline placeable's Translatable holds a reference to this DOM node
|
Creating a mapping from the DOM nodes in source_dom_node which correspond to placeables, with DOM nodes in the XML document template (this information is obtained from unit_node). We are interested in DOM nodes in the XML document template which are the roots of placeables. See the diagram below, as well as find_placeable_dom_tree_roots. XLIFF Source (below): <source>This is text <g> bold text</g> and a footnote<x/></source> / \________ / \ <p>This is text<blah>...<span> bold text</span>...</blah> and <note>...</note></p> Input XML document used as a template (above) In the above diagram, the XLIFF source DOM node <g> is associated with the XML document DOM node <blah>, whereas the XLIFF source DOM node <x> is associated with the XML document DOM node <note>.
|
Associate placeables in source_dom_node and target_dom_node which have the same 'id' attributes. We're using XLIFF placeables. The XLIFF standard requires that placeables have unique ids. The id of a placeable is never modified, which means that even if placeables are moved around in a translation, we can easily associate placeables from the source text with placeables in the target text. This function does exactly that.
|
Convenience function to get node corresponding to 'target_node' and to assign the tail text of 'target_node' to this node.
|
Use the "shape" of 'target_node' (which is a DOM tree) to insert nodes into the DOM tree rooted at 'dom_node'. The mapping 'target_dom_to_doc_dom' is used to map nodes from 'target_node' to nodes which much be inserted into dom_node.
|
Return a function: action: etree_Element x base.TranslationUnit -> None which takes a dom_node and a translation unit. The dom_node is rearranged according to rearrangement of placeables in unit.target (relative to their positions in unit.source).
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Mar 3 16:35:57 2010 | http://epydoc.sourceforge.net |