Firstly, the argument to document() is not a filename, but a URI. You don’t explain what the actual contents of the string are. Filenames and URIs are not the same thing, though some products bend the rules by accepting filenames in places where URIs are expected.
If the contents are a relative URI, you need to take some care to ensure that they are resolved correctly. In the normal case, I would expect the value to be a URI that is relative to the base URI of the source document. If this is the case, you should pass the node itself to the document() function, not a variable containing a copy of the string content of the node. You can do this by writing
<xsl:variable name=“fileName” select=“/family/child[1]/familyFile”/>
The document() function has a special rule that says if the argument is a node rather than a string, then the URI contained in the node is resolved relative to that node, not relative to the stylesheet.
Using the select attribute of xsl:variable is in any case good practice. Writing an xsl:variable that contains a single xsl:value-of instruction is generally very inefficient, compared with using the select attribute of xsl:variable directly. This is because it causes unnecessary construction of a result tree fragment.
Michael Kay
#Tamino#webMethods#API-Management