Re: [xml] Deep-copy of xsltStylesheetPtr?
- From: Daniel Veillard <veillard redhat com>
- To: Rasmus Lerdorf <rasmus lerdorf com>
- Cc: xml gnome org
- Subject: Re: [xml] Deep-copy of xsltStylesheetPtr?
- Date: Sat, 18 Sep 2004 06:08:14 -0400
On Fri, Sep 17, 2004 at 04:46:40PM -0700, Rasmus Lerdorf wrote:
Probably a very lame question. Feel free to RTFM me to the right set of
docs or an example somewhere.
I am looking for a way to get a deep-copy of an xsltStylesheetPtr the same
way I can copy an xmlDocPtr using xmlMemSetup() and xmlCopyDoc().
Hum, there is no API for this, it was never needed so far.
It may also be a big problem if you try to decouple memory areas, let me
explain:
- we use string interning for document parsing, using a dictionnary
stored in doc->dict.
- when compiling a stylesheet we try to use the same set of strings
so inherit the doc->dict in the style->dict. In general the stylesheet
and the document(s) it was build from are deeply related. There
is pointers from the doc compiled elements to the stylesheet and
from the stylesheet to the doc. The stylesheet doc is modified
in the process.
Copying the xsltStylesheetPtr would mean duplicating the doc first too.
I think the simplest is to reparse the stylesheet. Honnestly it's usually
a really fast operation, I doubt it would much cheaper to try to rebuild
all the relationship between a copy of the original document and a new
copy of the original stylesheet structure.
Some explanations about the compilation are at
http://xmlsoft.org/XSLT/internals.html
The dictionnary unification is also used for string interning of the
processed document, which allows to use pointer comparison for a lot of
internal operation when the transformation occurs instead of doing
string content compare.
It seems you are using memory pools (the xmlMemSetup() trick) I think
this makes copy even harder, it becomes impossible to reuse the original
dictionnary and just increment its use count. Seems in such a situation
the best is to copy the initial document and recompile the stylesheet.
Daniel
--
Daniel Veillard | Red Hat Desktop team http://redhat.com/
veillard redhat com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]