[xslt] extension function, python, nodeset ?
- From: Frédéric Glorieux <fred fictif org>
- To: xslt gnome org
- Subject: [xslt] extension function, python, nodeset ?
- Date: Thu, 05 Apr 2007 21:00:22 +0200
Hi,
First, thanks for libxml2 and libxslt.
I would like to implement some python functions in xslt context. I found
how to parse a nodeset as an input, but not found a way to give multiple
nodes as output. Do someone know an example somewhere on the web, or a
documentation of the python API ?
To explain the goal, I need different regexp tagging, for example a kind
of hiliter, from a list of terms.
<glossary>
<entry>
<term>important</term>
<term>word</term>
<definition>
Authors may know what are their important words, but don't <span>feel
important to tag it, even if search engines</span> and readers could
find good use of it. A <inline>word</inline> already tagged.
</definition>
</entry>
</glossary>
<xsl:template match="definition/text() | span/text()">
<xsl:copy-of select="my:hilite( ancestor::entry/term , .)"/>
</xsl:template>
How to output a nodeset like below from my:hilite() function ?
result="""Authors may know what are their <tag>important</tag>
<tag>word</tag>s, but don't <span>feel <tag>important</tag> to tag it,
even if search engines</span> and readers could find good use of it. A
<inline>word</inline> already tagged."""
For now I'm parsing that as a doc, so a root element is needed.
return [libxml2.parseDoc( "<needed>" + result + "</needed>"
).getRootElement()]
Thanks for hints and better practices.
--
Fr�ric Glorieux <http://fictif.org/>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]