[xml] registering a extension module in libxslt



hi all,

below is a code snippet, when executing it and loading the stylesheet the
extension module initialisation gets not triggered and later I get:

libxslt-error: xsltValueOf: text copy failed
[gitk-core:gitkerrors.c:95] : libxml-error: xmlXPathCompOpEval: function gettext
not found
[gitk-core:gitkerrors.c:95] : libxml-error: Unregistered function

The URI does definitely match (it uses the same constant definition).
I had a look at the libxslt source, but e.g. things like
xsltRegisterExtFunction() are not called verbatim anymore (params come from hashes).

@daniel could you please extend the example at
http://xmlsoft.org/XSLT/extensions.html
with example calls to xsltRegisterExtModule() and xsltRegisterExtFunction() and
a xslt snipped that is using the extension?

Many thanks
  Stefan

--------------

...
if(xsltRegisterExtModule(I18N_NS_URL,xsltExtInit_i18n,xsltExtShutdown_i18n)) {
  gitk_err("failed to register extension modules (i18n)");
  result=FALSE;
}
...
if(!(xsl_i18n=xsltParseStylesheetFile(XSL_PATH"i18n.xsl"))) {
  gitk_err("failed to load stylesheet (i18n.xsl)");
  result=FALSE;
}
...

void *xsltExtInit_i18n(xsltTransformContextPtr ctxt, const xmlChar *URI) {
  gitk_log_intro();
  gitk_log1(">>>>>>>>>> URI=\"%s\"",URI);
  if(xsltRegisterExtFunction(
    ctxt,"gettext",URI,xmlXPathEvalFunc_i18n_gettext)
  ) {
    gitk_err("failed to register extension function (i18n)");
  }
  gitk_log_outro();
  return(NULL);
}

void xsltExtShutdown_i18n(xsltTransformContextPtr ctxt,const xmlChar *URI,void
*data) {
}

void xmlXPathEvalFunc_i18n_gettext(xmlXPathParserContextPtr ctxt, int nargs) {
  gitk_log_intro();
  gitk_log1(">>>>>>>>>> nargs=%d",nargs);
  gitk_log_outro();
}

-----------------

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  xmlns:giml="http://gitk.sourceforge.net/";
  xmlns:i18n="<I18N_NS_URL>"
  xmlns="http://gitk.sourceforge.net/";
  exclude-result-prefixes="giml">

<xsl:output method="xml" doctype-system="http://gitk.sourceforge.net/giml.dtd"/>

<xsl:template match="i18n:text">
  <xsl:value-of select="i18n:gettext(.)"/>
</xsl:template>
...

-- 
      \|/            Stefan Kost
     <@ @>           private            business
+-oOO-(_)-OOo------------------------------------------------------ - - -  -   -
|       __  Address  Simildenstr. 5     HTWK Leipzig, Fb IMN, Postfach 301166
|      ///           04277 Leipzig      04251 Leipzig
| __  ///            Germany            Germany
| \\\///    Phone    +49341 2253538     +49341 30766101
|  \__/     EMail    st_kost_at_gmx.net kost_at_imn.htwk-leipzig.de
|           WWW      www.sonicpulse.de  www.imn.htwk-leipzig.de/~kost/about.html
===-=-=--=---=---------------------------------- - - -  -    -

Attachment: kost.vcf
Description: Vcard



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