Changeset 3091:c76ff5ea4766 in livinglogic.python.xist

Show
Ignore:
Timestamp:
01/02/08 18:57:52 (12 years ago)
Author:
Walter Doerwald <walter@…>
Branch:
default
Message:

Update transformation doc (separate sections, update code).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • docs/Transformation.xml

    r3086 r3091  
    1 <section><title>Manipulating trees</title> 
    2 <par>&xist; provides many methods for manipulating an &xml; tree.</par> 
     1<par>Apart from the <pyref module="ll.xist.xsc" class="Node" method="convert"><method>convert</method></pyref> 
     2method, &xist; provides many tools for manipulating an &xml; tree.</par> 
     3 
     4 
     5<section><title>The <method>withsep</method> method</title> 
    36 
    47<par>The method <pyref module="ll.xist.xsc" class="Frag" method="withsep"><method>withsep</method></pyref> 
     
    1013<prompt>&gt;&gt;&gt; </prompt><input>from ll.xist import xsc</input> 
    1114<prompt>&gt;&gt;&gt; </prompt><input>from ll.xist.ns import html</input> 
    12 <prompt>&gt;&gt;&gt; </prompt><input>node = html.div(*xrange(10))</input> 
     15<prompt>&gt;&gt;&gt; </prompt><input>node = html.div(xrange(10))</input> 
    1316<prompt>&gt;&gt;&gt; </prompt><input>print node.withsep(", ").bytes()</input> 
    1417&lt;div&gt;0, 1, 2, 3, 4, 5, 6, 7, 8, 9&lt;/div&gt; 
    1518</tty> 
     19 
     20</section> 
     21 
     22 
     23<section><title>The <method>shuffled</method> method</title> 
    1624 
    1725<par>The method <pyref module="ll.xist.xsc" class="Frag" method="shuffled"><method>shuffled</method></pyref> 
     
    2230<prompt>&gt;&gt;&gt; </prompt><input>from ll.xist import xsc</input> 
    2331<prompt>&gt;&gt;&gt; </prompt><input>from ll.xist.ns import html</input> 
    24 <prompt>&gt;&gt;&gt; </prompt><input>node = html.div(*xrange(10))</input> 
     32<prompt>&gt;&gt;&gt; </prompt><input>node = html.div(xrange(10))</input> 
    2533<prompt>&gt;&gt;&gt; </prompt><input>print node.shuffled().withsep(", ").bytes()</input> 
    2634&lt;div&gt;8, 1, 3, 6, 7, 5, 2, 9, 4, 0&lt;/div&gt; 
    2735</tty> 
     36 
     37</section> 
     38 
     39 
     40<section><title>The <method>reversed</method> and <method>sorted</method> methods</title> 
    2841 
    2942<par>There are methods named <pyref module="ll.xist.xsc" class="Frag" method="reversed"><method>reversed</method></pyref> 
     
    3548<prompt>&gt;&gt;&gt; </prompt><input>from ll.xist.ns import html</input> 
    3649<prompt>&gt;&gt;&gt; </prompt><input>def key(n):</input> 
    37 <prompt>... </prompt><input>   return unicode(n)</input> 
     50<prompt>... </prompt><input>    return unicode(n)</input> 
    3851<prompt>&gt;&gt;&gt; </prompt><input>node = html.div(8,4,2,1,9,6,3,0,7,5)</input> 
    3952<prompt>&gt;&gt;&gt; </prompt><input>print node.sorted(key=key).reversed().withsep(",").bytes()</input> 
    4053&lt;div&gt;9,8,7,6,5,4,3,2,1,0&lt;/div&gt; 
    4154</tty> 
     55 
     56</section> 
     57 
     58 
     59<section><title>The <method>mapped</method> method</title> 
    4260 
    4361<par>The method <pyref module="ll.xist.xsc" class="Node" method="mapped"><method>mapped</method></pyref> 
     
    5573    return node 
    5674 
    57 node = parsers.parseURL("http://www.python.org/", tidy=True) 
     75node = parsers.parseurl("http://www.python.org/", tidy=True) 
    5876node = node.mapped(p2p) 
    5977node.write(open("parrot_index.html", "wb")) 
     
    6482old node to tell <pyref module="ll.xist.xsc" class="Node" method="mapped"><method>mapped</method></pyref> 
    6583that it should recursively continue with the content of the node.</par> 
     84 
    6685</section>