473,385 Members | 1,353 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,385 software developers and data experts.

XmlUrlResolver & document()

Hi,

I try to use document() function in XSLT, but looks like .Net XSLT parser don't try to resolve external URL. Does any body know what can be wrong here :
=================C#==========================
public class XmlUrlResolverExt:XmlUrlResolver
{
private static readonly ILog log = LogFactory.GetLogger(System.Reflection.MethodBase. GetCurrentMethod().DeclaringType);

public XmlUrlResolverExt() : base() { }
public override object GetEntity(Uri uri, string role, Type type)
{
log.Debug(string.Format("XmlUrlResolverExt.GetEnti ty('{0}','{1}','{2}')",uri.ToString(), role, type.ToString()));
return base.GetEntity(uri, role, type);
}
public override Uri ResolveUri(Uri uri, string relativeUri)
{
log.Debug(string.Format("XmlUrlResolverExt.Resolve Uri('{0}','{1}')", uri.ToString(), relativeUri));
return base.ResolveUri(uri, relativeUri);
}
}
.................................................. ...................
.................................................. ...................

XslTransform oProcessor = new XslTransform();
XsltArgumentList oXslArgs = new XsltArgumentList();
XmlUrlResolverExt oResolver = new XmlUrlResolverExt();
XmlTextWriter oWriter = new XmlTextWriter("Output.xml", System.Text.Encoding.UTF8);

oResolver.Credentials = new NetworkCredential("User", "pwd", "domain");

oProcessor.Load(new XmlTextReader(pXSLTFile), new XmlUrlResolverExt());

oXslArgs.AddParam("paramFilename", "", sFileName); // sFileName - network path in following format \\server\share\file.xml

oProcessor.Transform(oXmlDoc, oXslArgs, oWriter, oResolver);

==================XSLT======================

<?xml version="1.0" encoding="UTF-8" ?>
.................................................. ......................
.................................................. ......................
<xsl:param name="paramFilename"/>
<xsl:variable name="docActualsFile" select="document($paramFilename)"/>
.................................................. ......................
.................................................. ......................

------------------------------------------
Thanks,
Maxim
Nov 12 '05 #1
6 1853
Maxim Kazitov wrote:
public override Uri ResolveUri(Uri uri, string relativeUri)
{

log.Debug(string.Format("XmlUrlResolverExt.Resolve Uri('{0}','{1}')",
uri.ToString(), relativeUri));


That's the problem. uri is null, so ResolveUri method throws an
exception and so resolving process gets skipped.

--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com
Nov 12 '05 #2
Yes, you are right, I fix it And ResolveUri working fine, but I don't see any call's for GetEntity, and XSLT doesn't work any way.
"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message news:u%****************@TK2MSFTNGP10.phx.gbl...
Maxim Kazitov wrote:
public override Uri ResolveUri(Uri uri, string relativeUri)
{

log.Debug(string.Format("XmlUrlResolverExt.Resolve Uri('{0}','{1}')",
uri.ToString(), relativeUri));


That's the problem. uri is null, so ResolveUri method throws an
exception and so resolving process gets skipped.

--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com

Nov 12 '05 #3
I try to include file://<SERVER>/<DIR>/SOME.XML and looks like it's
doesn't work for file:// protocol (all MSDN examples related to HTTP
protocol).
"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:u%****************@TK2MSFTNGP10.phx.gbl...
Maxim Kazitov wrote:
public override Uri ResolveUri(Uri uri, string relativeUri)
{

log.Debug(string.Format("XmlUrlResolverExt.Resolve Uri('{0}','{1}')",
uri.ToString(), relativeUri));


That's the problem. uri is null, so ResolveUri method throws an exception
and so resolving process gets skipped.

--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com

Nov 12 '05 #4
Looks like I found the problems (thanks to all).

Interesting links :
http://msdn.microsoft.com/library/de...l/xinclude.asp

http://msdn.microsoft.com/xml/defaul.../cusxmlres.asp
http://support.microsoft.com/kb/325692/EN-US/

"Maxim Kazitov" <mv*****@tut.by> wrote in message news:ub**************@TK2MSFTNGP14.phx.gbl...
I try to include file://<SERVER>/<DIR>/SOME.XML and looks like it's
doesn't work for file:// protocol (all MSDN examples related to HTTP
protocol).


"Oleg Tkachenko [MVP]" <oleg@NO!SPAM!PLEASEtkachenko.com> wrote in message
news:u%****************@TK2MSFTNGP10.phx.gbl...
Maxim Kazitov wrote:
public override Uri ResolveUri(Uri uri, string relativeUri)
{

log.Debug(string.Format("XmlUrlResolverExt.Resolve Uri('{0}','{1}')",
uri.ToString(), relativeUri));


That's the problem. uri is null, so ResolveUri method throws an exception
and so resolving process gets skipped.

--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com


Nov 12 '05 #5
Maxim Kazitov wrote:
I try to include file://<SERVER>/<DIR>/SOME.XML and looks like it's
doesn't work for file:// protocol (all MSDN examples related to HTTP
protocol).


XmlUrlResolver class you are using is able to resolve file://, http://
and https:// protocols, see
http://msdn.microsoft.com/library/de...classtopic.asp.
The rest (such as network share) you have to implement yourself.
GetEntity doesn't get called when RersolveUri returns null.

--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com
Nov 12 '05 #6
Maxim Kazitov wrote:
Looks like I found the problems (thanks to all).

Interesting links :
http://msdn.microsoft.com/library/de...l/xinclude.asp


I'm glad you found my article interesting :) Beware that links in that
article are mostly dead. XInclude.NET is now a part of the Mvp.Xml
library, see http://mvp-xml.sf.net

--
Oleg Tkachenko [XML MVP, MCP]
http://blog.tkachenko.com
Nov 12 '05 #7

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

Similar topics

6
by: mali_djuro | last post by:
Hi all, i used JDOM to create XML file. first, i get data from database and create Document object. in some data i have quotas, so it makes replacment in content of elements. for example: if i...
4
by: johkar | last post by:
When the output method is set to xml, even though I have CDATA around my JavaScript, the operaters of && and < are converted to XML character entities which causes errors in my JavaScript. I know...
6
by: Gideon de Swardt | last post by:
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...
11
by: Jeremy | last post by:
How can one stop a browser from converting &amp; to & ? We have a textarea in our system wehre a user can type in some html code and have it saved to the database. When the data is retireved...
1
by: pachyphloia | last post by:
I have a problem understanding what is happening when inheriting from XmlUrlResolver. Using standard settings (including the default XmlResolver) I can use a dtd given in the doctype for...
6
by: cj | last post by:
I'm receiving an xml formatted string that I pull data from by reading it into an xml document like this: Dim doc As New Xml.XmlDocument doc.LoadXml(respstr) Dim co_name As Xml.XmlNodeList =...
14
by: Arne | last post by:
A lot of Firefox users I know, says they have problems with validation where the ampersand sign has to be written as &amp; to be valid. I don't have Firefox my self and don't wont to install it only...
12
by: InvalidLastName | last post by:
We have been used XslTransform. .NET 1.1, for transform XML document, Dataset with xsl to HTML. Some of these html contents contain javascript and links. For example: // javascript if (a &gt; b)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?

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.