I want to use same xsl template in few websites. Can I add it into class library? If yes how can I Load it? Example of path, etc...
+1
A:
Yes you can, check out this article: http://www.tkachenko.com/blog/archives/000653.html
I've written an embedded resource resolver that resolves URLs like this:
clires://assembly-name/path-to-embedded-file/embedded-file.xsl
Max Toro
2010-09-02 17:38:06
Look's fine. But I'm receiving exception like "XmlResolver returned null..." (( path seems to be correct...
pukipuki
2010-09-08 13:55:43
Are you passing the resolver when you call XslCompiledTrasform.Load ?
Max Toro
2010-09-08 17:34:30
yep. And xsl-file build-action property is embedded-resource. XmlEmbeddedResourceResolver resolver = new XmlEmbeddedResourceResolver();xslt.Load("clires://RzhdOnline/xsl/eticket_mail.xsl", XsltSettings.TrustedXslt, resolver);
pukipuki
2010-09-08 18:14:34
@pukipuki: I'm not sure if XslCompiledTrasform uses the resolver for the principal stylesheet, I think only for imports. I suggest you debug and hit a breakpoint in the GetEntity method of the resolver, or you could just call Assembly.GetManifestResourceStream("RzhdOnline.xsl.eticket_mail.xsl")
Max Toro
2010-09-08 22:55:29
The problem is in case sensitivity... lib's name has been translated into lower case in GetEntity method )
pukipuki
2010-09-09 13:41:19
@pukipuki: You can also omit the host delimiter if the resource is in the calling assembly, try clires:RzhdOnline/xsl/eticket_mail.xsl
Max Toro
2010-09-09 16:19:45
@pukipuki: Or set `resolver.DefaultAssembly = Assembly.GetExecutingAssembly()`
Max Toro
2010-09-09 16:24:55