Author: jmorliaguet
Date: Sun Apr 30 12:09:23 2006
New Revision: 2991

Modified:
   cpsskins/branches/paris-sprint-2006/setup/DOM.txt
   cpsskins/branches/paris-sprint-2006/setup/README.txt
Log:

- using minidom's toprettyxml() to prettify the XML writer's output
  and break long lines



Modified: cpsskins/branches/paris-sprint-2006/setup/DOM.txt
==============================================================================
--- cpsskins/branches/paris-sprint-2006/setup/DOM.txt   (original)
+++ cpsskins/branches/paris-sprint-2006/setup/DOM.txt   Sun Apr 30 12:09:23 2006
@@ -24,11 +24,14 @@
 
     >>> theme = root.appendChild(element)
 
-doc.toxml() creates an XML representation of the document:
-
-    >>> print doc.toxml() # doctest: +NORMALIZE_WHITESPACE
-    <?xml version="1.0" ?><themes><theme title="A theme" 
uri="cpsskins://canvas-theme:12345"/></themes>
+doc.toxml() or doc.toprettyxml() creates an XML representation of the document:
 
+    >>> print doc.toprettyxml(indent=u'  ', encoding=u'utf-8')
+    <?xml version="1.0" encoding="utf-8"?>
+    <themes>
+      <theme title="A theme" uri="cpsskins://canvas-theme:12345"/>
+    </themes>
+    <BLANKLINE>
 
 Exporting nested tree structures
 --------------------------------
@@ -73,9 +76,18 @@
 
     >>> from pprint import pprint
     >>> export(tree, root)
-    >>> print doc.toxml()
-    <?xml version="1.0" ?>
-    <themes><element title="Theme('A Theme')"><element title="ThemePage('A 
Theme page')"><element title="PageBlock('Top block')"><element 
title="Cell('Left cell')"/><element title="Cell('Main 
cell')"/></element></element></element></themes>
-
+    >>> print doc.toprettyxml(indent=u'  ', encoding=u'utf-8')
+    <?xml version="1.0" encoding="utf-8"?>
+    <themes>
+      <element title="Theme('A Theme')">
+        <element title="ThemePage('A Theme page')">
+          <element title="PageBlock('Top block')">
+            <element title="Cell('Left cell')"/>
+            <element title="Cell('Main cell')"/>
+          </element>
+        </element>
+      </element>
+    </themes>
+    <BLANKLINE>
 
 [1] http://docs.python.org/lib/module-xml.dom.html

Modified: cpsskins/branches/paris-sprint-2006/setup/README.txt
==============================================================================
--- cpsskins/branches/paris-sprint-2006/setup/README.txt        (original)
+++ cpsskins/branches/paris-sprint-2006/setup/README.txt        Sun Apr 30 
12:09:23 2006
@@ -505,7 +505,7 @@
     ...     exporter = getMultiAdapter((obj, doc), IDOMAdapter)
     ...     exporter.setDocument(document)
     ...     exporter.save()
-    ...     return document.toxml()
+    ...     return document.toprettyxml(indent=u'  ', encoding=u'utf-8')
 
 
 Export of styles
@@ -515,7 +515,16 @@
     >>> resource[u'div.body'] = {'color': u'red', 'border': u'none'}
 
     >>> print toXML(resource, u'styles')
-
+    <?xml version="1.0" encoding="utf-8"?>
+    <styles>
+      <style uri="cpsskins://format-style:12345">
+        <selector value="div.body">
+          <property name="color" value="red"/>
+          <property name="border" value="none"/>
+        </selector>
+      </style>
+    </styles>
+    <BLANKLINE>
 
 Export of relations
 -------------------
@@ -528,6 +537,13 @@
     ...                            first=Actions(u'Actions portlet'))
 
     >>> print toXML(relation, u'relations')
+    <?xml version="1.0" encoding="utf-8"?>
+    <relations>
+      <relation predicate="_ A">
+        <relate uri="cpsskins://canvas-portlet-standard.actions:12345"/>
+      </relation>
+    </relations>
+    <BLANKLINE>
 
 Dyadic relations:
 
