C code :
void applyXslt(Saxon::Api::XdmNode^ fxmlFile, Saxon::Api::XsltTransformer^ xsltFile, const std::string& outputFile)
{
// Apply the xslt to the cached xml
auto processor = gcnew Saxon::Api::Processor(false);
xsltFile->InitialContextNode = fxmlFile;
auto serializer = processor->NewSerializer(); \\ Error occurs here
System::String^ output = gcnew System::String(outputFile.c_str());
serializer->SetOutputFile(output);
xsltFile->Run(serializer);
}
It somehow fails to create a serializer , It worked when i created a test project , but now it doesnt seem to work. Is this a bug in Saxon ??
CodePudding user response:
To allow you to mark the question as answered, I summarize what seemed to have helped from the comments.
In general, the Processor
class is central, see https://www.saxonica.com/html/documentation10/dotnet/dotnetapi.html saying
The first thing the application needs to do is to create a
Processor
. TheProcessor
holds configuration information for Saxon, and shared resources such as the name pool and schema pool. It is possible to run multiple processors concurrently if required, but it is usually more economical for all Saxon processes within a single application to use the sameProcessor
.
So based on that your code should hold on to the Processor
you used to create the XdmNode
and XsltTransformer
you already pass in to your function applyXslt
and pass that processor instance in as well as a parameter to then use it to create that Serializer
.