/usr/share/doc/python-simpletal/html/api-simpleelementtree.html is in python-simpletal 4.1-7.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>SimpleTAL API: simpleElementTree Module.</title>
<link href="../style/site.css" type="text/css" rel="stylesheet">
</head>
<body>
<h1>SimpleTAL API: simpleElementTree Module.</h1>
<p id="subject">Documentation on how to use the simpleElementTree Module.</p>
<div><h2>simpleElementTree</h2>
<p>This module provides optional integration with <a href="http://effbot.org/zone/element-index.htm" title="ElementTree XML parsing library">ElementTree</a>, allowing XML documents to be parsed and placed directly into the Context. The contents of the XML document can then be accessed using an sub-set of XPATH from within TAL templates.</p>
<h3>parseFile (file)</h3>
<p>This function takes one parameter, which should be either a file-like object or a string holding the name of a file on the filesystem. The file is read, the XML it contains is parsed, and an instance of simpleTALES.ContextVariable is returned.</p>
<p>The returned ContextVariable can then be added to the Context using addGlobal in the normal way, e.g.</p>
<pre>
<code>xmlTree = simpleElementTree.parseFile (file="input.xml")
context = simpleTALES.Context(allowPythonPath=1)
context.addGlobal ("input", xmlTree)</code>
</pre>
<h2>ElementTree Paths</h2>
<p>The Context variable provided by parseFile provides the following syntax for path access in TAL:</p>
<ul>
<li>Accessing the variable directly returns the Text value for this node.</li>
<li>Accessing variable/find/path returns the first node to match the path, as supported by ElementTree (see <a href="http://effbot.org/zone/element-xpath.htm">XPath Support in ElementTree</a>).</li>
<li>Accessing variable/findall/path returns a list of nodes that match the path, as supported by ElementTree (see <a href="http://effbot.org/zone/element-xpath.htm">XPath Support in ElementTree</a>).</li>
<li>Accessing variable@name returns the XML attribute "name".</li>
<li>Accessing variable/anotherElement is a short-cut for variable/find/anotherElement.</li>
</ul>
<p>Here are some examples:</p>
<pre>
<code><html>
<body>
<h1 tal:attributes="class input/title/@type" tal:content="input/title">Title here</h1>
<ul>
<li tal:repeat="note input/findall/.//note">
<b tal:condition="note/@type" tal:replace="string: Note (${note/@type}) - $note and then some"></b>
</li>
</ul>
</body>
</html></code>
</pre>
</div>
<p id="version">PubTal Version </p>
<div id="footer">
<p>File: api-simpleelementtree.txt</p>
<p>Last modified: Tue, 08 Feb 2005 14:41:32 EST</p>
<p>Copyright 2005 Colin Stewart</p>
<p title="PubTal is a template driven web site publisher.">Made with <a href="http://www.owlfish.com/software/PubTal/">PubTal</a> 3.1.3</p>
</div>
</body>
|