[xslt] Few questions
- From: Carlo Contavalli <ccontavalli libero it>
- To: xslt gnome org
- Subject: [xslt] Few questions
- Date: Mon, 8 Sep 2003 11:41:54 +0200
Hi!
I'm almost done writing a module using libxml/libxslt (mainly
2.5.7 and 1.0.30), and I have a few question marks still to answer:
- (libxslt) the module provides some extension tags (registered
with xsltRegisterExtElement). The function handling one of the
extension tags needs to retrieve all the text that would
be expanded by the xslt processor in the corresponding ``subtree''.
To do this, I've used:
xsltEvalTemplateString(...)
is this correct? If my tag contains a <fallback handler, however,
althought working correctly, I keep getting the non-fatal error:
xsltApplyOneTemplate: fallback was not compiled
is there another function I should use? What can I do to avoid
the error (something smarter than removing the fallback node
from the tree)?
- (libxml) Some xml documents that get parsed use external entityes
fetched from http urls. I get an uncoherent behavior due to the fact
that if the dtd does not exist on the local file system, I get a sort
of warning telling me the dtd does not exist, but parsing goes on.
However, when it is fetched from a remote url, the http status of
the request is not checked and if the document does not exist
libxml tryes to parse the error page as if it was the DTD, leading
to a fatal error (it is quite uncommon to have a 404 page
containing a valid DTD).
So, if the dtd does not exist on the local file system -> ignorable
warning, if it does not exist on a remote url -> parsing stops with
an error not always easy to understand (Extra content at the end
of the document... but where did it get the document?). Is this
an expected behavior? Is there something I can do to avoid the
problem?
- (libxslt) The application changes the error handlers, calling
xsltSetGenericErrorFunc with its own handler and its own
context. However, I sometimes get segfault due to transform.c
calling xsltGenericError(xsltGenericDebugContext, where
xsltGenericDebugContext is a different (unknown) data
type than the one expected by my handler as GenericErrorContext.
Is this behavior expected? How can I make sure
xsltGenericError gets called only with its own context
(without enabling debugging - still there in 1.0.32)?
- (libxml) The application I'm talking about is _not_ multithreaded
(at least by default). However, it is made
of a list of modules being called in a big loop, where
more than a module may make use of the libxml library in
the same thread of execution. libxml makes use of many global
variables, some of which may be changed to customize its
behavior. Actually, to avoid one module influencing the
parsing of another module, I compile libxml with multithreading
support and save the ``state'' of the library by copying
the memory area returned by xmlGetGlobalState with memcpy
and by restoring it after the module has executed, leading
to something like:
At module initialization
- create new global state (malloc and InitializeGlobalState)
- save global state (GetGlobalState and memcpy)
- overwrite the global state with the one created above
- (change libxml defaults)
- save my own global state
- restore previous global state
At module execution (in the big loop)
- save global state
- overwrite the global state with my own
- (work with libxml)
- restore global state
Is there a better way to do this? Is there any other
solution than copying every single global variable
when multithreading is disabled? I've looked at the
source code, and I believe it would be nice to let
the applications access the statics NewGlobalState
and FreeGlobalState, and to have a SetGlobalState
that acts directly on the tsd variables being used
(if you believe it worth, I could easily provide the
needed code).
- (libxslt) What's the status for libxslt? I haven't seen
any threading support and the only globals I've seen
are those for error handling.
Am I on the safe side (with regard to the problem
highlited above) if I save and restore just them
before and after running the module?
Sorry for the long mail and sorry for the OT about libxml, but
I really didn't know how to best split the mail. Feel free to
answer me on any of the two lists.
Thanks in advance,
Cheers,
Carlo
--
GPG Fingerprint: 2383 7B14 4D08 53A4 2C1A CA29 9E98 5431 1A68 6975
-------------
A computer lets you make more mistakes faster than any other invention,
with the possible exceptions of handguns and Tequilla.
-- Mitch Ratcliffe
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]