Hello, we are glad that the option to use streams as inputs for BindXml was implemented but using it we got to an another problem. When using the BindXml(Stream,Stream) method the XmlResolver used to resolve the xsl;import does not function correctly as it looks in the current assembly execution directory (C:\windows\system32) not in the directoroy of the filestream provided. This was not a problem when using the BindXml(string,string).
What would solve our problem is if you provided a way to send in XmlReaderSettings object or XmlResolver object to be used when calling the BindXml(Stream,Stream) method so the interface would be
BindXml(Stream,Stream, XmlReaderSettings)
creating a XmlReaderSettings and providing a custom XmlResolver
XmlReaderSettings settings = new XmlReaderSettings();
settings.XmlResolver = new CustomXmlResolver();
and then load the compiled transformation with the provided XmlReaderSetting from the stream.
This would also solve the problem with loading external resources in .Net 4.5.2
as written in
https://msdn.microsoft.com/en-us/library/system.xml.xmlreadersettings.xmlresolver(v=vs.110).aspx
XSLT Transformation code
<?xml version="1.0" encoding="utf-16"?>
<xsl:stylesheet version=“1.0” xmlns:xsl=“http://www.w3.org/1999/XSL/Transform” xmlns:msxsl=“urn:schemas-microsoft-com:xslt” exclude-result-prefixes=“msxsl”>
<xsl:import href="…\Templates.xslt"/>
<xsl:import href="…\Enums.xslt"/>
<xsl:output method=“xml” indent=“yes”/>
<xsl:template match="/ClassNametoMatchTheXMLModel">
</xsl:template>
</xsl:stylesheet>
Sample code to create pdf document from XSLT transformation and xml model.
using (var ms = new MemoryStream())
{
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
Aspose.Pdf.Document doc = new Aspose.Pdf.Document();
string templatePath = Path.Combine(“pathtofile”, @“template.xslt”);
using (var ts = new FileStream(templatePath, FileMode.Open, FileAccess.Read, FileShare.Read))
{
<span style=“font-family: “Courier New”;”> doc.BindXml(xms, ts);
<span style=“font-family: “Courier New”;”> doc.Save(ms);
}
return ms.ToArray();
}