Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: ASP and XML/XSL error

From: "Mike Sharp" <rdcpro@-------.--->
To: NULL
Date: 1/3/2005 11:34:00 PM
> If I have two files, same name, different folder, which one will be found
> first using Server.MapPath?  Does it look alphabetically or does it look 
> at
> an unsorted list as to when the folders were created?
>

Only one will ever be found; the one that is in the folder mapped to the 
virtual name.  Server.MapPath only converts a virtual path to a physical 
path. It gets that information from the IIS mapping for the site.  So when 
you said

loadXMLFile "freight100_0a.xml", "freight.xsl"

the parser was looking who knows where for the file.  Actually, it's 
probably looking relative to where the ASP dll is.  Who knows.

But Server.MapPath("freight100_0a.xml") returns the actual filesystem path 
of the file specified in the string.  In this case it's assuming the file is 
in the same virtual directory as the ASP page.  If this is not the case, 
you'll get an error.  If your ASP page is in

c:\inetpub\wwwroot\mySite\myActiveServerPage.asp

then

Server.MapPath("freight100_0a.xml")

will be the same thing as writing

c:\inetpub\wwwroot\mySite\freight100_0a.xml

If the file isn't there, it won't look anywhere else--it just fails. If you 
use

Server.MapPath("/dev/freight100_0a.xml")

this means the file is located in the dev subfolder of your current virtual 
directory.


As a further example, if you look in your IIS manager, you might have a web 
with the URL:

http://myserver.com/foo/bar

This may be mapped to

c:\inetpub\wwwroot\mySite\someotherdirectory\foo\bar

and if in an ASP page located in "bar" you have

Server.MapPath("myXML.xml")

it will replace the virtual path with the filesystem path.  So in this case, 
it will return:

"c:\inetpub\wwwroot\mySite\someotherdirectory\foo\bar\myXML.xml"

If you use

Server.MapPath("/foo/bar/myXML.xml")

it will return the same value:

"c:\inetpub\wwwroot\mySite\someotherdirectory\foo\bar\myXML.xml"

If you use:

Server.MapPath("snafu/myXML.xml")

then it's going to assume there is a sub folder called "snafu" in the "bar" 
folder.  In this case:

"c:\inetpub\wwwroot\mySite\someotherdirectory\foo\bar\snafu\myXML.xml"
maps to:
http://myserver.com/foo/bar/snafu/myXML.xml

If there file isn't there, you get an error.  It won't search subfolders, or 
any other place at all.

Regards,
Mike Sharp 




transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent