Stuart Hemming
Stuart Hemming

Reputation: 1663

Importing or Including XSLT files from a resource

I'm working on an app where there are a number of XSL stylesheets in use. These stylesheets are stored as resources in the DLL.

I want to include or import another stylesheet in to the running one. Now, I can make this work if the included stylesheet is in the same folder as the running one, but I need to include one in a different folder.

<xsl:include href ="../Folder/transform.xslt"/>

causes an error to be thown when the containing stylesheet is loaded. The server looks to c:\Windows\Folder\transform.xslt which, obviously, isn't there.

Can anyopne suggest how I do this? mI can find next to nothing about running a transform from an enbedded resource and, sadly, I have no choice but to do it this way.

Upvotes: 2

Views: 996

Answers (1)

Mitch
Mitch

Reputation: 22291

Not sure exactly how it would go, but I theorize it would be done by passing a custom XmlResolver to load the references from resources.

Implement a class that inherits from XmlResolver and looks in resources instead of the filesystem (which would be location the default XmlUrlResolver would look to).


Update: It looks like MSDN has had this problem before. See http://msdn.microsoft.com/en-us/library/aa302284.aspx for an example of how to implement a custom XmlResolver.

Upvotes: 1

Related Questions