472,340 Members | 1,742 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,340 software developers and data experts.

XmlUrlResolver xsl:include

I am trying to do a server side transformation using an xsl:include in my
xslt stylesheet. The include stylesheet is stored /Library/abo.Library.xslt
and is included in multiple xslts, one example would be
/Valuation/ValuationSelect.xslt which is also used on the client side via
JavaScript and MSXML2.FreeThreadedDOMDocument.4.0. Client side the include
and transformation without any problems but it is when I am trying to do the
transformation on the server that I do get a XsltCompileException and
IOException error "the network path was not found". Worth mentioning also is
that the Library is a virtual folder in IIS, although I would have thought
that the XmlUrlResolver would resolve this problem for me it does not look
like it.

Here is the header of my xslt
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="/Library/abo.Library.xslt"/>
.....
</xsl:stylesheet>

and my C# code snippet for the transformation

XslTransform transform = new XslTransform();
XmlUrlResolver resolver = new XmlUrlResolver();
resolver.Credentials = System.Net.CredentialCache.DefaultCredentials;
transform.Load(Server.MapPath("/Organization/OrganizationSearch.xslt"),
resolver);
Any ideas will be much appreciated

Gideon de Swardt
Nov 18 '05 #1
6 2831
Hi, Gideon de Swardt,

