xsl-list
[Top] [All Lists]

RE: Identity of Documents Puzzle

2002-12-09 02:33:23
This is all tested with Saxon 6.5.2 and depends on, at a 
minimum, that 
multiple calls to document() with the same URL will result in 
the same 
document node instance (and ideally, calls to the same file system 
object (e.g., inode in *nx file systems) would result in the same 
document node instance).

My question: is there any way, other than passing in the 
filename of the 
top-level file as a parameter to the style sheet, to ensure that the 
node for the document as created by the initial style sheet 
processing 
is the same as one for a call to document() for the same file 

First point is, that "the same file" is not a concept that any XSLT
processor will recognize. The closest you can get it "the same URI". No
XSLT processor is going to recognize that http://saxon.sf.net/index.html
is the same file as http://saxon.sourceforge.net/index.html

The rule that two calls on document() supplying the same absolute URI
will return the same document node is defined in the XSLT spec, and most
processors are likely to implement it using some kind of mapping table
from URIs to nodes. In Saxon this is referred to as the "document pool".

Saxon doesn't include the initial input document in the document pool.
There is no requirement in the XSLT spec that says it should, though I
think there is also no requirement that prevents it, in those cases
where the absolute URI is known. If you want, you can add it yourself
using ((Controller)transformer).getDocumentPool().add(x,y). You could
also intercept the call on document() by means of a user-written
URIResolver, which would be a more portable solution.

Michael Kay
Software AG
home: Michael(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>