无法将最新生成的 xml 文件与 XALAN Transform C++ 一起使用

问题描述

我正在尝试使用 Apache xalan-C++ 框架将 XML(这将基于 xml 模板生成,并在 xml 中进行一些更改)、XSL 到 html

我正在使用 xerces 解析器基于模板 xml 生成 xml 文件。 sFinalXMLPath 是指生成的 xml 文件文件名或完整文件路径。

我正在使用生成的 xml 文件名或完整文件路径,但失败了。但是在程序执行后,硬编码了文件名,它就可以工作了。

错误信息:

enter image description here

代码

XSLTInputSource xmlIn(sFinalXMLPath.c_str());
std::string xsltFilePath = stemplateDir + "test_mail.xsl";
std::string htmlFilePath = stemplateDir + "test_mail.html";
XSLTInputSource xslIn(xsltFilePath.c_str());
XSLTResultTarget xmlOut(htmlFilePath.c_str());
int theResult = theXalanTransformer.transform(xmlIn,xslIn,xmlOut);

生成到xml的代码

std::string xmlFileName = AppendTimetoFileName("mail_xml_input.xml");
//tcTempLoc += fs::path::preferred_separator;
tcTempLoc += "/";
std::string sFinalXMLPath = tcTempLoc + xmlFileName;

cout << "\nTemplate XML Path: " << xmlFilePath;
cout << "\nFinal XML Path: " << sFinalXMLPath;
fs::copy_file(xmlFilePath,sFinalXMLPath);

// Build input xml
XmlDomDocument* xFinalXMLInput = new XmlDomDocument(sFinalXMLPath.c_str());
string sValuetoSet;
if (xFinalXMLInput) {
    for (int i = 0; i < xFinalXMLInput->getChildCount("Overview","Entry"); i++) {
        for (int j = 0; j < xFinalXMLInput->getChildCount("Entry",i,"property"); j++) {
            sAttrName = xFinalXMLInput->getChildAttribute("Entry","property",j,"value");
            sValuetoSet = mProps[sAttrName];
            cout << "\nValue to set for " << sAttrName << " is : " << sValuetoSet;
            iResult = xFinalXMLInput->setChildAttribute("Entry","value",sValuetoSet.c_str());
            sAttrName = xFinalXMLInput->getChildAttribute("Entry","value");
            cout << "\nValue replaced : " << sAttrName;
        }
    }
}

xFinalXMLInput->normalizeDocument();
xFinalXMLInput->DoOutput2File(sFinalXMLPath.c_str());
delete xFinalXMLInput;

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...