/documentation/fabmetheus_utilities.xml_simple_reader.html
HTML | 205 lines | 153 code | 52 blank | 0 comment | 0 complexity | a70ea7241a1b94d82d6d8863f9e841e0 MD5 | raw file
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
- <html><head><title>Python: module fabmetheus_utilities.xml_simple_reader</title>
- </head><body bgcolor="#f0f0f8">
- <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
- <tr bgcolor="#7799ee">
- <td valign=bottom> <br>
- <font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="fabmetheus_utilities.html"><font color="#ffffff">fabmetheus_utilities</font></a>.xml_simple_reader</strong></big></big> ($Date: 2008/21/04 $)</font></td
- ><td align=right valign=bottom
- ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/enrique/Desktop/backup/babbleold/script/reprap/fabmetheus/fabmetheus_utilities/xml_simple_reader.py">/home/enrique/Desktop/backup/babbleold/script/reprap/fabmetheus/fabmetheus_utilities/xml_simple_reader.py</a></font></td></tr></table>
- <p><tt>The xml_simple_reader.py script is an xml parser that can parse a line separated xml text.<br>
- <br>
- This xml parser will read a line seperated xml text and produce a tree of the xml with a root element. Each element can have an attribute table, children, a class name, parent, text and a link to the root element.<br>
- <br>
- This example gets an xml tree for the xml file boolean.xml. This example is run in a terminal in the folder which contains boolean.xml and xml_simple_reader.py.<br>
- <br>
- <br>
- > python<br>
- Python 2.5.1 (r251:54863, Sep 22 2007, 01:43:31)<br>
- [GCC 4.2.1 (SUSE Linux)] on linux2<br>
- Type "help", "copyright", "credits" or "license" for more information.<br>
- >>> fileName = 'boolean.xml'<br>
- >>> file = open(fileName, 'r')<br>
- >>> xmlText = file.read()<br>
- >>> file.close()<br>
- >>> from xml_simple_reader import <a href="#XMLSimpleReader">XMLSimpleReader</a><br>
- >>> xmlParser = <a href="#XMLSimpleReader">XMLSimpleReader</a>(fileName, None, xmlText)<br>
- >>> print( xmlParser )<br>
- ?xml, {'version': '1.0'}<br>
- ArtOfIllusion, {'xmlns:bf': '//babelfiche/codec', 'version': '2.0', 'fileversion': '3'}<br>
- Scene, {'bf:id': 'theScene'}<br>
- materials, {'bf:elem-type': 'java.lang.Object', 'bf:list': 'collection', 'bf:id': '1', 'bf:type': 'java.util.Vector'}<br>
- ..<br>
- many more lines of the xml tree<br>
- ..</tt></p>
- <p>
- <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
- <tr bgcolor="#aa55cc">
- <td colspan=3 valign=bottom> <br>
- <font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
-
- <tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
- <td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="__init__.html">__init__</a><br>
- <a href="fabmetheus_utilities.archive.html">fabmetheus_utilities.archive</a><br>
- </td><td width="25%" valign=top><a href="cStringIO.html">cStringIO</a><br>
- <a href="fabmetheus_utilities.euclidean.html">fabmetheus_utilities.euclidean</a><br>
- </td><td width="25%" valign=top><a href="fabmetheus_utilities.geometry.geometry_utilities.evaluate.html">fabmetheus_utilities.geometry.geometry_utilities.evaluate</a><br>
- <a href="fabmetheus_utilities.gcodec.html">fabmetheus_utilities.gcodec</a><br>
- </td><td width="25%" valign=top><a href="fabmetheus_utilities.geometry.geometry_utilities.matrix.html">fabmetheus_utilities.geometry.geometry_utilities.matrix</a><br>
- <a href="fabmetheus_utilities.xml_simple_writer.html">fabmetheus_utilities.xml_simple_writer</a><br>
- </td></tr></table></td></tr></table><p>
- <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
- <tr bgcolor="#ee77aa">
- <td colspan=3 valign=bottom> <br>
- <font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
-
- <tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
- <td width="100%"><dl>
- <dt><font face="helvetica, arial"><a href="fabmetheus_utilities.xml_simple_reader.html#XMLElement">XMLElement</a>
- </font></dt><dt><font face="helvetica, arial"><a href="fabmetheus_utilities.xml_simple_reader.html#XMLSimpleReader">XMLSimpleReader</a>
- </font></dt></dl>
- <p>
- <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
- <tr bgcolor="#ffc8d8">
- <td colspan=3 valign=bottom> <br>
- <font color="#000000" face="helvetica, arial"><a name="XMLElement">class <strong>XMLElement</strong></a></font></td></tr>
-
- <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
- <td colspan=2><tt>An xml element.<br> </tt></td></tr>
- <tr><td> </td>
- <td width="100%">Methods defined here:<br>
- <dl><dt><a name="XMLElement-__init__"><strong>__init__</strong></a>(self)</dt><dd><tt>Add empty lists.</tt></dd></dl>
- <dl><dt><a name="XMLElement-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Get the string representation of this XML element.</tt></dd></dl>
- <dl><dt><a name="XMLElement-addAttribute"><strong>addAttribute</strong></a>(self, beforeQuote, withinQuote)</dt><dd><tt>Add the attribute to the dictionary.</tt></dd></dl>
- <dl><dt><a name="XMLElement-addSuffixToID"><strong>addSuffixToID</strong></a>(self, idSuffix)</dt><dd><tt>Add the suffix to the id.</tt></dd></dl>
- <dl><dt><a name="XMLElement-addToIdentifierDictionaryIFIdentifierExists"><strong>addToIdentifierDictionaryIFIdentifierExists</strong></a>(self)</dt><dd><tt>Add to the id dictionary if the id key exists in the attribute dictionary.</tt></dd></dl>
- <dl><dt><a name="XMLElement-addXML"><strong>addXML</strong></a>(self, depth, output)</dt><dd><tt>Add xml for this xmlElement.</tt></dd></dl>
- <dl><dt><a name="XMLElement-copyXMLChildren"><strong>copyXMLChildren</strong></a>(self, idSuffix, parent)</dt><dd><tt>Copy the xml children.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getCascadeFloat"><strong>getCascadeFloat</strong></a>(self, defaultFloat, key)</dt><dd><tt>Get the cascade float.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getChildrenWithClassName"><strong>getChildrenWithClassName</strong></a>(self, className)</dt><dd><tt>Get the children which have the given class name.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getChildrenWithClassNameRecursively"><strong>getChildrenWithClassNameRecursively</strong></a>(self, className)</dt><dd><tt>Get the children which have the given class name recursively.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getCopy"><strong>getCopy</strong></a>(self, idSuffix, parent)</dt><dd><tt>Copy the xml element, set its dictionary and add it to the parent.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getCopyShallow"><strong>getCopyShallow</strong></a>(self, attributeDictionary<font color="#909090">=None</font>)</dt><dd><tt>Copy the xml element and set its dictionary and parent.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getFirstChildWithClassName"><strong>getFirstChildWithClassName</strong></a>(self, className)</dt><dd><tt>Get the first child which has the given class name.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getIDSuffix"><strong>getIDSuffix</strong></a>(self, elementIndex<font color="#909090">=None</font>)</dt><dd><tt>Get the id suffix from the dictionary.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getImportNameWithDot"><strong>getImportNameWithDot</strong></a>(self)</dt><dd><tt>Get import name with dot.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getParentParseReplacedLine"><strong>getParentParseReplacedLine</strong></a>(self, line, lineStripped, parent)</dt><dd><tt>Parse replaced line and return the parent.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getParser"><strong>getParser</strong></a>(self)</dt><dd><tt>Get the parser.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getPaths"><strong>getPaths</strong></a>(self)</dt><dd><tt>Get all paths.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getPreviousVertex"><strong>getPreviousVertex</strong></a>(self, defaultVector3<font color="#909090">=None</font>)</dt><dd><tt>Get previous vertex if it exists.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getPreviousXMLElement"><strong>getPreviousXMLElement</strong></a>(self)</dt><dd><tt>Get previous <a href="#XMLElement">XMLElement</a> if it exists.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getRoot"><strong>getRoot</strong></a>(self)</dt><dd><tt>Get the root element.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getSubChildWithID"><strong>getSubChildWithID</strong></a>(self, idReference)</dt><dd><tt>Get the child which has the idReference.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getTagKeys"><strong>getTagKeys</strong></a>(self)</dt><dd><tt>Get stripped tag keys.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getValueByKey"><strong>getValueByKey</strong></a>(self, key)</dt><dd><tt>Get value by the key.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getVertexes"><strong>getVertexes</strong></a>(self)</dt><dd><tt>Get the vertexes.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getXMLElementByID"><strong>getXMLElementByID</strong></a>(self, idKey)</dt><dd><tt>Get the xml element by id.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getXMLElementByImportID"><strong>getXMLElementByImportID</strong></a>(self, idKey)</dt><dd><tt>Get the xml element by import file name and id.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getXMLElementsByImportName"><strong>getXMLElementsByImportName</strong></a>(self, name)</dt><dd><tt>Get the xml element by import file name and name.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getXMLElementsByName"><strong>getXMLElementsByName</strong></a>(self, name)</dt><dd><tt>Get the xml elements by name.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getXMLElementsByTag"><strong>getXMLElementsByTag</strong></a>(self, tag)</dt><dd><tt>Get the xml elements by tag.</tt></dd></dl>
- <dl><dt><a name="XMLElement-getXMLProcessor"><strong>getXMLProcessor</strong></a>(self)</dt><dd><tt>Get the xmlProcessor.</tt></dd></dl>
- <dl><dt><a name="XMLElement-linkObject"><strong>linkObject</strong></a>(self, xmlObject)</dt><dd><tt>Link self to xmlObject and add xmlObject to archivableObjects.</tt></dd></dl>
- <dl><dt><a name="XMLElement-printAllVariables"><strong>printAllVariables</strong></a>(self)</dt><dd><tt>Print all variables.</tt></dd></dl>
- <dl><dt><a name="XMLElement-printAllVariablesRoot"><strong>printAllVariablesRoot</strong></a>(self)</dt><dd><tt>Print all variables and the root variables.</tt></dd></dl>
- <dl><dt><a name="XMLElement-removeChildrenFromIDNameParent"><strong>removeChildrenFromIDNameParent</strong></a>(self)</dt><dd><tt>Remove the children from the id and name dictionaries and the children list.</tt></dd></dl>
- <dl><dt><a name="XMLElement-removeFromIDNameParent"><strong>removeFromIDNameParent</strong></a>(self)</dt><dd><tt>Remove this from the id and name dictionaries and the children of the parent.</tt></dd></dl>
- <dl><dt><a name="XMLElement-setParentAddToChildren"><strong>setParentAddToChildren</strong></a>(self, parent)</dt><dd><tt>Set the parent and add this to its children.</tt></dd></dl>
- </td></tr></table> <p>
- <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
- <tr bgcolor="#ffc8d8">
- <td colspan=3 valign=bottom> <br>
- <font color="#000000" face="helvetica, arial"><a name="XMLSimpleReader">class <strong>XMLSimpleReader</strong></a></font></td></tr>
-
- <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
- <td colspan=2><tt>A simple xml parser.<br> </tt></td></tr>
- <tr><td> </td>
- <td width="100%">Methods defined here:<br>
- <dl><dt><a name="XMLSimpleReader-__init__"><strong>__init__</strong></a>(self, fileName, parent, xmlText)</dt><dd><tt>Add empty lists.</tt></dd></dl>
- <dl><dt><a name="XMLSimpleReader-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Get the string representation of this parser.</tt></dd></dl>
- <dl><dt><a name="XMLSimpleReader-getOriginalRoot"><strong>getOriginalRoot</strong></a>(self)</dt><dd><tt>Get the original reparsed root element.</tt></dd></dl>
- <dl><dt><a name="XMLSimpleReader-getRoot"><strong>getRoot</strong></a>(self)</dt><dd><tt>Get the root element.</tt></dd></dl>
- <dl><dt><a name="XMLSimpleReader-parseLine"><strong>parseLine</strong></a>(self, line)</dt><dd><tt>Parse an xml line and add it to the xml tree.</tt></dd></dl>
- </td></tr></table></td></tr></table><p>
- <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
- <tr bgcolor="#eeaa77">
- <td colspan=3 valign=bottom> <br>
- <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
-
- <tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
- <td width="100%"><dl><dt><a name="-addXMLLine"><strong>addXMLLine</strong></a>(line, xmlLines)</dt><dd><tt>Get the all the xml lines of a text.</tt></dd></dl>
- <dl><dt><a name="-getXMLLines"><strong>getXMLLines</strong></a>(text)</dt><dd><tt>Get the all the xml lines of a text.</tt></dd></dl>
- <dl><dt><a name="-getXMLTagSplitLines"><strong>getXMLTagSplitLines</strong></a>(combinedLine)</dt><dd><tt>Get the xml lines split at a tag.</tt></dd></dl>
- </td></tr></table><p>
- <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
- <tr bgcolor="#55aa55">
- <td colspan=3 valign=bottom> <br>
- <font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
-
- <tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
- <td width="100%"><strong>__author__</strong> = 'Enrique Perez (perez_enrique@yahoo.com)'<br>
- <strong>__credits__</strong> = 'Nophead <http://hydraraptor.blogspot.com/><font color="#c040c0">\n</font>Art of Illusion <http://www.artofillusion.org/>'<br>
- <strong>__date__</strong> = '$Date: 2008/21/04 $'<br>
- <strong>__license__</strong> = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'<br>
- <strong>absolute_import</strong> = _Feature((2, 5, 0, 'alpha', 1), (2, 7, 0, 'alpha', 0), 16384)<br>
- <strong>globalGetAccessibleAttributeSet</strong> = set(['getPaths', 'getPreviousVertex', 'getPreviousXMLElement', 'getVertexes', 'parent'])</td></tr></table><p>
- <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
- <tr bgcolor="#7799ee">
- <td colspan=3 valign=bottom> <br>
- <font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr>
-
- <tr><td bgcolor="#7799ee"><tt> </tt></td><td> </td>
- <td width="100%">Enrique Perez (perez_enrique@yahoo.com)</td></tr></table><p>
- <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
- <tr bgcolor="#7799ee">
- <td colspan=3 valign=bottom> <br>
- <font color="#ffffff" face="helvetica, arial"><big><strong>Credits</strong></big></font></td></tr>
-
- <tr><td bgcolor="#7799ee"><tt> </tt></td><td> </td>
- <td width="100%">Nophead <<a href="http://hydraraptor.blogspot.com/">http://hydraraptor.blogspot.com/</a>><br>
- Art of Illusion <<a href="http://www.artofillusion.org/">http://www.artofillusion.org/</a>></td></tr></table>
- </body></html>