微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决无法将最新生成的 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.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?