Re: [xslt] namespace declaration not copied



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).

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.

Any thoughts?
-- Luca

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total
 time   seconds   seconds    calls   s/call   s/call  name
 42.00     19.10    19.10  4444620     0.00     0.00  xmlSearchNs
 14.89     25.87     6.77 224138093     0.00     0.00  xmlStrEqual
 11.21     30.97     5.10 21301959     0.00     0.00  xmlStrdup
  5.67     33.55     2.58  5552943     0.00     0.00  xmlFreeNodeList
  4.33     35.52     1.97 12768898     0.00     0.00  xmlStaticCopyNode
  2.11     36.48     0.96 21540463     0.00     0.00  xmlStrndup
  1.58     37.20     0.72  7966663     0.00     0.00
xmlStaticCopyNodeList
  1.17     37.73     0.53  5348665     0.00     0.00  xmlCopyProp
  1.08     38.22     0.49  2636541     0.00     0.00  xsltGetNamespace
  1.01     38.68     0.46 16190397     0.00     0.00  xsltNextImport





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