The problem is that your includes are web-relative *and* dependent on the
root of the web-application, but the XmlUrlResolver tries to resolve them
relatively to the filesystem, because you pass the first parameter of the
Load method as a file:\\. You should either pass the absolute url of the
document (http://) or you should change the includes to be relative to the
document and independent of the web-application structure (using ../ instead
of /).

Hope this helps
Martin

"Gideon de Swardt" <gd*******@aspengrove.net> wrote in message
news:ub**************@tk2msftngp13.phx.gbl...
I am trying to do a server side transformation using an xsl:include in my
xslt stylesheet. The include stylesheet is stored /Library/abo.Library.xslt and is included in multiple xslts, one example would be
/Valuation/ValuationSelect.xslt which is also used on the client side via
JavaScript and MSXML2.FreeThreadedDOMDocument.4.0. Client side the include
and transformation without any problems but it is when I am trying to do the transformation on the server that I do get a XsltCompileException and
IOException error "the network path was not found". Worth mentioning also is that the Library is a virtual folder in IIS, although I would have thought
that the XmlUrlResolver would resolve this problem for me it does not look
like it.

Here is the header of my xslt
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="/Library/abo.Library.xslt"/>
.....
</xsl:stylesheet>

and my C# code snippet for the transformation

XslTransform transform = new XslTransform();
XmlUrlResolver resolver = new XmlUrlResolver();
resolver.Credentials = System.Net.CredentialCache.DefaultCredentials;
transform.Load(Server.MapPath("/Organization/OrganizationSearch.xslt"),
resolver);
Any ideas will be much appreciated

Gideon de Swardt

Nov 18 '05 #2
Hi Martin

Thanks for your response

but

dont want to specify the url cause same solution might be installed on
different servers using different versions of this file.

tried relative path but because my Library folder is virtual directory in
IIS and the physical location on the file system is outside the root of the
website i returns the wrong path and returns an IOException example

webroot folder is c:\inetpub\wwwroot\webapp
where as the library folder is c:\common\library

so the url resolver will try and return
c:\inetpub\wwwroot\webapp\Library\abo.Library.xslt instead of
c:\common\library\abo.library.xslt. I would have thought that the Resolver
would be able to resolve urls across virtual folders. The reason for the
virtual folder is that multiple websites use the same folder and all have a
virtual folder pointing to the c:\common\library folder.

and the last thing i want to do is hard code the location of this file in
the xslt using file:// cause then i would not be able to use the xslt on the
client side.
so the question is what to do

Regards

G
"Martin Dechev" <de*******@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
Hi, Gideon de Swardt,

The problem is that your includes are web-relative *and* dependent on the
root of the web-application, but the XmlUrlResolver tries to resolve them
relatively to the filesystem, because you pass the first parameter of the
Load method as a file:\\. You should either pass the absolute url of the
document (http://) or you should change the includes to be relative to the
document and independent of the web-application structure (using ../ instead of /).

Hope this helps
Martin

"Gideon de Swardt" <gd*******@aspengrove.net> wrote in message
news:ub**************@tk2msftngp13.phx.gbl...
I am trying to do a server side transformation using an xsl:include in my xslt stylesheet. The include stylesheet is stored /Library/abo.Library.xslt
and is included in multiple xslts, one example would be
/Valuation/ValuationSelect.xslt which is also used on the client side via JavaScript and MSXML2.FreeThreadedDOMDocument.4.0. Client side the include and transformation without any problems but it is when I am trying to do

the
transformation on the server that I do get a XsltCompileException and
IOException error "the network path was not found". Worth mentioning also is
that the Library is a virtual folder in IIS, although I would have

thought that the XmlUrlResolver would resolve this problem for me it does not look like it.

Here is the header of my xslt
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="/Library/abo.Library.xslt"/>
.....
</xsl:stylesheet>

and my C# code snippet for the transformation

XslTransform transform = new XslTransform();
XmlUrlResolver resolver = new XmlUrlResolver();
resolver.Credentials = System.Net.CredentialCache.DefaultCredentials;
transform.Load(Server.MapPath("/Organization/OrganizationSearch.xslt"),
resolver);
Any ideas will be much appreciated

Gideon de Swardt


Nov 18 '05 #3
Hi, Gideon de Swardt,

You should use something like:

transform.Load("http://domain.com/site/Organization/OrganizationSearch.xslt"
, resolver);

or

transform.Load("http://some IP
Address/site/Organization/OrganizationSearch.xslt", resolver);

for the website-root-relative paths to be resolved.

You can store the the first part of the url in a config file and change it
for each solution. i.e.:

transform.Load(
System.Configuration.ConfigurationSettings.AppSett ings["RootUrl"] +
"/Organization/OrganizationSearch.xslt", resolver);

and in the web.config or the app.config:

<configuration>
<appSettings>
<add key="RootUrl" value="http://domain.com/site" />
</appSettings>
</configuration>

Greetings
Martin
"Gideon de Swardt" <gd*******@aspengrove.net> wrote in message
news:es**************@TK2MSFTNGP10.phx.gbl...
Hi Martin

Thanks for your response

but

dont want to specify the url cause same solution might be installed on
different servers using different versions of this file.

tried relative path but because my Library folder is virtual directory in
IIS and the physical location on the file system is outside the root of the website i returns the wrong path and returns an IOException example

webroot folder is c:\inetpub\wwwroot\webapp
where as the library folder is c:\common\library

so the url resolver will try and return
c:\inetpub\wwwroot\webapp\Library\abo.Library.xslt instead of
c:\common\library\abo.library.xslt. I would have thought that the Resolver
would be able to resolve urls across virtual folders. The reason for the
virtual folder is that multiple websites use the same folder and all have a virtual folder pointing to the c:\common\library folder.

and the last thing i want to do is hard code the location of this file in
the xslt using file:// cause then i would not be able to use the xslt on the client side.
so the question is what to do

Regards

G
"Martin Dechev" <de*******@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
Hi, Gideon de Swardt,

The problem is that your includes are web-relative *and* dependent on the
root of the web-application, but the XmlUrlResolver tries to resolve them relatively to the filesystem, because you pass the first parameter of the Load method as a file:\\. You should either pass the absolute url of the
document (http://) or you should change the includes to be relative to the document and independent of the web-application structure (using ../

instead
of /).

Hope this helps
Martin

"Gideon de Swardt" <gd*******@aspengrove.net> wrote in message
news:ub**************@tk2msftngp13.phx.gbl...
I am trying to do a server side transformation using an xsl:include in my xslt stylesheet. The include stylesheet is stored

/Library/abo.Library.xslt
and is included in multiple xslts, one example would be
/Valuation/ValuationSelect.xslt which is also used on the client side via JavaScript and MSXML2.FreeThreadedDOMDocument.4.0. Client side the include and transformation without any problems but it is when I am trying to do the
transformation on the server that I do get a XsltCompileException and
IOException error "the network path was not found". Worth mentioning also
is
that the Library is a virtual folder in IIS, although I would have

thought that the XmlUrlResolver would resolve this problem for me it does not look like it.

Here is the header of my xslt
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="/Library/abo.Library.xslt"/>
.....
</xsl:stylesheet>

and my C# code snippet for the transformation

XslTransform transform = new XslTransform();
XmlUrlResolver resolver = new XmlUrlResolver();
resolver.Credentials = System.Net.CredentialCache.DefaultCredentials;

transform.Load(Server.MapPath("/Organization/OrganizationSearch.xslt"), resolver);
Any ideas will be much appreciated

Gideon de Swardt



Nov 18 '05 #4
Thanks Martin

I changed my code to point to the abs url
http://localhost/Valuation/ValuationSelect.xslt and that works if i use the
XslTransform object, but if I use System.Web.UI.WebControls.Xml to do the
transformation I can not pass the full url as the TransformSource, i receive
the following error.

Invalid path for MapPath
'/Valuation/http://localhost/Valuation/ValuationSelect.xslt'. A virtual path
is expected.

Is there any way to indicate to the Xml Control not to use virtual paths but
absolute paths, without writing my own control to do the transformation for
me?

Regards

Gideon
Nov 18 '05 #5
Hi, Gideon,

Could you please post the code that illustrates the problem. Is there a
particular reason to use the TransformSource property instead of assigning
an instance of XslTransform class to the property Transform? Like it is done
in the example for the Xml class topic:

http://msdn.microsoft.com/library/en...sformtopic.asp

Greetings
Martin
"Gideon de Swardt" <gd*******@aspengrove.net> wrote in message
news:eC*************@tk2msftngp13.phx.gbl...
Thanks Martin

I changed my code to point to the abs url
http://localhost/Valuation/ValuationSelect.xslt and that works if i use the XslTransform object, but if I use System.Web.UI.WebControls.Xml to do the
transformation I can not pass the full url as the TransformSource, i receive the following error.

Invalid path for MapPath
'/Valuation/http://localhost/Valuation/ValuationSelect.xslt'. A virtual path is expected.

Is there any way to indicate to the Xml Control not to use virtual paths but absolute paths, without writing my own control to do the transformation for me?

Regards

Gideon

Nov 18 '05 #6
The TransformSource property is set in the aspx page rather than in the
compiled C# code, which allows for customization between multiple websites
without changing source code and having to re-compile the binaries.

My work around for this was to create a custom web control as bellow, which
also allowed me to set my default ArgumentLists as well, while loading the
base.Transform Xslt with the full url and XmlUrlResolver.

public class Xml : System.Web.UI.WebControls.Xml
{
public System.Xml.XmlUrlResolver UrlResolver;
protected override void Render(HtmlTextWriter writer)
{
Company.Web.Page thePage = (Company.Web.Page) this.Page;
//TransformArgumentList
this.TransformArgumentList = new XsltArgumentList();

this.TransformArgumentList.AddExtensionObject("htt p://www.company.net/XslLib
rary", new Company.Library());
//XmlUrlResolver
if (this.UrlResolver == null)
{
this.UrlResolver = new XmlUrlResolver();
this.UrlResolver.Credentials =
System.Net.CredentialCache.DefaultCredentials;
}
//Load Transform Source
if (this.TransformSource.Length > 0)
{
string transformSource = thePage.UrlBase +
thePage.ResolveUrl(this.TransformSource); //thePage.UrlBase returns the base
url eg. http://localhost
this.TransformSource = null;
base.Transform = new XslTransform();
base.Transform.Load(transformSource, this.UrlResolver);
}
//Render
base.Render(writer);
}
}
Thanks for all your help

Regards

Gideon de Sward
Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Vince C. | last post by:
Hi all, I've created XML documents that are described with a schema. I'm using those documents to create web pages. All my web pages contain a...
1
by: Mohit | last post by:
Hi Friends I have to call 1 of the 2 child XSLT files from the Main XSLT file based on some criteria. I want one child XSLT file will be executed...
2
by: Keith Chadwick | last post by:
I have been running some tests with regards to xsl:include and xsl:import with the same results on both and I am wondering if someone can explain...
1
by: Keith Chadwick | last post by:
Have been doing a fair amount of reading but at this point no joy. The scenario is - XSL template is stored within db. - Template has a...
1
by: lele1979 | last post by:
Hi XSL Community, I would do a file in PDF with FO and XSL/XML tecnology. In a precisely moment of a creation of this PDF file I must call a...
0
by: jephperro | last post by:
Hi, I'm trying to do something with multiple xml files and am wondering if it is possible. I have 2 XML feeds: One is a list of locations,...
2
by: sandra55 | last post by:
Hi, I need to include different stylesheets in my stylesheet so that I can use their stylesheet. However, as soon as I have my stylesheets in...
3
markmcgookin
by: markmcgookin | last post by:
Hi, I know this is a common issue, but to be honest all the sites I find with solutions to this dont explain it well at all. I have a variable...
3
by: Simon Brooke | last post by:
I'm trying to do internationalisation by using xsl:include to include a different file depending on the locale setting, and I'm completely failing....
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.