[xml] libxslt and dynamic functions

Is there any interest here in adding dynamic extension-function
resolution to libxslt?

What I mean is that, instead of having to register functions with the
xslt engine, one would have them automatically resolved by the xslt
engine searching for 'plugins'.

To do this libxslt would only need to be enhanced with some code to
allow a single function to be called whenever an extension function
was required (instead of having to bind extension names directly to
real callable things).

I'm thinking about doing this. I think it would increase usability of
programming extension functions for libxslt. It would be especially
good if there were dynamic handlers for languages other than C that
could participate in the dynamism. For example, if a python dynloader
could be called by the C engine and resolve an extension function to a
python callable.

If the python (ruby, perl, whatever) handler could then do some
standard xpath type handling (to convert strings into xpath strings
and lists and iterators into DOMs for example) then it would be
*really easy* to add functions to xslt.

I'm thinking of code like this XSLT:

   <xsl:template name="something">
      <xsl:apply-templates select="pythonfunc:people_of_age(35)"/>

   <!-- 'items' is produced by the people_of_age() callable -->
   <xsl:template match="items">

which calls this Python:

  def people_of_age(age):
     con = somedb.connect(os.environ["DBURL"])
     rs = con.execute("select * from people where age = %d" % (age))
     for r in rs:
        yield r
     return None

What do people here think?


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]