@@ -539,6 +555,14 @@
     ...                           second=Breadcrumbs(u'Breadcrumbs portlet'))
 
     >>> print toXML(relation, u'relations')
+    <?xml version="1.0" encoding="utf-8"?>
+    <relations>
+      <relation predicate="_ B _">
+        <relate uri="cpsskins://canvas-portlet-standard.actions:12345"/>
+        <relate uri="cpsskins://canvas-portlet-standard.breadcrumbs:12345"/>
+      </relation>
+    </relations>
+    <BLANKLINE>
 
 Triadic relations:
 
@@ -551,6 +575,15 @@
     ...                            third=Slot(slot=u'slotA'))
 
     >>> print toXML(relation, u'relations')
+    <?xml version="1.0" encoding="utf-8"?>
+    <relations>
+      <relation predicate="_ C _ D _">
+        <relate uri="cpsskins://canvas-portlet-standard.actions:12345"/>
+        <relate uri="cpsskins://canvas-portlet-standard.breadcrumbs:12345"/>
+        <relate uri="cpsskins://canvas-slot:slotA"/>
+      </relation>
+    </relations>
+    <BLANKLINE>
 
 
 Export of elements
@@ -573,6 +606,24 @@
     >>> pageblock[u'cell1'][u'slot'] = slot
 
     >>> print toXML(pageblock, u'elements')
+    <?xml version="1.0" encoding="utf-8"?>
+    <elements>
+      <pageblock uri="cpsskins://canvas-pageblock:12345">
+        <title value="Some page block"/>
+        <cell uri="cpsskins://canvas-cell:12345">
+          <title value="Some cell 1"/>
+          <slot uri="cpsskins://canvas-slot:">
+            <title value="Some slot"/>
+            <description value=""/>
+            <slot value=""/>
+          </slot>
+        </cell>
+        <cell uri="cpsskins://canvas-cell:12345">
+          <title value="Some cell 2"/>
+        </cell>
+      </pageblock>
+    </elements>
+    <BLANKLINE>
 
 
 Export of container elements
@@ -583,7 +634,22 @@
     >>> theme = addThemeSkeleton(tmutil)
 
     >>> print toXML(theme, u'themes')
-
+    <?xml version="1.0" encoding="utf-8"?>
+    <themes>
+      <theme uri="cpsskins://canvas-theme:12345">
+        <title value="A theme"/>
+        <themepage uri="cpsskins://canvas-themepage:12345">
+          <title value="A page"/>
+          <pageblock uri="cpsskins://canvas-pageblock:12345">
+            <title value="A page block"/>
+            <cell uri="cpsskins://canvas-cell:12345">
+              <title value="A cell"/>
+            </cell>
+          </pageblock>
+        </themepage>
+      </theme>
+    </themes>
+    <BLANKLINE>
 
 Export of portlets
 ------------------
@@ -591,7 +657,14 @@
     >>> portlet = Actions(title=u'Action portlet', category=u'zmi_views')
 
     >>> print toXML(portlet, u'portlets')
-
+    <?xml version="1.0" encoding="utf-8"?>
+    <portlets>
+      <portlet uri="cpsskins://canvas-portlet-standard.actions:12345">
+        <title value="Action portlet"/>
+        <category value="zmi_views"/>
+      </portlet>
+    </portlets>
+    <BLANKLINE>
 
 Export of format elements
 -------------------------
@@ -600,7 +673,17 @@
     >>> effect = Effect(width=100, height=80) 
 
     >>> print toXML(effect, u'formats')
-
+    <?xml version="1.0" encoding="utf-8"?>
+    <formats>
+      <effect uri="cpsskins://format-effect:12345">
+        <types value=""/>
+        <format value="PNG"/>
+        <width value="100"/>
+        <height value="80"/>
+        <keep_ratio value="True"/>
+      </effect>
+    </formats>
+    <BLANKLINE>
 
 Resolving URIs
 ==============
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to