Hi Edward,
Thanks for your patience.
The development team has further investigated the issue PDFNEWNET-34509 reported earlier and as per our observations, following exception is being thrown.
Execution of the ‘document()’ function was prohibited. Use the XsltSettings.EnableDocumentFunction property to enable it. An error occurred at (1,2414).
It’s because the supplied XML+XSLT documents are complex enough and use advanced features of transformation. Please note that problem (at least now) is in XML+XSLT transformation itself, not in conversion results of PDF.
In such cases, it is always useful to do transformation in outer code (not inside Aspose.Pdf),
investigate result when necessary and supply final result XML for usage in BindXML method.
For testing purposes, we tried using following code snippet but we encountered an exception which states that during XSLT transformation, some file is required which was not provided earlier.
An error occurred while loading document ‘file:///c:/styleRepository/styleRepository/RapGen/RapGen_resources/rapgen_preferences.xml’. See InnerException for a complete description of the error.
[C#]
FileStream inXmlStream = new FileStream(@“F:\ExternalTestsData\34509.xml”, FileMode.Open);<o:p></o:p>
FileStream inXslStream = new FileStream(@"F:\ExternalTestsData\34509.xslt", FileMode.Open);
string result = DoTransformation(inXmlStream, inXslStream);
byte[] outAsBytes = System.Text.Encoding.UTF8.GetBytes(result);
string preparedXmlFile = @"F:\ExternalTestsData\34509_prepared.xml";
File.WriteAllBytes(preparedXmlFile, outAsBytes);
Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
pdf.BindXML(preparedXmlFile,
null);
pdf.Save(@"F:\ExternalTestsData\34529.pdf");
internal static string DoTransformation(Stream inputStream, Stream xslStream)
{
//---------------------------------------------
// load
source document
//---------------------------------------------
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
xmlDoc.Load(inputStream);
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();
xmlReaderSettings.ProhibitDtd = false;
XmlReader xmlReader = XmlReader.Create(new StringReader(xmlDoc.OuterXml), xmlReaderSettings);
//---------------------------------------------
// load
xslt-transform
//---------------------------------------------
System.Xml.XmlDocument xsltDoc = new System.Xml.XmlDocument();
xsltDoc.Load(xslStream);
System.Xml.Xsl.XslCompiledTransform
processor = new System.Xml.Xsl.XslCompiledTransform();
XmlReader xsltReader = XmlReader.Create(new StringReader(xsltDoc.OuterXml));
System.Xml.Xsl.XsltSettings
xsltSettings = new System.Xml.Xsl.XsltSettings();
xsltSettings.EnableDocumentFunction = true;
processor.Load(xsltReader, xsltSettings, null);
//---------------------------------------------
// do
transformation
//---------------------------------------------
System.Text.StringBuilder documentBuilder = new System.Text.StringBuilder();
XmlWriterSettings xmlWriterSettings = new XmlWriterSettings();
xmlWriterSettings.ConformanceLevel = ConformanceLevel.Auto;
XmlWriter xmlWriter = XmlWriter.Create(documentBuilder, xmlWriterSettings);
processor.Transform(xmlReader, xmlWriter);
return documentBuilder.ToString();
}
Please share the required file so that we can further proceed with the investigation/resolution of this problem.