473,396 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 2898
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 fixed header and a variable document part. The...
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 by version 1 of XSLT processor and the other by...
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 this behavior to me! First off the xslt file is...
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 xsl:include statement as <xsl:include...
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 precisely template from a precisely XSL file, that...
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, LOC.XML One is a list of products,PROD.XML I...
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 different files, it does not work anymore. But they...
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 ($fileName) which I want to add to ...
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. I've tried several different approaches: ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.