[Lxml-checkins] r52027 - in lxml/trunk: . doc
scoder at codespeak.net
scoder at codespeak.net
Sun Mar 2 09:31:32 CET 2008
Author: scoder
Date: Sun Mar 2 09:31:32 2008
New Revision: 52027
Modified:
lxml/trunk/ (props changed)
lxml/trunk/doc/extensions.txt
Log:
r3666 at delle: sbehnel | 2008-03-02 08:56:20 +0100
r3656 at delle: sbehnel | 2008-03-02 07:52:50 +0100
reverted doc changes
Modified: lxml/trunk/doc/extensions.txt
==============================================================================
--- lxml/trunk/doc/extensions.txt (original)
+++ lxml/trunk/doc/extensions.txt Sun Mar 2 09:31:32 2008
@@ -1,20 +1,11 @@
-Python extensions for XPath and XSLT
-====================================
+Extension functions for XPath and XSLT
+======================================
This document describes how to use Python extension functions in XPath
and XSLT like this::
<xsl:value-of select="f:myPythonFunction(.//sometag)" />
-It also describes how to use Python extension elements in XSLT like
-this::
-
- <xsl:template match="*">
- <my:python-extension>
- <some-content />
- </my:python-extension>
- </xsl:template>
-
Here is how an extension function looks like. As the first argument,
it always receives a context object (see below). The other arguments
are provided by the respective call in the XPath expression, one in
@@ -27,14 +18,6 @@
>>> def loadsofargs(dummy, *args):
... return "Got %d arguments." % len(args)
-And here is how an extension element looks like::
-
- >>> from lxml import etree
- >>> class MyExtElement(etree.XSLTExtension):
- ... def execute(self, context, self_node, input_node, output_parent):
- ... # just copy own content input to output
- ... output_parent.extend( list(self_node) )
-
.. contents::
..
@@ -54,6 +37,7 @@
FunctionNamespace class. For simplicity, we choose the empty namespace
(None)::
+ >>> from lxml import etree
>>> ns = etree.FunctionNamespace(None)
>>> ns['hello'] = hello
>>> ns['countargs'] = loadsofargs
More information about the lxml-checkins
mailing list