I have a xslt file, myxslt.xslt, that contains an import, that looks a bit like this:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="someOtherXsltFile.xslt"/>
<!--Do some transformations -->
</xsl:stylesheet>
I am trying to import these files into my C# application by using the assembly:
Assembly assembly = Assembly.GetExecutingAssembly();
using (Stream xsltStream = assembly.GetManifestResourceStream(mynamespace.myxslt.xslt))
{
using (XmlReader xsltReader = XmlReader.Create(xsltStream))
{
xslt.Load(xsltReader);
}
}
as I saw in this answer: Adding (Embedded Resource) Schema To XmlReaderSettings Instead Of Filename?
The Stream and XmlReader load fine.
However my application throws a cannot find file exception when I try to load the xslt. The file that it cannot load is someOtherXsltFile.xslt
.
Both files are loaded as an embedded resource and both are visible in the list from assembly.GetManifestResourceNames
.
I would rather not change anything in the xslt files as those are standard files that came with the messages that I am trying to transform.
Is there a way to load my xslt using an import from the assembly?