xsl-list
[Top] [All Lists]

RE: Using document()

2002-10-10 01:30:49
why is it necessary to do
document('foo#bar') rather than do

<xsl:for-each select="document('foo')">
<xsl:value-of select="id('bar')"/>
</xsl:for-each>


The ONLY thing I know is that I'm not going to get anything 
more complex than a bare XPointer to a node with an ID. It 
could be in the input file or it could be in an external file. 

To do anything like what you suggest would require a bit of 
string manipulation (although granted its not that hard). 


I would recommend that you do the string manipulation.

You might be able to achieve the right effect with a URIResolver, but it
won't work on all products. There is an awkward interaction between the
URIResolver specification and the rule that if you access the same
document twice, you must get the same root node back each time. This
puts the XSLT processor in a quandary when you do:

document('foo#john') | document('foo#mary')

Saxon solves this dilemma by not passing the fragment to the
URIResolver. This might seem unfriendly, but there is some logic to it:
the specification for URIResolver says clearly that it is intended to
resolve a URI, not a "URI Reference", and the fragment is not actually
part of the URI. It also follows the same logic as HTML browsers, where
the request for a URI is passed to the server, and the location of a
fragment is the responsibility of the client.

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>