Commit a714b001 authored by Nicolas Delaby's avatar Nicolas Delaby

Initial release of xupdate_processor implemented in SAX with help of lxml.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils/xupdate_processor@31007 20353a03-c40f-0410-a6d1-a30d3c3de9de
parents
[buildout]
installed_develop_eggs = /home/nicolas/my_libs/xupdate_processor/develop-eggs/xupdate-processor.egg-link
parts = test
[test]
__buildout_installed__ = /home/nicolas/my_libs/xupdate_processor/parts/test
/home/nicolas/my_libs/xupdate_processor/bin/test
__buildout_signature__ = zc.recipe.testrunner-1.2.0-py2.4.egg zc.recipe.egg-1.2.2-py2.4.egg setuptools-0.6c9-py2.4.egg zope.testing-3.8.3-py2.4.egg zc.buildout-1.2.1-py2.4.egg zope.interface-3.5.2-py2.4-linux-i686.egg zope.exceptions-3.5.2-py2.4.egg
_b = /home/nicolas/my_libs/xupdate_processor/bin
_d = /home/nicolas/my_libs/xupdate_processor/develop-eggs
_e = /home/nicolas/.eggs
bin-directory = /home/nicolas/my_libs/xupdate_processor/bin
develop-eggs-directory = /home/nicolas/my_libs/xupdate_processor/develop-eggs
eggs = xupdate_processor
eggs-directory = /home/nicolas/.eggs
executable = /usr/bin/python2.4
initialization = from shutil import copy2; from glob import glob; [copy2(f, '../../parts/test/%s' % f.split('/')[-1]) for f in glob('../../*.xml')]
location = /home/nicolas/my_libs/xupdate_processor/parts/test
recipe = zc.recipe.testrunner
script = /home/nicolas/my_libs/xupdate_processor/bin/test
[buildout]
installed_develop_eggs = /home/nicolas/my_libs/xupdate_processor/develop-eggs/xupdate-processor.egg-link
[buildout]
parts = test
Documentation for xuproc
================================================
1. update text nodes
>>> from xupdate_processor import applyXUpdate
>>> from lxml import etree
>>> from cStringIO import StringIO
>>> xml_doc_string = """<?xml version="1.0"?>
... <erp5>
... <object portal_type="Test">
... <title>A</title>
... </object>
... <object portal_type="Test">
... <title>A</title>
... </object>
... <object portal_type="Test">
... <title>A</title>
... </object>
... </erp5>
... """
>>> xml_xu_string = """<?xml version="1.0"?>
... <xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
... <xupdate:update select="/erp5/object[2]/title">B</xupdate:update>
... <xupdate:update select="/erp5/object[3]/title">C</xupdate:update>
... </xupdate:modifications>
... """
>>> result_tree = applyXUpdate(xml_xu_string=xml_xu_string, xml_doc_string=xml_doc_string)
>>> print etree.tostring(result_tree, pretty_print=1)
<erp5>
<object portal_type="Test">
<title>A</title>
</object>
<object portal_type="Test">
<title>B</title>
</object>
<object portal_type="Test">
<title>C</title>
</object>
</erp5>
2. Update Text Node with special chars and entities
>>> xml_doc_string = """
... <erp5>
... <object portal_type="Person" id="313730">
... <description type="text">description1 --- $sdfr&#231;_sdfs&#231;df_oisfsopf</description>
... <first_name type="string">Kamada</first_name>
... <last_name type="string">Kamada</last_name>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:24.700 GMT+9</time>
... </workflow_action>
... </object>
... </erp5>
... """
>>> xml_xu_string = """
... <xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
... <xupdate:update select="/erp5/object[@id='313730']/description">description3 çsdf__sdfççç_df___&amp;amp;&amp;amp;é]]]°°°°°°</xupdate:update>
... <xupdate:update select="/erp5/object[@id='313730']/first_name">Tatuya</xupdate:update>
... <xupdate:update select="/erp5/object[@id='313730']/workflow_action[@id='edit_workflow']/time">2009/08/28 19:12:24.703 GMT+9</xupdate:update>
... </xupdate:modifications>"""
>>> result_tree = applyXUpdate(xml_xu_string=xml_xu_string, xml_doc_string=xml_doc_string)
>>> print etree.tostring(result_tree, pretty_print=1)
<erp5>
<object portal_type="Person" id="313730">
<description type="text">description3 &#231;sdf__sdf&#231;&#231;&#231;_df___&amp;amp;&amp;amp;&#233;]]]&#176;&#176;&#176;&#176;&#176;&#176;</description>
<first_name type="string">Tatuya</first_name>
<last_name type="string">Kamada</last_name>
<workflow_action id="edit_workflow">
<time type="date">2009/08/28 19:12:24.703 GMT+9</time>
</workflow_action>
</object>
</erp5>
3. update two date element which have same id
>>> xml_doc_string = """
... <erp5>
... <object portal_type="Person" id="313730">
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:40.550 GMT+9</time>
... </workflow_action>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:40.903 GMT+9</time>
... </workflow_action>
... <workflow_action id="edit_workflow">
... <time type="date">2009/08/28 19:12:40.907 GMT+9</time>
... </workflow_action>
... </object>
... </erp5>
... """
>>> xml_xu_string = """
... <xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
... <xupdate:update select="/erp5/object[@id='313730']/workflow_action[@id='edit_workflow'][2]/time">2009/08/28 19:12:40.905 GMT+9</xupdate:update>
... <xupdate:update select="/erp5/object[@id='313730']/workflow_action[@id='edit_workflow'][3]/time">2009/08/28 19:12:40.910 GMT+9</xupdate:update>
... </xupdate:modifications>
... """
>>> result_tree = applyXUpdate(xml_xu_string=xml_xu_string, xml_doc_string=xml_doc_string)
>>> print etree.tostring(result_tree, pretty_print=1)
<erp5>
<object portal_type="Person" id="313730">
<workflow_action id="edit_workflow">
<time type="date">2009/08/28 19:12:40.550 GMT+9</time>
</workflow_action>
<workflow_action id="edit_workflow">
<time type="date">2009/08/28 19:12:40.905 GMT+9</time>
</workflow_action>
<workflow_action id="edit_workflow">
<time type="date">2009/08/28 19:12:40.910 GMT+9</time>
</workflow_action>
</object>
</erp5>
4. insert and remove elements
>>> xml_doc_string = """
... <erp5>
... <object portal_type="Person" id="313731">
... <local_role type="tokens" id="tk">&lt;?xml version="1.0"?&gt;&lt;marshal&gt;&lt;tuple&gt;&lt;string&gt;Manager&lt;/string&gt;&lt;string&gt;Owner&lt;/string&gt;&lt;/tuple&gt;&lt;/marshal&gt;</local_role>
... <local_permission type="tokens" id="Access contents information">&lt;?xml version="1.0"?&gt;</local_permission>
... <local_permission type="tokens" id="Add portal content">&lt;?xml version="1.0"?&gt;</local_permission>
... <local_permission type="tokens" id="View">&lt;?xml version="1.0"?&gt;</local_permission>
... </object>
... </erp5>
... """
>>> xml_xu_string = """
... <xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
... <xupdate:remove select="/erp5/object[@id='313731']/local_role[@id='tk']"/>
... <xupdate:append select="/erp5/object[@id='313731']" child="first()">
... <xupdate:element name="local_role"><xupdate:attribute name="type">tokens</xupdate:attribute><xupdate:attribute name="id">tatuya</xupdate:attribute>&lt;?xml version="1.0"?&gt;&lt;marshal&gt;&lt;tuple&gt;&lt;string&gt;Owner&lt;/string&gt;&lt;/tuple&gt;&lt;/marshal&gt;</xupdate:element>
... <xupdate:element name="JohnDoe">Go to the beach</xupdate:element>
... </xupdate:append>
... <xupdate:insert-before select="/erp5/object[@id='313731']/local_permission[@id='View']">
... <xupdate:element name="local_permission"><xupdate:attribute name="type">tokens</xupdate:attribute><xupdate:attribute name="id">Manage portal content</xupdate:attribute>&lt;?xml version="1.0"?&gt;</xupdate:element>
... </xupdate:insert-before>
... </xupdate:modifications>
... """
>>> result_tree = applyXUpdate(xml_xu_string=xml_xu_string, xml_doc_string=xml_doc_string)
>>> print etree.tostring(result_tree, pretty_print=1)
<erp5>
<object portal_type="Person" id="313731">
<local_role type="tokens" id="tatuya">&lt;?xml version="1.0"?&gt;&lt;marshal&gt;&lt;tuple&gt;&lt;string&gt;Owner&lt;/string&gt;&lt;/tuple&gt;&lt;/marshal&gt;</local_role>
<JohnDoe>Go to the beach</JohnDoe>
<local_permission type="tokens" id="Access contents information">&lt;?xml version="1.0"?&gt;</local_permission>
<local_permission type="tokens" id="Add portal content">&lt;?xml version="1.0"?&gt;</local_permission>
<local_permission type="tokens" id="Manage portal content">&lt;?xml version="1.0"?&gt;</local_permission>
<local_permission type="tokens" id="View">&lt;?xml version="1.0"?&gt;</local_permission>
</object>
</erp5>
5. rename element
>>> xml_doc_string = """
... <erp5>
... <object portal_type="Person" id="313730">
... <id type="string">313730</id>
... <title type="string">Tatuya Kamada</title>
... </object>
... </erp5>
... """
>>> xml_xu_string = """
... <xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
... <xupdate:rename select="/erp5">erp6</xupdate:rename>
... </xupdate:modifications>
... """
>>> result_tree = applyXUpdate(xml_xu_string=xml_xu_string, xml_doc_string=xml_doc_string)
>>> print etree.tostring(result_tree, pretty_print=1)
<erp6>
<object portal_type="Person" id="313730">
<id type="string">313730</id>
<title type="string">Tatuya Kamada</title>
</object>
</erp6>
6. Update attribute
>>> xml_doc_string = """
... <erp5>
... <object portal_type="Person" id="313730">
... <local_role type="tokens" id="fab">&lt;?xml version="1.0"?&gt;&lt;marshal&gt;&lt;tuple&gt;&lt;string&gt;Owner&lt;/string&gt;&lt;/tuple&gt;&lt;/marshal&gt;</local_role>
... </object>
... </erp5>
... """
>>> xml_xu_string = """
... <xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
... <xupdate:update select="/erp5/object[@id='313730']/local_role[@id='fab']/attribute::type">ccc</xupdate:update>
... </xupdate:modifications>
... """
>>> result_tree = applyXUpdate(xml_xu_string=xml_xu_string, xml_doc_string=xml_doc_string)
>>> print etree.tostring(result_tree, pretty_print=1)
<erp5>
<object portal_type="Person" id="313730">
<local_role type="ccc" id="fab">&lt;?xml version="1.0"?&gt;&lt;marshal&gt;&lt;tuple&gt;&lt;string&gt;Owner&lt;/string&gt;&lt;/tuple&gt;&lt;/marshal&gt;</local_role>
</object>
</erp5>
7. update Two attribue
>>> xml_doc_string = """
... <erp5>
... <object portal_type="Person" id="313730">
... <local_permission attr_a='aaa' type="tokens" id="View">Data</local_permission>
... </object>
... </erp5>
... """
>>> xml_xu_string = """
... <xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
... <xupdate:update select="/erp5/object[@id='313730']/local_permission[@id='View']/attribute::attr_a">ccc</xupdate:update>
... <xupdate:update select="/erp5/object[@id='313730']/local_permission[@id='View']/attribute::type">ccc</xupdate:update>
... </xupdate:modifications>
... """
>>> result_tree = applyXUpdate(xml_xu_string=xml_xu_string, xml_doc_string=xml_doc_string)
>>> print etree.tostring(result_tree, pretty_print=1)
<erp5>
<object portal_type="Person" id="313730">
<local_permission attr_a="ccc" type="ccc" id="View">Data</local_permission>
</object>
</erp5>
8. remove two attribue
>>> xml_doc_string = """
... <erp5>
... <object portal_type="Person" id="313730">
... <local_permission attr_a="aaa" attr_b="bbb" type="tokens" id="View">Data</local_permission>
... </object>
... </erp5>
... """
>>> xml_xu_string = """
... <xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
... <xupdate:remove select="/erp5/object[@id='313730']/local_permission[@id='View']/attribute::attr_a"/>
... <xupdate:remove select="/erp5/object[@id='313730']/local_permission[@id='View']/attribute::attr_b"/>
... </xupdate:modifications>
... """
>>> result_tree = applyXUpdate(xml_xu_string=xml_xu_string, xml_doc_string=xml_doc_string)
>>> print etree.tostring(result_tree, pretty_print=1)
<erp5>
<object portal_type="Person" id="313730">
<local_permission type="tokens" id="View">Data</local_permission>
</object>
</erp5>
9. inster-before
>>> xml_doc_string = """
... <erp5>
... <object portal_type="Person" id="313730">
... <local_permission type="tokens" id="View">Data</local_permission>
... </object>
... </erp5>
... """
>>> xml_xu_string = """
... <xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
... <xupdate:insert-before select="/erp5/object[@id='313730']">
... <object id="313731"/>
... <object id="313732"/>
... <object id="313733"/>
... </xupdate:insert-before>
... </xupdate:modifications>
... """
>>> result_tree = applyXUpdate(xml_xu_string=xml_xu_string, xml_doc_string=xml_doc_string)
>>> print etree.tostring(result_tree, pretty_print=1)
<erp5>
<object id="313731"/>
<object id="313732"/>
<object id="313733"/>
<object portal_type="Person" id="313730">
<local_permission type="tokens" id="View">Data</local_permission>
</object>
</erp5>
10. inster-after
>>> xml_doc_string = """
... <erp5>
... <object portal_type="Person" id="313730">
... <local_permission type="tokens" id="View">Data</local_permission>
... </object>
... </erp5>
... """
>>> xml_xu_string = """
... <xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
... <xupdate:insert-after select="/erp5/object[@id='313730']">
... <object id="313731"/>
... <object id="313732"/>
... <object id="313733"/>
... </xupdate:insert-after>
... </xupdate:modifications>
... """
>>> result_tree = applyXUpdate(xml_xu_string=xml_xu_string, xml_doc_string=xml_doc_string)
>>> print etree.tostring(result_tree, pretty_print=1)
<erp5>
<object portal_type="Person" id="313730">
<local_permission type="tokens" id="View">Data</local_permission>
</object>
<object id="313731"/>
<object id="313732"/>
<object id="313733"/>
</erp5>
11. Namespace handling
>>> xml_doc_string = """
... <erp5>
... <object portal_type="Test">
... <prefix:title xmlns:prefix="http://any_uri">A</prefix:title>
... </object>
... <object portal_type="Test">
... <prefixbis:title xmlns:prefixbis="http://any_uri_bis">A</prefixbis:title>
... </object>
... <object portal_type="Test">
... <againanotherprefix:title xmlns:againanotherprefix="http://any_uri">A</againanotherprefix:title>
... </object>
... </erp5>
... """
>>> xml_xu_string = """
... <xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
... <xupdate:remove xmlns:prefixbis="http://any_uri_bis" select="/erp5/object[2]/prefixbis:title"/>
... <xupdate:append select="/erp5/object[2]" child="first()">
... <xupdate:element name="prefix:title" namespace="http://any_uri"><xupdate:attribute name="prefix:myattr" namespace="http://any_uri">anyvalue</xupdate:attribute>B</xupdate:element>
... </xupdate:append>
... <xupdate:remove xmlns:againanotherprefix="http://any_uri" select="/erp5/object[3]/againanotherprefix:title"/>
... <xupdate:append select="/erp5/object[3]" child="first()">
... <xupdate:element name="title">A</xupdate:element>
... </xupdate:append>
... <xupdate:insert-after select="/erp5/object[3]">
... <xupdate:element name="erp5:object" namespace="http://www.erp5.org/namespaces/erp5_object">
... <xupdate:attribute name="portal_type">Test</xupdate:attribute>
... <title>B</title>
... </xupdate:element>
... <xupdate:element name="object">
... <xupdate:attribute name="portal_type">Test</xupdate:attribute>
... <prefix:title xmlns:prefix="http://any_uri">C</prefix:title>
... </xupdate:element>
... </xupdate:insert-after>
... </xupdate:modifications>
... """
>>> result_tree = applyXUpdate(xml_xu_string=xml_xu_string, xml_doc_string=xml_doc_string)
>>> print etree.tostring(result_tree, pretty_print=1)
<erp5>
<object portal_type="Test">
<prefix:title xmlns:prefix="http://any_uri">A</prefix:title>
</object>
<object portal_type="Test">
<prefix:title xmlns:prefix="http://any_uri" prefix:myattr="anyvalue">B</prefix:title>
</object>
<object portal_type="Test">
<title>A</title>
</object>
<erp5:object xmlns:erp5="http://www.erp5.org/namespaces/erp5_object" portal_type="Test">
<title>B</title>
</erp5:object>
<object portal_type="Test">
<prefix:title xmlns:prefix="http://any_uri">C</prefix:title>
</object>
</erp5>
12. Modify Attributes with Qualified Name
>>> xml_doc_string = """
... <erp5>
... <object portal_type="Test">
... <title xmlns:prefix="http://any_uri" prefix:attr="A">A</title>
... </object>
... </erp5>
... """
>>> xml_xu_string = """
... <xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
... <xupdate:update xmlns:prefix="http://any_uri" select="/erp5/object/title/attribute::prefix:attr">B</xupdate:update>
... </xupdate:modifications>
... """
>>> result_tree = applyXUpdate(xml_xu_string=xml_xu_string, xml_doc_string=xml_doc_string)
>>> print etree.tostring(result_tree, pretty_print=1)
<erp5>
<object portal_type="Test">
<title xmlns:prefix="http://any_uri" prefix:attr="B">A</title>
</object>
</erp5>
13. Modify nodes with Qualified Names at root level
>>> xml_doc_string = """
... <erp5:erp5 xmlns:erp5="http://www.erp5.org/namspaces/erp5_object" a="aaa" b="bbb">
... <object portal_type="Test">
... <title xmlns:prefix="http://any_uri" prefix:attr="A">A</title>
... </object>
... </erp5:erp5>
... """
>>> xml_xu_string = """
... <xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
... <xupdate:rename xmlns:aaa="http://www.erp5.org/namspaces/aaa" xmlns:erp5="http://www.erp5.org/namspaces/erp5_object" select="/erp5:erp5">aaa:erp5</xupdate:rename>
... <xupdate:remove xmlns:aaa="http://www.erp5.org/namspaces/aaa" select="/aaa:erp5/attribute::a"/>
... <xupdate:update xmlns:prefix="http://any_uri" xmlns:aaa="http://www.erp5.org/namspaces/aaa" select="/aaa:erp5/object/title/attribute::prefix:attr">B</xupdate:update>
... </xupdate:modifications>
... """
>>> result_tree = applyXUpdate(xml_xu_string=xml_xu_string, xml_doc_string=xml_doc_string)
>>> print etree.tostring(result_tree, pretty_print=1)
<aaa:erp5 xmlns:aaa="http://www.erp5.org/namspaces/aaa" b="bbb">
<object portal_type="Test">
<title xmlns:prefix="http://any_uri" prefix:attr="B">A</title>
</object>
</aaa:erp5>
14. processing-instruction and comments
>>> xml_doc_string = """
... <erp5>
... <object portal_type="Person" id="313730">
... <id type="string">313730</id>
... <title type="string">Tatuya Kamada</title>
... </object>
... </erp5>
... """
>>> xml_xu_string = """
... <xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
... <xupdate:insert-after select="/erp5/object[@id='313730']">
... <xupdate:processing-instruction name="aaa">type="aaa"</xupdate:processing-instruction>
... <xupdate:comment>This text is a comment</xupdate:comment>
... </xupdate:insert-after>
... </xupdate:modifications>
... """
>>> result_tree = applyXUpdate(xml_xu_string=xml_xu_string, xml_doc_string=xml_doc_string)
>>> print etree.tostring(result_tree, pretty_print=1)
<erp5>
<object portal_type="Person" id="313730">
<id type="string">313730</id>
<title type="string">Tatuya Kamada</title>
</object>
<?aaa type="aaa"?>
<!--This text is a comment-->
</erp5>
15. variables
>>> xml_doc_string = """
... <erp5>
... <object portal_type="Person" id="313730">
... <title type="string">Tatuya Kamada</title>
... </object>
... </erp5>
... """
>>> xml_xu_string = """
... <xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
... <xupdate:variable name="person" select="/erp5/object[@id='313730']"/>
... <xupdate:insert-after select="/erp5/object[@id='313730']">
... <xupdate:value-of select="$person"/>
... </xupdate:insert-after>
... </xupdate:modifications>
... """
>>> result_tree = applyXUpdate(xml_xu_string=xml_xu_string, xml_doc_string=xml_doc_string)
>>> print etree.tostring(result_tree, pretty_print=1)
<erp5>
<object portal_type="Person" id="313730">
<title type="string">Tatuya Kamada</title>
</object>
<object portal_type="Person" id="313730">
<title type="string">Tatuya Kamada</title>
</object>
</erp5>
16. value-of
>>> xml_doc_string = """
... <erp5>
... <object portal_type="Person" id="313730">
... <title type="string">Tatuya Kamada</title>
... </object>
... </erp5>
... """
>>> xml_xu_string = """
... <xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
... <xupdate:insert-after select="/erp5/object[@id='313730']">
... <xupdate:value-of select="/erp5/object[@id='313730']"/>
... </xupdate:insert-after>
... </xupdate:modifications>
... """
>>> result_tree = applyXUpdate(xml_xu_string=xml_xu_string, xml_doc_string=xml_doc_string)
>>> print etree.tostring(result_tree, pretty_print=1)
<erp5>
<object portal_type="Person" id="313730">
<title type="string">Tatuya Kamada</title>
</object>
<object portal_type="Person" id="313730">
<title type="string">Tatuya Kamada</title>
</object>
</erp5>
17. OOo files 1
>>> orig_filename = 'test_ooo_1.xml'
>>> xu_filename = 'xu_ooo_1.xml'
>>> destination_filename = 'dest_ooo_1.xml'
>>> result_tree = applyXUpdate(xml_xu_filename=xu_filename, xml_doc_filename=orig_filename)
>>> destination_tree = etree.parse(destination_filename)
>>> destination_buffer = StringIO()
>>> result_buffer = StringIO()
>>> destination_tree.write_c14n(destination_buffer)
>>> result_tree.write_c14n(result_buffer)
>>> from ERP5Diff import ERP5Diff
>>> erp5diff = ERP5Diff()
>>> erp5diff.compare(result_buffer.getvalue(), destination_buffer.getvalue())
>>> etree.tostring(erp5diff._result)
'<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0"/>'
17. OOo files 2
>>> orig_filename = 'test_ooo_2.xml'
>>> xu_filename = 'xu_ooo_2.xml'
>>> destination_filename = 'dest_ooo_2.xml'
>>> result_tree = applyXUpdate(xml_xu_filename=xu_filename, xml_doc_filename=orig_filename)
>>> destination_tree = etree.parse(destination_filename)
>>> destination_buffer = StringIO()
>>> result_buffer = StringIO()
>>> destination_tree.write_c14n(destination_buffer)
>>> result_tree.write_c14n(result_buffer)
>>> from ERP5Diff import ERP5Diff
>>> erp5diff = ERP5Diff()
>>> erp5diff.compare(result_buffer.getvalue(), destination_buffer.getvalue())
>>> etree.tostring(erp5diff._result)
'<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0"/>'
\ No newline at end of file
[buildout]
develop = .
parts = test
[test]
recipe = zc.recipe.testrunner
eggs = xupdate_processor
initialization = from shutil import copy2; from glob import glob; [copy2(f, '../../parts/test/%s' % f.split('/')[-1]) for f in glob('../../*.xml')]
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:rdfa="http://docs.oasis-open.org/opendocument/meta/rdfa#" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" office:version="1.2"><office:scripts/><office:font-face-decls><style:font-face style:name="Liberation Serif" svg:font-family="&apos;Liberation Serif&apos;" style:font-family-generic="roman" style:font-pitch="variable"/><style:font-face style:name="Liberation Sans" svg:font-family="&apos;Liberation Sans&apos;" style:font-family-generic="swiss" style:font-pitch="variable"/><style:font-face style:name="DejaVu Sans" svg:font-family="&apos;DejaVu Sans&apos;" style:font-family-generic="system" style:font-pitch="variable"/></office:font-face-decls><office:automatic-styles><style:style style:name="fr1" style:family="graphic" style:parent-style-name="Graphics"><style:graphic-properties style:horizontal-pos="center" style:horizontal-rel="paragraph" style:mirror="none" fo:clip="rect(0cm, 0cm, 0cm, 0cm)" draw:luminance="0%" draw:contrast="0%" draw:red="0%" draw:green="0%" draw:blue="0%" draw:gamma="100%" draw:color-inversion="false" draw:image-opacity="100%" draw:color-mode="standard"/></style:style></office:automatic-styles><office:body><office:text><text:sequence-decls><text:sequence-decl text:display-outline-level="0" text:name="Illustration"/><text:sequence-decl text:display-outline-level="0" text:name="Table"/><text:sequence-decl text:display-outline-level="0" text:name="Text"/><text:sequence-decl text:display-outline-level="0" text:name="Drawing"/></text:sequence-decls><text:p text:style-name="Standard">Hello World !</text:p><text:p text:style-name="Standard"/><text:p text:style-name="Standard">XUProc is a wonderfull Tool</text:p><text:p text:style-name="Standard"><draw:frame draw:style-name="fr1" draw:name="images1" text:anchor-type="paragraph" svg:width="6.011cm" svg:height="5.306cm" draw:z-index="0"><draw:image xlink:href="Pictures/10000201000000D5000000BCBE47EB65.png" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame></text:p></office:text></office:body></office:document-content>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:rdfa="http://docs.oasis-open.org/opendocument/meta/rdfa#" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" office:version="1.2">
<office:scripts/>
<office:font-face-decls>
<style:font-face style:name="OpenSymbol" svg:font-family="OpenSymbol"/>
<style:font-face style:name="DejaVu Sans Mono" svg:font-family="'DejaVu Sans Mono'" style:font-family-generic="modern" style:font-pitch="fixed"/>
<style:font-face style:name="Liberation Serif" svg:font-family="'Liberation Serif'" style:font-family-generic="roman" style:font-pitch="variable"/>
<style:font-face style:name="Liberation Sans" svg:font-family="'Liberation Sans'" style:font-family-generic="swiss" style:font-pitch="variable"/>
<style:font-face style:name="DejaVu Sans" svg:font-family="'DejaVu Sans'" style:font-family-generic="system" style:font-pitch="variable"/>
</office:font-face-decls>
<office:automatic-styles>
<style:style style:name="P1" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L1"/>
<style:style style:name="P2" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L5"/>
<style:style style:name="P3" style:family="paragraph" style:parent-style-name="Text_20_body">
<style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0cm"/>
</style:style>
<style:style style:name="P4" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L1">
<style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0cm"/>
</style:style>
<style:style style:name="P5" style:family="paragraph" style:parent-style-name="Preformatted_20_Text">
<style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.499cm"/>
</style:style>
<style:style style:name="fr1" style:family="graphic" style:parent-style-name="Graphics">
<style:graphic-properties style:horizontal-pos="center" style:horizontal-rel="paragraph" style:mirror="none" fo:clip="rect(0cm, 0cm, 0cm, 0cm)" draw:luminance="0%" draw:contrast="0%" draw:red="0%" draw:green="0%" draw:blue="0%" draw:gamma="100%" draw:color-inversion="false" draw:image-opacity="100%" draw:color-mode="standard"/>
</style:style>
<text:list-style style:name="L1">
<text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:space-before="0.748cm" text:min-label-width="0.499cm"/>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:space-before="1.995cm" text:min-label-width="0.499cm"/>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:space-before="3.242cm" text:min-label-width="0.499cm"/>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:space-before="4.489cm" text:min-label-width="0.499cm"/>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:space-before="5.736cm" text:min-label-width="0.499cm"/>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:space-before="6.983cm" text:min-label-width="0.499cm"/>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:space-before="8.23cm" text:min-label-width="0.499cm"/>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:space-before="9.478cm" text:min-label-width="0.499cm"/>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:space-before="10.725cm" text:min-label-width="0.499cm"/>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:space-before="11.972cm" text:min-label-width="0.499cm"/>
</text:list-level-style-bullet>
</text:list-style>
<text:list-style style:name="L2">
<text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.27cm" fo:text-indent="-0.635cm" fo:margin-left="1.27cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.905cm" fo:text-indent="-0.635cm" fo:margin-left="1.905cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.54cm" fo:text-indent="-0.635cm" fo:margin-left="2.54cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.175cm" fo:text-indent="-0.635cm" fo:margin-left="3.175cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.81cm" fo:text-indent="-0.635cm" fo:margin-left="3.81cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.445cm" fo:text-indent="-0.635cm" fo:margin-left="4.445cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.08cm" fo:text-indent="-0.635cm" fo:margin-left="5.08cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.715cm" fo:text-indent="-0.635cm" fo:margin-left="5.715cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="6.35cm" fo:text-indent="-0.635cm" fo:margin-left="6.35cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="6.985cm" fo:text-indent="-0.635cm" fo:margin-left="6.985cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
</text:list-style>
<text:list-style style:name="L3">
<text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.27cm" fo:text-indent="-0.635cm" fo:margin-left="1.27cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.905cm" fo:text-indent="-0.635cm" fo:margin-left="1.905cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.54cm" fo:text-indent="-0.635cm" fo:margin-left="2.54cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.175cm" fo:text-indent="-0.635cm" fo:margin-left="3.175cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.81cm" fo:text-indent="-0.635cm" fo:margin-left="3.81cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.445cm" fo:text-indent="-0.635cm" fo:margin-left="4.445cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.08cm" fo:text-indent="-0.635cm" fo:margin-left="5.08cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.715cm" fo:text-indent="-0.635cm" fo:margin-left="5.715cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="6.35cm" fo:text-indent="-0.635cm" fo:margin-left="6.35cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="6.985cm" fo:text-indent="-0.635cm" fo:margin-left="6.985cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
</text:list-style>
<text:list-style style:name="L4">
<text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.27cm" fo:text-indent="-0.635cm" fo:margin-left="1.27cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.905cm" fo:text-indent="-0.635cm" fo:margin-left="1.905cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.54cm" fo:text-indent="-0.635cm" fo:margin-left="2.54cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.175cm" fo:text-indent="-0.635cm" fo:margin-left="3.175cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.81cm" fo:text-indent="-0.635cm" fo:margin-left="3.81cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.445cm" fo:text-indent="-0.635cm" fo:margin-left="4.445cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.08cm" fo:text-indent="-0.635cm" fo:margin-left="5.08cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.715cm" fo:text-indent="-0.635cm" fo:margin-left="5.715cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="6.35cm" fo:text-indent="-0.635cm" fo:margin-left="6.35cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="6.985cm" fo:text-indent="-0.635cm" fo:margin-left="6.985cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
</text:list-style>
<text:list-style style:name="L5">
<text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.27cm" fo:text-indent="-0.635cm" fo:margin-left="1.27cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.905cm" fo:text-indent="-0.635cm" fo:margin-left="1.905cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.54cm" fo:text-indent="-0.635cm" fo:margin-left="2.54cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.175cm" fo:text-indent="-0.635cm" fo:margin-left="3.175cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.81cm" fo:text-indent="-0.635cm" fo:margin-left="3.81cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.445cm" fo:text-indent="-0.635cm" fo:margin-left="4.445cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.08cm" fo:text-indent="-0.635cm" fo:margin-left="5.08cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.715cm" fo:text-indent="-0.635cm" fo:margin-left="5.715cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="6.35cm" fo:text-indent="-0.635cm" fo:margin-left="6.35cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
<text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•">
<style:list-level-properties text:list-level-position-and-space-mode="label-alignment">
<style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="6.985cm" fo:text-indent="-0.635cm" fo:margin-left="6.985cm"/>
</style:list-level-properties>
</text:list-level-style-bullet>
</text:list-style>
</office:automatic-styles>
<office:body>
<office:text>
<text:sequence-decls>
<text:sequence-decl text:display-outline-level="0" text:name="Illustration"/>
<text:sequence-decl text:display-outline-level="0" text:name="Table"/>
<text:sequence-decl text:display-outline-level="0" text:name="Text"/>
<text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
</text:sequence-decls>
<text:p text:style-name="Standard">Hello World !</text:p>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard">XUProc is a wonderfull Tool</text:p>
<text:p text:style-name="Standard">
<draw:frame draw:style-name="fr1" draw:name="images1" text:anchor-type="paragraph" svg:width="6.011cm" svg:height="5.306cm" draw:z-index="0">
<draw:image xlink:href="Pictures/10000201000000D5000000BCBE47EB65.png" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
</draw:frame>
</text:p>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard"/>
<text:p text:style-name="Standard"/>
<text:h text:style-name="Heading_20_1" text:outline-level="1"/>
<text:p text:style-name="Text_20_body"/>
<text:list xml:id="list1013965289" text:style-name="L5">
<text:list-item>
<text:p text:style-name="P2">Item Two</text:p>
</text:list-item>
<text:list-item>
<text:p text:style-name="P2">Item three</text:p>
</text:list-item>
<text:list-item>
<text:p text:style-name="P2">Item Six</text:p>
</text:list-item>
<text:list-item>
<text:p text:style-name="P2">Item seven</text:p>
</text:list-item>
<text:list-item>
<text:p text:style-name="P2">Item height</text:p>
</text:list-item>
<text:list-item>
<text:p text:style-name="P2">Item Four</text:p>
</text:list-item>
<text:list-item>
<text:p text:style-name="P2">Item five</text:p>
</text:list-item>
<text:list-item>
<text:p text:style-name="P2">Item nine</text:p>
</text:list-item>
</text:list>
</office:text>
</office:body>
</office:document-content>
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
setup(name="xupdate_processor",
version=0.1,
description="XUpdate Processor",
author="Nicolas DELABY",
author_email="nicolas@nexedi.com",
url="http://nexedi.com",
license="GPL",
packages=find_packages(),
package_data={'doc_test': ['*.xml',],
'': ['DOCTEST',]},
scripts=["xuproc"],
install_requires=['zope.interface', 'lxml', 'erp5diff >= 0.7'],
classifiers=['License :: OSI Approved :: GNU General Public License (GPL)',
'Operating System :: OS Independent',
'Topic :: Text Processing :: Markup :: XML',
'Topic :: Utilities'],
include_package_data=True,
zip_safe=False,
)
<?xml version="1.0" encoding="UTF-8"?>
<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:rdfa="http://docs.oasis-open.org/opendocument/meta/rdfa#" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" office:version="1.2"><office:scripts/><office:font-face-decls><style:font-face style:name="Liberation Serif" svg:font-family="&apos;Liberation Serif&apos;" style:font-family-generic="roman" style:font-pitch="variable"/><style:font-face style:name="Liberation Sans" svg:font-family="&apos;Liberation Sans&apos;" style:font-family-generic="swiss" style:font-pitch="variable"/><style:font-face style:name="DejaVu Sans" svg:font-family="&apos;DejaVu Sans&apos;" style:font-family-generic="system" style:font-pitch="variable"/></office:font-face-decls><office:automatic-styles/><office:body><office:text><text:sequence-decls><text:sequence-decl text:display-outline-level="0" text:name="Illustration"/><text:sequence-decl text:display-outline-level="0" text:name="Table"/><text:sequence-decl text:display-outline-level="0" text:name="Text"/><text:sequence-decl text:display-outline-level="0" text:name="Drawing"/></text:sequence-decls><text:p text:style-name="Standard">Hello World !</text:p></office:text></office:body></office:document-content>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:rdfa="http://docs.oasis-open.org/opendocument/meta/rdfa#" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" office:version="1.2"><office:scripts/><office:font-face-decls><style:font-face style:name="OpenSymbol" svg:font-family="OpenSymbol"/><style:font-face style:name="DejaVu Sans Mono" svg:font-family="&apos;DejaVu Sans Mono&apos;" style:font-family-generic="modern" style:font-pitch="fixed"/><style:font-face style:name="Liberation Serif" svg:font-family="&apos;Liberation Serif&apos;" style:font-family-generic="roman" style:font-pitch="variable"/><style:font-face style:name="Liberation Sans" svg:font-family="&apos;Liberation Sans&apos;" style:font-family-generic="swiss" style:font-pitch="variable"/><style:font-face style:name="DejaVu Sans" svg:font-family="&apos;DejaVu Sans&apos;" style:font-family-generic="system" style:font-pitch="variable"/></office:font-face-decls><office:automatic-styles><style:style style:name="P1" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L1"/><style:style style:name="P2" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L5"/><style:style style:name="P3" style:family="paragraph" style:parent-style-name="Text_20_body"><style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0cm"/></style:style><style:style style:name="P4" style:family="paragraph" style:parent-style-name="Text_20_body" style:list-style-name="L1"><style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0cm"/></style:style><style:style style:name="P5" style:family="paragraph" style:parent-style-name="Preformatted_20_Text"><style:paragraph-properties fo:margin-top="0cm" fo:margin-bottom="0.499cm"/></style:style><style:style style:name="fr1" style:family="graphic" style:parent-style-name="Graphics"><style:graphic-properties style:horizontal-pos="center" style:horizontal-rel="paragraph" style:mirror="none" fo:clip="rect(0cm, 0cm, 0cm, 0cm)" draw:luminance="0%" draw:contrast="0%" draw:red="0%" draw:green="0%" draw:blue="0%" draw:gamma="100%" draw:color-inversion="false" draw:image-opacity="100%" draw:color-mode="standard"/></style:style><text:list-style style:name="L1"><text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:space-before="0.748cm" text:min-label-width="0.499cm"/></text:list-level-style-bullet><text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:space-before="1.995cm" text:min-label-width="0.499cm"/></text:list-level-style-bullet><text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:space-before="3.242cm" text:min-label-width="0.499cm"/></text:list-level-style-bullet><text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:space-before="4.489cm" text:min-label-width="0.499cm"/></text:list-level-style-bullet><text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:space-before="5.736cm" text:min-label-width="0.499cm"/></text:list-level-style-bullet><text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:space-before="6.983cm" text:min-label-width="0.499cm"/></text:list-level-style-bullet><text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:space-before="8.23cm" text:min-label-width="0.499cm"/></text:list-level-style-bullet><text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:space-before="9.478cm" text:min-label-width="0.499cm"/></text:list-level-style-bullet><text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:space-before="10.725cm" text:min-label-width="0.499cm"/></text:list-level-style-bullet><text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:space-before="11.972cm" text:min-label-width="0.499cm"/></text:list-level-style-bullet></text:list-style><text:list-style style:name="L2"><text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.27cm" fo:text-indent="-0.635cm" fo:margin-left="1.27cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.905cm" fo:text-indent="-0.635cm" fo:margin-left="1.905cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.54cm" fo:text-indent="-0.635cm" fo:margin-left="2.54cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.175cm" fo:text-indent="-0.635cm" fo:margin-left="3.175cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.81cm" fo:text-indent="-0.635cm" fo:margin-left="3.81cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.445cm" fo:text-indent="-0.635cm" fo:margin-left="4.445cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.08cm" fo:text-indent="-0.635cm" fo:margin-left="5.08cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.715cm" fo:text-indent="-0.635cm" fo:margin-left="5.715cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="6.35cm" fo:text-indent="-0.635cm" fo:margin-left="6.35cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="6.985cm" fo:text-indent="-0.635cm" fo:margin-left="6.985cm"/></style:list-level-properties></text:list-level-style-bullet></text:list-style><text:list-style style:name="L3"><text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.27cm" fo:text-indent="-0.635cm" fo:margin-left="1.27cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.905cm" fo:text-indent="-0.635cm" fo:margin-left="1.905cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.54cm" fo:text-indent="-0.635cm" fo:margin-left="2.54cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.175cm" fo:text-indent="-0.635cm" fo:margin-left="3.175cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.81cm" fo:text-indent="-0.635cm" fo:margin-left="3.81cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.445cm" fo:text-indent="-0.635cm" fo:margin-left="4.445cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.08cm" fo:text-indent="-0.635cm" fo:margin-left="5.08cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.715cm" fo:text-indent="-0.635cm" fo:margin-left="5.715cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="6.35cm" fo:text-indent="-0.635cm" fo:margin-left="6.35cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="6.985cm" fo:text-indent="-0.635cm" fo:margin-left="6.985cm"/></style:list-level-properties></text:list-level-style-bullet></text:list-style><text:list-style style:name="L4"><text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.27cm" fo:text-indent="-0.635cm" fo:margin-left="1.27cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.905cm" fo:text-indent="-0.635cm" fo:margin-left="1.905cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.54cm" fo:text-indent="-0.635cm" fo:margin-left="2.54cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.175cm" fo:text-indent="-0.635cm" fo:margin-left="3.175cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.81cm" fo:text-indent="-0.635cm" fo:margin-left="3.81cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.445cm" fo:text-indent="-0.635cm" fo:margin-left="4.445cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.08cm" fo:text-indent="-0.635cm" fo:margin-left="5.08cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.715cm" fo:text-indent="-0.635cm" fo:margin-left="5.715cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="6.35cm" fo:text-indent="-0.635cm" fo:margin-left="6.35cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="6.985cm" fo:text-indent="-0.635cm" fo:margin-left="6.985cm"/></style:list-level-properties></text:list-level-style-bullet></text:list-style><text:list-style style:name="L5"><text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.27cm" fo:text-indent="-0.635cm" fo:margin-left="1.27cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="2" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="1.905cm" fo:text-indent="-0.635cm" fo:margin-left="1.905cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="3" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="2.54cm" fo:text-indent="-0.635cm" fo:margin-left="2.54cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="4" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.175cm" fo:text-indent="-0.635cm" fo:margin-left="3.175cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="5" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="3.81cm" fo:text-indent="-0.635cm" fo:margin-left="3.81cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="6" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="4.445cm" fo:text-indent="-0.635cm" fo:margin-left="4.445cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="7" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.08cm" fo:text-indent="-0.635cm" fo:margin-left="5.08cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="8" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="◦"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="5.715cm" fo:text-indent="-0.635cm" fo:margin-left="5.715cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="9" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="▪"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="6.35cm" fo:text-indent="-0.635cm" fo:margin-left="6.35cm"/></style:list-level-properties></text:list-level-style-bullet><text:list-level-style-bullet text:level="10" text:style-name="Bullet_20_Symbols" style:num-suffix="." text:bullet-char="•"><style:list-level-properties text:list-level-position-and-space-mode="label-alignment"><style:list-level-label-alignment text:label-followed-by="listtab" text:list-tab-stop-position="6.985cm" fo:text-indent="-0.635cm" fo:margin-left="6.985cm"/></style:list-level-properties></text:list-level-style-bullet></text:list-style></office:automatic-styles><office:body><office:text><text:sequence-decls><text:sequence-decl text:display-outline-level="0" text:name="Illustration"/><text:sequence-decl text:display-outline-level="0" text:name="Table"/><text:sequence-decl text:display-outline-level="0" text:name="Text"/><text:sequence-decl text:display-outline-level="0" text:name="Drawing"/></text:sequence-decls><text:p text:style-name="Standard">Hello World !</text:p><text:p text:style-name="Standard"/><text:p text:style-name="Standard">XUProc is a wonderfull Tool</text:p><text:p text:style-name="Standard"><draw:frame draw:style-name="fr1" draw:name="images1" text:anchor-type="paragraph" svg:width="6.011cm" svg:height="5.306cm" draw:z-index="0"><draw:image xlink:href="Pictures/10000201000000D5000000BCBE47EB65.png" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/></draw:frame></text:p><text:p text:style-name="Standard"/><text:p text:style-name="Standard"/><text:p text:style-name="Standard"/><text:p text:style-name="Standard"/><text:p text:style-name="Standard"/><text:p text:style-name="Standard"/><text:p text:style-name="Standard"/><text:p text:style-name="Standard"/><text:p text:style-name="Standard"/><text:p text:style-name="Standard"/><text:p text:style-name="Standard"/><text:p text:style-name="Standard"/><text:h text:style-name="Heading_20_1" text:outline-level="1"/><text:p text:style-name="Text_20_body"/><text:list xml:id="list1013965289" text:style-name="L5"><text:list-item><text:p text:style-name="P2">Item One</text:p></text:list-item><text:list-item><text:p text:style-name="P2">Item Two</text:p></text:list-item><text:list-item><text:p text:style-name="P2">Item three</text:p></text:list-item><text:list-item><text:p text:style-name="P2">Item Four</text:p></text:list-item><text:list-item><text:p text:style-name="P2">Item five</text:p></text:list-item><text:list-item><text:p text:style-name="P2">Item Six</text:p></text:list-item><text:list-item><text:p text:style-name="P2">Item seven</text:p></text:list-item><text:list-item><text:p text:style-name="P2">Item height</text:p></text:list-item><text:list-item><text:p text:style-name="P2">Item nine</text:p></text:list-item></text:list></office:text></office:body></office:document-content>
\ No newline at end of file
# -*- coding: utf-8 -*-
from zope import interface
import zope.testing
import unittest
OPTIONFLAGS = (zope.testing.doctest.ELLIPSIS |
zope.testing.doctest.NORMALIZE_WHITESPACE)
def test_suite():
doctests = ('DOCTEST',)
globs = dict(interface=interface)
return unittest.TestSuite((
zope.testing.doctest.DocFileSuite(doctest,
optionflags=OPTIONFLAGS,
globs=globs,
) for doctest in doctests
))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
\ No newline at end of file
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:update xmlns:rpt="http://openoffice.org/2005/report" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:rdfa="http://docs.oasis-open.org/opendocument/meta/rdfa#" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:oooc="http://openoffice.org/2004/calc" select="/office:document-content/office:automatic-styles">
<style:style style:name="fr1" style:family="graphic" style:parent-style-name="Graphics">
<style:graphic-properties style:horizontal-pos="center" style:horizontal-rel="paragraph" style:mirror="none" fo:clip="rect(0cm, 0cm, 0cm, 0cm)" draw:luminance="0%" draw:contrast="0%" draw:red="0%" draw:green="0%" draw:blue="0%" draw:gamma="100%" draw:color-inversion="false" draw:image-opacity="100%" draw:color-mode="standard"/>
</style:style>
</xupdate:update>
<xupdate:insert-after select="/office:document-content/office:body/office:text/text:p[1]">
<xupdate:element name="text:p" namespace="urn:oasis:names:tc:opendocument:xmlns:text:1.0">
<xupdate:attribute name="text:style-name" namespace="urn:oasis:names:tc:opendocument:xmlns:text:1.0">Standard</xupdate:attribute>
</xupdate:element>
<xupdate:element name="text:p" namespace="urn:oasis:names:tc:opendocument:xmlns:text:1.0"><xupdate:attribute name="text:style-name" namespace="urn:oasis:names:tc:opendocument:xmlns:text:1.0">Standard</xupdate:attribute>XUProc is a wonderfull Tool</xupdate:element>
<xupdate:element name="text:p" namespace="urn:oasis:names:tc:opendocument:xmlns:text:1.0">
<xupdate:attribute name="text:style-name" namespace="urn:oasis:names:tc:opendocument:xmlns:text:1.0">Standard</xupdate:attribute>
<draw:frame xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" draw:style-name="fr1" draw:name="images1" text:anchor-type="paragraph" svg:width="6.011cm" svg:height="5.306cm" draw:z-index="0">
<draw:image xlink:href="Pictures/10000201000000D5000000BCBE47EB65.png" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
</draw:frame>
</xupdate:element>
</xupdate:insert-after>
</xupdate:modifications>
<xupdate:modifications xmlns:xupdate="http://www.xmldb.org/xupdate" version="1.0">
<xupdate:remove xmlns:rpt="http://openoffice.org/2005/report" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:rdfa="http://docs.oasis-open.org/opendocument/meta/rdfa#" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:oooc="http://openoffice.org/2004/calc" select="/office:document-content/office:body/office:text/text:list/text:list-item[1]"/>
<xupdate:remove select="/office:document-content/office:body/office:text/text:list/text:list-item[4]"/>
<xupdate:remove select="/office:document-content/office:body/office:text/text:list/text:list-item[5]"/>
<xupdate:insert-after select="/office:document-content/office:body/office:text/text:list/text:list-item[8]">
<xupdate:element name="text:list-item" namespace="urn:oasis:names:tc:opendocument:xmlns:text:1.0">
<text:p xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" text:style-name="P2">Item Four</text:p>
</xupdate:element>
<xupdate:element name="text:list-item" namespace="urn:oasis:names:tc:opendocument:xmlns:text:1.0">
<text:p xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" text:style-name="P2">Item five</text:p>
</xupdate:element>
</xupdate:insert-after>
</xupdate:modifications>
# -*- coding: utf-8 -*-
from xuproc import applyXUpdate
from lxml import etree
def main():
import sys
doc_xml_name = sys.argv[1]
xu_xml_name = sys.argv[2]
print etree.tostring(applyXUpdate(xml_xu_filename=xu_xml_name,
xml_doc_filename=doc_xml_name),
pretty_print=True)
\ No newline at end of file
# -*- coding: utf-8 -*-
from lxml import etree
from lxml.etree import Element, _ElementTree, ProcessingInstruction, Comment
from xml.sax.handler import ContentHandler
from xml.sax import SAXParseException
from copy import deepcopy
import re
attribute_axes_regex = re.compile(r'(?P<parent_node>^.*(?=/(attribute::|@)))(?P<attribute_axes>/(attribute::|@))(?P<attribute_id>[\w\-:]*)$')
XUPDATE_NS = 'http://www.xmldb.org/xupdate'
class XUpdateValidationException(SAXParseException):
pass
class XUpdateHandler(ContentHandler):
"""
Handler to parse xupdate documents
"""
def __init__(self, original_tree=None):
"""
original_tree: lxml tree
"""
ContentHandler.__init__(self)
if not isinstance(original_tree, _ElementTree):
original_tree = original_tree.getroottree()
self._modification_starts = False
self.result_tree = deepcopy(original_tree)
self.nsmap = {}
self._variable_dict = {}
self._node_stack = []
self._current_position_string_stack = []
self._string_stack = []
self._to_remove_node_list = []
self._parent_node_append_stack = []
self._current_position_to_append_stack = []
self._attr_name_stack = []
def startPrefixMapping(self, prefix, uri):
self.nsmap[prefix] = uri
def startElementNS(self, name, qname, attrs):
uri, localname = name
prefix = None
if ':' in qname:
prefix, _ = qname.split(':')
#store position of current string_stack
#to join all characters contents for the current element only
self._current_position_string_stack.append(len(self._string_stack))
if uri == XUPDATE_NS:
#This is an xupdate action
if localname == 'modifications':
if self._modification_starts:
raise XUpdateValidationException('{%s}modifications already read' % XUPDATE_NS)
else:
self.modification_starts = True
elif localname == 'update':
#get the node fromp xpath expression
xpath_expression = attrs.getValueByQName('select')
matched_re = attribute_axes_regex.match(xpath_expression)
if matched_re is not None:
#Unfortunately, etree manage attributes as smart_string results (they known their parents)
# But they do not know in which attribute they are linked
#so, use a workaround to update attribute nodes like dictionaries
#('/attribute::' or '/@' axes)
#XXX This code will be removed after release of lxml 2.2.4
parent_node_expression = matched_re.group('parent_node')
attribute_id = matched_re.group('attribute_id')
if ':' in attribute_id:
prefix, local_name = attribute_id.split(':')
uri = self.nsmap[prefix]
attribute_id = '{%s}%s' % (uri, local_name,)
node = self.result_tree.xpath(parent_node_expression, namespaces=self.nsmap)[0]
self._node_stack.append((node, attribute_id))
self._current_position_to_append_stack.append(len(self._node_stack))
else:
node = self.result_tree.xpath(xpath_expression, namespaces=self.nsmap)[0]
self._node_stack.append(node)
self._current_position_to_append_stack.append(len(self._node_stack))
elif localname == 'remove':
xpath_expression = attrs.getValueByQName('select')
matched_re = attribute_axes_regex.match(xpath_expression)
if matched_re is not None:
parent_node_expression = matched_re.group('parent_node')
attribute_id = matched_re.group('attribute_id')
node = self.result_tree.xpath(parent_node_expression, namespaces=self.nsmap)[0]
if ':' in attribute_id:
attr_prefix, local_name = attribute_id.split(':')
uri = self.nsmap[attr_prefix]
attribute_id = '{%s}%s' % (uri, local_name,)
del node.attrib[attribute_id]
else:
node = self.result_tree.xpath(xpath_expression, namespaces=self.nsmap)[0]
self._to_remove_node_list.append(node)
elif localname == 'append':
node = self.result_tree.xpath(attrs.getValueByQName('select'))[0]
self._parent_node_append_stack.append(node)
xpath_position = attrs.getValueByQName('child')
self._current_position_to_append_stack.append((xpath_position, len(self._node_stack)))
elif localname == 'element':
tag_name = attrs.getValueByQName('name')
nsmap = {}
if ':' in tag_name:
prefix, local_name = tag_name.split(':')
uri = attrs.getValueByQName('namespace')
tag_name = '{%s}%s' % (uri, local_name,)
nsmap[prefix] = uri
node = Element(tag_name, nsmap=nsmap)
self._node_stack.append(node)
self._current_position_to_append_stack.append(len(self._node_stack))
elif localname == 'attribute':
node = self._node_stack[-1]
self._node_stack.append(node)
attr_name = attrs.getValueByQName('name')
if ':' in attr_name:
uri = attrs.getValueByQName('namespace')
prefix, local_name = attr_name.split(':')
attr_name = '{%s}%s' % (uri, local_name,)
self._attr_name_stack.append(attr_name)
elif localname == 'insert-before':
node = self.result_tree.xpath(attrs.getValueByQName('select'), namespaces=self.nsmap)[0]
self._current_position_to_append_stack.append(len(self._node_stack))
self._node_stack.append(node)
elif localname == 'insert-after':
node = self.result_tree.xpath(attrs.getValueByQName('select'), namespaces=self.nsmap)[0]
self._current_position_to_append_stack.append(len(self._node_stack))
self._node_stack.append(node)
elif localname == 'rename':
node = self.result_tree.xpath(attrs.getValueByQName('select'), namespaces=self.nsmap)[0]
self._node_stack.append(node)
elif localname == 'processing-instruction':
node_name = attrs.getValueByQName('name')
node = ProcessingInstruction(node_name)
self._node_stack.append(node)
elif localname == 'comment':
node = Comment()
self._node_stack.append(node)
elif localname == 'variable':
name = attrs.getValueByQName('name')
node = self.result_tree.xpath(attrs.getValueByQName('select'), namespaces=self.nsmap)[0]
self._variable_dict[name] = node
elif localname == 'value-of':
select = attrs.getValueByQName('select')
if select[0] == '$':
#This is a variable
node = self._variable_dict[select[1:]]
else:
#This is an xpath expression
node = self.result_tree.xpath(select, namespaces=self.nsmap)[0]
self._node_stack.append(deepcopy(node))
else:
raise NotImplementedError(localname)
else:
nsmap = {}
if uri:
localname = '{%s}%s' % (uri, localname)
nsmap = {prefix: uri}
new_node = Element(localname, nsmap=nsmap)
new_attr_dict = {}
for attr_key, value in attrs.items():
uri, attr_name = attr_key
if uri:
attr_name = '{%s}%s' % (uri, attr_name)
new_attr_dict[attr_name] = value
new_node.attrib.update(new_attr_dict)
self._node_stack.append(new_node)
self._current_position_to_append_stack.append(len(self._node_stack))
def characters(self, content):
if content.strip():
self._string_stack.append(content)
def endElementNS(self, name, qname):
uri, localname = name
last_position = self._current_position_string_stack.pop()
token_list = [self._string_stack.pop() for token in self._string_stack[last_position:]]
token_list.reverse()
content = ''.join(token_list)
if not content.strip():
content = None
if uri == XUPDATE_NS:
#This is an xupdate action
if localname == 'modifications':
pass
elif localname == 'update':
#get the node fromp xpath expression
node_stack_position = self._current_position_to_append_stack.pop()
node_to_append_list = [self._node_stack.pop() for node in self._node_stack[node_stack_position:]]
node = self._node_stack.pop()
if isinstance(node, tuple):
#This is a attribute update
node, attribute_id = node
node.attrib.update({attribute_id: content})
else:
node.extend(node_to_append_list)
if len(node):
node[-1].tail = content
else:
node.text = content
elif localname == 'remove':
pass
elif localname == 'append':
xpath_position, node_stack_position = self._current_position_to_append_stack.pop()
parent_node = self._parent_node_append_stack.pop()
node_to_append_list = [self._node_stack.pop() for node in self._node_stack[node_stack_position:]]
if xpath_position == 'first()':
for node in node_to_append_list:
parent_node.insert(0, node)
else:
#Include last()
node_to_append_list.reverse()
parent_node.extend(node_to_append_list)
elif localname == 'element':
node_stack_position = self._current_position_to_append_stack.pop()
node_to_append_list = [self._node_stack.pop() for node in self._node_stack[node_stack_position:]]
node = self._node_stack[-1]
node.extend(node_to_append_list)
if len(node):
node[-1].tail = content
else:
node.text = content
elif localname == 'attribute':
node = self._node_stack.pop()
attr_name = self._attr_name_stack.pop()
node.attrib.update({attr_name: content})
elif localname == 'insert-before':
node_stack_position = self._current_position_to_append_stack.pop()
node_to_append_list = [self._node_stack.pop() for node in self._node_stack[node_stack_position+1:]]
node_to_append_list.reverse()
sibling_node = self._node_stack.pop()
for node in node_to_append_list:
sibling_node.addprevious(node)
elif localname == 'insert-after':
node_stack_position = self._current_position_to_append_stack.pop()
node_to_append_list = [self._node_stack.pop() for node in self._node_stack[node_stack_position+1:]]
sibling_node = self._node_stack.pop()
for node in node_to_append_list:
sibling_node.addnext(node)
elif localname == 'rename':
node = self._node_stack.pop()
if ':' in content:
#Transform QName to compatible Tag name for lxml
prefix, localname = content.split(':')
uri = self.nsmap.get(prefix)
content = '{%s}%s' % (uri, localname)
#Update nsmap of existing node is forbiden,
#So create a new node and replace it
new_node = Element(content, nsmap={prefix: uri})
for child in node:
new_node.append(deepcopy(child))
new_node.text = node.text
new_node.tail = node.tail
for k, v in node.attrib.items():
new_node.attrib[k] = v
parent = node.getparent()
if parent is not None:
node.getparent().replace(node, new_node)
else:
#if root Element
self.result_tree._setroot(new_node)
else:
node.tag = content
elif localname == 'processing-instruction':
#Stay orphans do not remove from stack
node = self._node_stack[-1]
node.text = content
elif localname == 'comment':
#Stay orphans do not remove from stack
node = self._node_stack[-1]
node.text = content
elif localname == 'variable':
pass
elif localname == 'value-of':
pass
else:
raise NotImplementedError(localname)
else:
node_stack_position = self._current_position_to_append_stack.pop()
node_to_append_list = [self._node_stack.pop() for node in self._node_stack[node_stack_position:]]
#Stay orphans do not remove from stack
node = self._node_stack[-1]
node.extend(node_to_append_list)
if len(node):
node[-1].tail = content
else:
node.text = content
def endDocument(self):
[node.getparent().remove(node) for node in self._to_remove_node_list]
\ No newline at end of file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import xml.sax
from lxml import etree
from cStringIO import StringIO
from content_handler import XUpdateHandler
def applyXUpdate(xml_xu_file=None,
xml_doc_file=None,
xml_xu_string=None,
xml_doc_string=None,
xml_xu_filename=None,
xml_doc_filename=None):
etree_parser = etree.XMLParser(remove_blank_text=True)
if xml_xu_file:
xml_xu = xml_xu_file
if xml_xu_string:
xml_xu = StringIO(xml_xu_string)
if xml_xu_filename:
xml_xu = xml_xu_filename
if xml_doc_file:
xml_doc = xml_doc_file
if xml_doc_string:
xml_doc = StringIO(xml_doc_string)
if xml_doc_filename:
xml_doc = xml_doc_filename
original_tree = etree.parse(xml_doc, etree_parser)
parser = xml.sax.make_parser()
parser.setFeature('http://xml.org/sax/features/namespaces', True)
parser.setFeature('http://xml.org/sax/features/namespace-prefixes', True)
parser.setContentHandler(XUpdateHandler(original_tree=original_tree))
parser.parse(xml_xu)
content_handler = parser.getContentHandler()
return content_handler.result_tree
if __name__ == '__main__':
import sys
doc_xml_name = sys.argv[1]
xu_xml_name = sys.argv[2]
print etree.tostring(applyXUpdate(xml_xu_filename=xu_xml_name, xml_doc_filename=doc_xml_name), pretty_print=True)
\ No newline at end of file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##############################################################################
#
# Nicolas Delaby <nicolas@nexedi.com>
#
# Copyright (C) 2009 Nexedi SA
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsability of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# garantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from xupdate_processor import main
main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment