473,573 Members | 2,424 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.xsl t
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.FreeThre adedDOMDocument .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 XsltCompileExce ption 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:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:include href="/Library/abo.Library.xsl t"/>
.....
</xsl:stylesheet>

and my C# code snippet for the transformation

XslTransform transform = new XslTransform();
XmlUrlResolver resolver = new XmlUrlResolver( );
resolver.Creden tials = System.Net.Cred entialCache.Def aultCredentials ;
transform.Load( Server.MapPath( "/Organization/OrganizationSea rch.xslt"),
resolver);
Any ideas will be much appreciated

Gideon de Swardt
Nov 18 '05 #1
6 2913
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*******@aspe ngrove.net> wrote in message
news:ub******** ******@tk2msftn gp13.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.xsl t 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.FreeThre adedDOMDocument .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 XsltCompileExce ption 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:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:include href="/Library/abo.Library.xsl t"/>
.....
</xsl:stylesheet>

and my C# code snippet for the transformation

XslTransform transform = new XslTransform();
XmlUrlResolver resolver = new XmlUrlResolver( );
resolver.Creden tials = System.Net.Cred entialCache.Def aultCredentials ;
transform.Load( Server.MapPath( "/Organization/OrganizationSea rch.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\wwwr oot\webapp
where as the library folder is c:\common\libra ry

so the url resolver will try and return
c:\inetpub\wwwr oot\webapp\Libr ary\abo.Library .xslt instead of
c:\common\libra ry\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\libra ry 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*******@hotm ail.com> wrote in message
news:%2******** *******@TK2MSFT NGP11.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*******@aspe ngrove.net> wrote in message
news:ub******** ******@tk2msftn gp13.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.xsl t
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.FreeThre adedDOMDocument .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 XsltCompileExce ption 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:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:include href="/Library/abo.Library.xsl t"/>
.....
</xsl:stylesheet>

and my C# code snippet for the transformation

XslTransform transform = new XslTransform();
XmlUrlResolver resolver = new XmlUrlResolver( );
resolver.Creden tials = System.Net.Cred entialCache.Def aultCredentials ;
transform.Load( Server.MapPath( "/Organization/OrganizationSea rch.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/OrganizationSea rch.xslt"
, resolver);

or

transform.Load( "http://some IP
Address/site/Organization/OrganizationSea rch.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.Configur ation.Configura tionSettings.Ap pSettings["RootUrl"] +
"/Organization/OrganizationSea rch.xslt", resolver);

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

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

Greetings
Martin
"Gideon de Swardt" <gd*******@aspe ngrove.net> wrote in message
news:es******** ******@TK2MSFTN GP10.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\wwwr oot\webapp
where as the library folder is c:\common\libra ry

so the url resolver will try and return
c:\inetpub\wwwr oot\webapp\Libr ary\abo.Library .xslt instead of
c:\common\libra ry\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\libra ry 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*******@hotm ail.com> wrote in message
news:%2******** *******@TK2MSFT NGP11.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*******@aspe ngrove.net> wrote in message
news:ub******** ******@tk2msftn gp13.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.xsl t
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.FreeThre adedDOMDocument .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 XsltCompileExce ption 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:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:include href="/Library/abo.Library.xsl t"/>
.....
</xsl:stylesheet>

and my C# code snippet for the transformation

XslTransform transform = new XslTransform();
XmlUrlResolver resolver = new XmlUrlResolver( );
resolver.Creden tials = System.Net.Cred entialCache.Def aultCredentials ;

transform.Load( Server.MapPath( "/Organization/OrganizationSea rch.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.W ebControls.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*******@aspe ngrove.net> wrote in message
news:eC******** *****@tk2msftng p13.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.W ebControls.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.W ebControls.Xml
{
public System.Xml.XmlU rlResolver UrlResolver;
protected override void Render(HtmlText Writer writer)
{
Company.Web.Pag e thePage = (Company.Web.Pa ge) this.Page;
//TransformArgume ntList
this.TransformA rgumentList = new XsltArgumentLis t();

this.TransformA rgumentList.Add ExtensionObject ("http://www.company.net/XslLib
rary", new Company.Library ());
//XmlUrlResolver
if (this.UrlResolv er == null)
{
this.UrlResolve r = new XmlUrlResolver( );
this.UrlResolve r.Credentials =
System.Net.Cred entialCache.Def aultCredentials ;
}
//Load Transform Source
if (this.Transform Source.Length > 0)
{
string transformSource = thePage.UrlBase +
thePage.Resolve Url(this.Transf ormSource); //thePage.UrlBase returns the base
url eg. http://localhost
this.TransformS ource = null;
base.Transform = new XslTransform();
base.Transform. Load(transformS ource, this.UrlResolve r);
}
//Render
base.Render(wri ter);
}
}
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
2557
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 fixed header and a variable document part. The header is the same in each page and is described in an XML document, "Head.xml". The document part, which is variable in content, is described in...
1
3589
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 by version 1 of XSLT processor and the other by version 2 of XSLT processor based on some condition. Q) How and where shall I write logic or import desirable XSLT on the Fly ? Q) When we call...
2
3221
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 this behavior to me! First off the xslt file is being loaded as in dim myXSLT as new XslTransform() myXSLT.load("scripts/clnt.home.body.xslt") The load craps out when I change the...
1
1676
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 xsl:include statement as <xsl:include href="inc.template.methods.xsl"/> I now I have to pass a resolver when I use the load method so that it understands the xsl include as in:
1
1679
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 precisely template from a precisely XSL file, that I have already included. The name of this template is the same that from a file XML.
0
1840
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, LOC.XML One is a list of products,PROD.XML I have 2 separate XSL files.
2
1443
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 different files, it does not work anymore. But they do work when they are implemented in the same file. So I think there is something wrong with the way I include the files or call them. This is how...
3
2656
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 ($fileName) which I want to add to http://tempuri.org/ then attach .xsd to the end
3
3589
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. I've tried several different approaches: <xsl:include href="concat( 'i18n-', $locale, '-include.xslt)"/> fails with XSLT compile error: FileNotFoundException
0
7747
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7987
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8180
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7740
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6363
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5263
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3706
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2167
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1269
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.