Project

Profile

Help

Bug #4083

closed

Performance of shallow copy with namespaces

Added by Michael Kay over 5 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Sprint/Milestone:
-
Start date:
2018-12-28
Due date:
% Done:

0%

Estimated time:
Applies to JS Branch:
Trunk
Fix Committed on JS Branch:
Fixed in JS Release:
SEF Generated with:
Platforms:
Company:
-
Contact person:
-
Additional contact persons:
-

Description

By default xsl:copy is required to copy all in-scope namespaces. Saxon-JS does this very literally.

Imagine you are using a recursive shallow copy to copy a tree with a depth of 10, in which 12 namespaces are declared on the root element. Every time an element is copied, we call DomUtils.inScopeNamespaces() to get a complete list of its namespaces (which involves examining every attribute of every ancestor to see whether it is actually a namespace declaration, and eliminating redundant declarations as we go); each non-redundant declaration is then added as an attribute node on the new copied element (without any check for redundancy). As a result every node in the result tree has 12 attributes representing namespaces. A second copy operation from this tree to a third tree will now have to examine 120 namespace attributes, eliminate most of them as redundant and copy the remainder to the third tree.

In Saxon/J we reduce these costs by passing a virtual namespaceBindings object which is very quickly constructed because it is actually just a wrapper for the element node; when adding these namespaceBindings to the new element we first check whether the namespaceBindings are the same as the bindings for the parent of the new node, in which case no action is needed.

Please register to edit this issue

Also available in: Atom PDF Tracking page