Re: [xsl] document()

Subject: Re: [xsl] document()
From: "M. David Peterson" <m.david@xxxxxxxxxx>
Date: Sun, 07 Nov 2004 07:21:33 -0800
Gabriel K. wrote:

The error I get is "The object can't be found". Everything works fine if the XML file resides in the same folder as the XSL file.

Q: what processor are you using for transformation (e.g. Saxon, Xalan, MSXML, System.Xml.Xsl.Transform() (.NET))? The problem you are encountering could very well be based on the processor you are using and the credentials the processor is using. While any fully XSLT 1.0 compliant (which all of the previously stated processors, among others, are) will work by using the method I suggested you may be confined to only the directory your stylesheet is contained in do to constraints put upon any processes (not just XSLT) that try to run outside of there approved "environment" (read: "folder" in this case). This will be especially true when running on either a Java or .NET based application server.


If you can let me know the XSLT processor and the environment either myself or someone else who has dealt with your specific situation before will be able to help you get "unstuck".

Best regards!

<M:D/>


/Gabriel


----- Original Message ----- From: "M. David Peterson" <m.david@xxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Sunday, November 07, 2004 3:33 AM
Subject: Re: [xsl] document()



Hello Gabriel,

There are two ways to use the document() function. One is to use a string representation of the path to the directory in which the file is contained. To tell the processor that this is a string representation you need to use single quotes:

document('/mickel/XML/xml_file.xml')

Keep in mind that this will only work if 'mickel' is at the root of your directory. Another way to locate the correct file would be to use:

document('../../XML/xml_file.xml')

Your current approach tells the processor to locate the 'xml_file.xml' child element of /mickel/XML and use its value as a string representation of the file to use which, if it does not exist, will simply be ingored and leave you with an empty string for the document() function to work with. Obviously an empy string doesnt do a lot for you.

Hope this helps!

Regards,

<M:D/>


Gabriel K. wrote:


I want to open an xml file that resides in a folder that is a above the xsl file in which document() is used (to access the xml file).

The XSL file resides here (under the web root):
/mickel/XSL/PC/

and the XML file resides here (under the web root);
/mickel/XML


I have tried to use document(/mickel/XML/xml_file.xml), but it doesn't seem to work. Should this work? Can I reference the web root folder with "/"?




/Gabriel

Current Thread