带有 C++ CLI 的 Saxon .NET
Saxon .NET with C++ CLI
我想到了使用 C++ CLI
与 Saxon .NET interface
交互的想法。问题是 Saxonica 上的每个示例都带有 C#
,而不是 C++
。你能给我一个缓存 XML 文件并使用 Xslt 文件路径使用 C++ CLI 将其转换为使用 .NET 接口的示例吗???
另外请不要给我不使用 C++ CLI 的解决方法
使用 Saxon .NET HE 10 的最小示例(最初使用 10.6 进行测试,现在更新为 10.7)运行 Windows 针对 .NET Framework 4.8 例如
#include "pch.h"
using namespace System;
using namespace Saxon::Api;
int main(array<System::String ^> ^args)
{
Processor^ processor = gcnew Processor();
Console::WriteLine(processor->ProductVersion);
DocumentBuilder^ docBuilder = processor->NewDocumentBuilder();
Uri^ baseUri = gcnew Uri(System::Environment::CurrentDirectory + "\");
XdmNode^ inputDoc = docBuilder->Build(gcnew Uri(baseUri, "input-sample1.xml"));
XsltCompiler^ xsltCompiler = processor->NewXsltCompiler();
xsltCompiler->BaseUri = baseUri;
XsltExecutable^ xsltExecutable = xsltCompiler->Compile(gcnew Uri(baseUri, "sheet1.xsl"));
Xslt30Transformer^ xslt30Transformer = xsltExecutable->Load30();
xslt30Transformer->ApplyTemplates(inputDoc, processor->NewSerializer(Console::Out));
return 0;
}
示例项目位于 https://github.com/martin-honnen/SaxonHECLIExample1。
要改为写入文件,请使用例如
FileStream^ resultStream = File::OpenWrite("result1.xml");
xslt30Transformer->ApplyTemplates(inputDoc, processor->NewSerializer(resultStream));
resultStream->Close();
而不是xslt30Transformer->ApplyTemplates(inputDoc, processor->NewSerializer(Console::Out));
;示例改编位于 https://github.com/martin-honnen/SaxonHECLIExample1/tree/WriteToFileInsteadOfConsole
我想到了使用 C++ CLI
与 Saxon .NET interface
交互的想法。问题是 Saxonica 上的每个示例都带有 C#
,而不是 C++
。你能给我一个缓存 XML 文件并使用 Xslt 文件路径使用 C++ CLI 将其转换为使用 .NET 接口的示例吗???
另外请不要给我不使用 C++ CLI 的解决方法
使用 Saxon .NET HE 10 的最小示例(最初使用 10.6 进行测试,现在更新为 10.7)运行 Windows 针对 .NET Framework 4.8 例如
#include "pch.h"
using namespace System;
using namespace Saxon::Api;
int main(array<System::String ^> ^args)
{
Processor^ processor = gcnew Processor();
Console::WriteLine(processor->ProductVersion);
DocumentBuilder^ docBuilder = processor->NewDocumentBuilder();
Uri^ baseUri = gcnew Uri(System::Environment::CurrentDirectory + "\");
XdmNode^ inputDoc = docBuilder->Build(gcnew Uri(baseUri, "input-sample1.xml"));
XsltCompiler^ xsltCompiler = processor->NewXsltCompiler();
xsltCompiler->BaseUri = baseUri;
XsltExecutable^ xsltExecutable = xsltCompiler->Compile(gcnew Uri(baseUri, "sheet1.xsl"));
Xslt30Transformer^ xslt30Transformer = xsltExecutable->Load30();
xslt30Transformer->ApplyTemplates(inputDoc, processor->NewSerializer(Console::Out));
return 0;
}
示例项目位于 https://github.com/martin-honnen/SaxonHECLIExample1。
要改为写入文件,请使用例如
FileStream^ resultStream = File::OpenWrite("result1.xml");
xslt30Transformer->ApplyTemplates(inputDoc, processor->NewSerializer(resultStream));
resultStream->Close();
而不是xslt30Transformer->ApplyTemplates(inputDoc, processor->NewSerializer(Console::Out));
;示例改编位于 https://github.com/martin-honnen/SaxonHECLIExample1/tree/WriteToFileInsteadOfConsole