Menu

#59 Fragment id's in document() eat memory

v6.5
closed
5
2012-10-08
2002-02-06
Michael Kay
No

The XSLT 1.0 specification says that when document()
is called twice with the same URI, you get the same
document back each time. The "same URI" means the URI
after stripping any fragment identifier, so that
document("abc.xml#ijk") should give you a reference to
a node with the same root as document("abc.xml#pqr").

But Saxon is comparing the URIs without stripping the
fragment identifier, so a new document is loaded each
time. This eats processing time (for the parsing) and
memory (for multiple copies of the document), and it's
also a non-conformance with the spec, since the
identity of the resulting nodes can be compared using
generate-id() or the union (|) operator.

Applies to 6.5 and 7.0, and to all earlier releases
since 6.1, when fragment identifiers were first
supported.

Discussion

  • Michael Kay

    Michael Kay - 2002-02-06

    Logged In: YES
    user_id=251681

    I've now cleared this (in both source code branches). The
    fix does involve some potential impact on applications.
    Previously, using a URI reference such as "abc.xml#z001"
    returned a tree representing the subset of the XML document
    abc.xml, with the element having ID z001 as its outermost
    element. Now, it constructs a tree for the whole of
    document abc.xml, and returns a reference to the element
    with ID z001 - which will no longer be the document element
    of this tree.

    Another effect is that if you have a user-written
    URIResolver, it will never be passed the fragment
    identifier from a call on the document() function. However,
    the URIResolver does still handle fragment identifiers in
    other contexts, for example when dealing with the xml-
    stylesheet processing instruction.

    Mike Kay

     
  • Michael Kay

    Michael Kay - 2002-02-20

    Logged In: YES
    user_id=251681

    Cleared in 6.5.1, still present in 7.0

     
  • Michael Kay

    Michael Kay - 2002-04-30

    Logged In: YES
    user_id=251681

    Fixed in 7.1