M
Maxim Kazitov
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.GetEntity('{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.ResolveUri('{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" ?>
........................................................................
........................................................................
<xslaram name="paramFilename"/>
<xsl:variable name="docActualsFile" select="document($paramFilename)"/>
........................................................................
........................................................................
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.GetEntity('{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.ResolveUri('{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" ?>
........................................................................
........................................................................
<xslaram name="paramFilename"/>
<xsl:variable name="docActualsFile" select="document($paramFilename)"/>
........................................................................
........................................................................