Re: [xslt] namespace declaration not copied



On Thu, Sep 11, 2003 at 10:26:33AM +0200, Luca Padovani wrote:
> On Wed, 2003-09-10 at 18:27, Daniel Veillard wrote:
> > data model and declaration of namespace. A namespace node in
> > the XPath data model just indicate that the given namespace binding
> > is in effect on that node, this does not mean that when that
> > node is serialized a namespace declaration must be emitted.
> 
> Thank you for the clarification and the pointers to the specs. The
> reason why I was investigating it is that because of the way namespaces
> are implemented in libxml2, an innocent-looking
> 
> 	<xsl:copy-of .../>
> 
> may have an exponential cost (in time), as if the node being copied has
> a namespace, a search is done all the way up the source document until
> the declaration of the namespace is found (see xmlStaticCopyNode in
> libxml2/tree.c). If you do this many times, and your documents are deep,
> and the declaration of the namespace is, say, on the root element, then
> you can say goodbye to performance. BTW, since namespace lookup involves
> string comparison, this is another case where string sharing would cut
> costs down dramatically (see the fragment of profile attached).

  yep, agreed. String sharing for for read-only document is not far
in the pipeline, XSLT will be a candidate for reuse.

> I haven't found a workaround for this problem yet, but my impression is
> that the implementation should not be affected so tightly on where
> namespaces are declared, whether they are close or far away, etc.

  Well either you duplicate namespace information everywhere,
but use a lot of memory or you have to do that lookup. Libxml2
trees do not duplicate the info, as a result they need that lookup.

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.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]