The TinyTree doesn't include parent pointers: I experimented at one stage to
include them, but found that on balance, they are rarely worth the cost of
creating them and the memory they use. If a node is reached by downwards
traversal then it will often remember the identity of its parent, but if
not, Saxoin 6.5.3 searches backwards, effectively looking at all preceding
nodes in the document until it finds one with a shallower depth.
In 7.x and 8.x there is a parent pointer in the last sibling, so a search
for the parent node now searches forwards through all the siblings (a
shorter search than searching all preceding nodes at any level). But it
remains true that if you have a very wide tree (e.g. 10000 records at the
top level) then a search for the parent can be slow. I think that the
current release has also got better at "remembering" the parent of a node as
it scans down the tree. The main case where the parent is not remembered is
when you find a node using the descendant axis (or //).
It might be possible to redesign your code so that the parent is remembered
when you find the child, or (as you suggest) keys could help. Alternatively,
see what happens if you use the alternative "standard tree" model (-ds).
Was this advice useful? If you benefit from the help given, especially on a
commercial project, you can help us to continue to provide this service by
making a donation. See
> -----Original Message-----
> From: saxon-help-admin@...
> [mailto:saxon-help-admin@...] On Behalf Of
> Brett Knights
> Sent: 03 September 2004 05:58
> To: saxon-help@...
> Subject: [saxon] Speed of ancestor-or-self axis
> I am trying to process a 14MB xml file into many html pages.
> I am using
> Saxon 6.5.3.
> I am using code based on Mike's ShowBooks example to only
> read the xml
> once, set a target node as a parameter to each transform and then
> process the whole tree for each page.
> I need to process the whole tree each time because I am building
> navigation links for each page that depend on the whole site-map.
> As soon as I start using the ancestor-or-self axis in my XPath
> expressions the speed of page generation drops way off. The
> hierarchy is
> more wide than deep (not more than 6 levels) so looking up an
> hierarchy shouldn't be that much of a hit.
> Has anyone else encountered a similar problem and come up with an
> acceptable solution? i.e. is is possible to build a key for
> all ancestor
> Brett Knights
> This SF.Net email is sponsored by BEA Weblogic Workshop
> FREE Java Enterprise J2EE developer tools!
> Get your free copy of BEA WebLogic Workshop 8.1 today.
> saxon-help mailing list