views:

22

answers:

1

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
Look's fine. But I'm receiving exception like "XmlResolver returned null..." (( path seems to be correct...
pukipuki
Are you passing the resolver when you call XslCompiledTrasform.Load ?
Max Toro
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
@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
The problem is in case sensitivity... lib's name has been translated into lower case in GetEntity method )
pukipuki
@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
@pukipuki: Or set `resolver.DefaultAssembly = Assembly.GetExecutingAssembly()`
Max Toro