AW: [xslt] Extension module initialization is called for everyimported stylesheet
- From: "Buchcik, Kasimier" <k buchcik 4commerce de>
- To: <veillard redhat com>, "The Gnome XSLT library mailing-list" <xslt gnome org>
- Cc:
- Subject: AW: [xslt] Extension module initialization is called for everyimported stylesheet
- Date: Wed, 3 May 2006 13:28:57 +0200
Hi,
> -----Ursprüngliche Nachricht-----
> Im Auftrag von Daniel Veillard
> On Wed, May 03, 2006 at 07:56:58AM +0400, Oleg A. Paraschenko wrote:
> > Hello,
> >
> > On Tue, 2 May 2006 17:18:59 -0400
> > Daniel Veillard <veillard redhat com> wrote:
> >
> > > On Tue, May 02, 2006 at 09:31:40PM +0200, Buchcik, Kasimier wrote:
> > > > Hi,
> > > >
> > > > Extension module initialization functions will be called
> > > > once for every imported stylesheet (plus the main stylesheet).
> > > > The initialization function is the "xsltStyleExtInitFunction"
> > > > argument of the xsltRegisterExtModuleFull() function.
> > > > Is this the intended design? I.e., is the initialization
> > > > expected to be called for *every* imported stylehsheet and not
> > > > only once for a whole stylesheet compilation episode?
> >
> > As far as I remember, more precise behaviour is the following.
> > Initialization is expected for every (imported or main)
> stylesheet which
> > has the corresponding "extension-element-prefixes".
What is the reason of this expectation?
> > >
> > > It's probably an oversight, once per stylesheet should
> be sufficient.
> >
> > Do you mean "once per the whole stylesheet"? I think it is
> not sufficient.
> >
> > I have a chain of imported xslt-files that looks like:
> >
> > -- [code]
> > <x:stylesheet extension-element-prefixes="myx" ...>
> >
> > <myx:init>...</myx:init>
<myx:init> is not an extension element, so actually there
should be no need to use "extension-element-prefixes" here.
> > ...
> >
> > </x:stylesheet>
> > --- [/code]
> >
> > When my xsltStyleExtInitFunction is activated, it looks for
> "myx:init" and
> > performs additional initialization for the corresponding
> xslt file. If the
> > function were called only once, I'd have problems to locate
> all "myx:init"
> > in all xslt files.
I am in doubt about the correctness of this approach; or, if
we want to avoid the word "correct": I think this is more a hack
than a solution following the semantics of XSLT.
You are using the "extension-element-prefixes" mechanism
(which, I think, should not fire an initialization at all), to
process the user-defined data element <myx:init>.
"User-defined data" elements (this is a term which was introduced
in XSLT 2.0) and the definition of namespaces of extension elements
are not related.
With xsltRegisterExtModuleTopLevel() you can register such
top-level user-defined data elements to be processed.
I tried to test this with EXSLT's "function":
"func-2.xsl"
------------
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:func="http://exslt.org/functions"
xmlns:foo="urn:test:foo">
<func:function name="foo:func-2"/>
</xsl:stylesheet>
"func-2-imp.xsl"
----------------
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:func="http://exslt.org/functions"
xmlns:foo="urn:test:foo">
<xsl:import href="func-2-imp.xsl"/>
<func:function name="foo:func-1"/>
</xsl:stylesheet>
Both function definitions will be processed via the
following call-chain:
...
--> xsltParseStylesheetTop()
--> xsltExtModuleTopLevelLookup()
--> exsltFuncFunctionComp():
Here the content of func:function will be processed.
I think the correct way would be to register your
top-level elements with:
xsltRegisterExtModuleTopLevel ((const xmlChar *) "init",
(const xmlChar *) "urn:test:init",
myInitCompilation);
> okay, then Kasimier has his answer, ignore mine :-)
>
> Daniel
Quite to the contrary; I fear the explanation of Oleg has opened
even more issues on my side. I'll start a new thread for the
issues I see.
Regards,
Kasimier
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]