[4suite-checkins] In Amara/docs, files manual.xml

Uche Ogbuji uogbuji at 4suite.org
Sat Dec 2 16:35:18 MST 2006


Modified Files:
    manual.xml

Log Message:
1.2b1 release

ViewCVS diff:
  http://cvs.4suite.org/viewcvs/Amara/docs/manual.xml.diff?r1=1.11&r2=1.12
ViewCVS view:
  http://cvs.4suite.org/viewcvs/Amara/docs/manual.xml?rev=1.12&content-type=text/vnd.viewcvs-markup

Index: manual.xml
===================================================================
RCS file: /var/local/cvsroot/Amara/docs/manual.xml,v
retrieving revision 1.11
retrieving revision 1.12
diff -U2 -r1.11 -r1.12
--- manual.xml	26 Nov 2006 16:59:04 -0000	1.11
+++ manual.xml	2 Dec 2006 23:35:18 -0000	1.12
@@ -1024,5 +1024,27 @@
         </programlisting>
       </section>
-      <section id="wsstripping">
+          <section id="omit-nodetype">
+                <title>Omitting certain node types entirely</title>
+                <para>You can also omit processing instructions, comments or text nodes from a document using the <command>omit_nodetype_rule</command> rule.  The rule takes a single parameter which can be one of the three node types <command>xml.dom.Node.COMMENT_NODE</command>, <command>xml.dom.Node.PROCESSING_INSTRUCTION_NODE</command> or <command>xml.dom.Node.TEXT_NODE</command>.</para>
+                <para>In the following example there are no bindings created for comments:</para>
+                <programlisting><![CDATA[import amara
+from amara import binderytools
+from xml.dom import Node
+
+DOCUMENT = """<!-- Printing the best language --> <language>Python</language>"""
+
+rules = [binderytools.omit_nodetype_rule(Node.COMMENT_NODE)]
+
+doc = amara.parse(DOCUMENT, rules = rules)
+
+print doc.xml()]]>
+                </programlisting>
+                <para>With the resulting output:</para>
+                <programlisting><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
+<language>Python</language> 
+                      ]]>
+                </programlisting>
+          </section>
+          <section id="wsstripping">
         <title>Stripping whitespace</title>
         <para>A common need is to strip out pure whitespace nodes so that they don't clutter up "children" lists. Bindery bundles the <command>ws_strip_element_rule</command> rule for this purpose.  Elements that match the pattern are stripped of whitespace.</para>


More information about the 4suite-checkins mailing list