【问题标题】:Transform xml to sql insert statements [duplicate]将xml转换为sql插入语句[重复]
【发布时间】:2012-12-25 06:38:09
【问题描述】:

可能重复:
Are there general guidlines for solving undefined reference/unresolved symbol issues?

我想转换一个 xml 来插入 sql 语句。我已经准备好 xml 和 xslt 文件,并且我知道转换运行正常(用 Oxygen 测试)。

现在,我用 c++ 编码这个转换没有成功。

我已尝试包含以下库:

#include <libxml2/libxml/xmlversion.h>
#include <libxml2/libxml/parser.h>
#include <libxml2/libxml/valid.h>
#include <libxml2/libxml/xmlschemastypes.h>
#include <libxml2/libxml/xmlschemas.h>
#include <libxml2/libxml/xmlmemory.h>
#include <libxml2/libxml/debugXML.h>
#include <libxml2/libxml/HTMLtree.h>
#include <libxml2/libxml/xmlIO.h>
#include <libxml2/libxml/DOCBparser.h>
#include <libxml2/libxml/xinclude.h>
#include <libxml2/libxml/catalog.h>
#include <xalanc/Include/PlatformDefinitions.hpp>
#include <xercesc/util/PlatformUtils.hpp>
#include <xalanc/XalanTransformer/XalanTransformer.hpp>

但是编译器在代码中显示了很多错误,例如:

/home/kimpa2007/xml/src/main.cc:108: undefined reference to `xercesc_2_8::XMLUni::fgXercescDefaultLocale'

/home/kimpa2007/xml/src/main.cc:109: undefined reference to `xalanc_1_10::XalanTransformer::initialize(xercesc_2_8::MemoryManager&)'

有人可以用简单的方式解释如何对这种转换进行编码吗?

【问题讨论】:

标签: c++ xml xslt


【解决方案1】:

它们是几种进行XSL转换的方法,见Process an XML document using an XSLT stylesheet micro howto

  • xsltproc
  • 夏兰
  • 撒克逊人B
  • 撒克逊6

我知道您打算使用 Xalan。也许这实际上是正确的方法。请注意,需要配置此库。您可以在Xayno90 post 上获得配置帮助。我在这里复制粘贴步骤:

我终于设法一起编译和安装 Xerces 和 Xalan Ubuntu 10.04,如下操作:

第一步

sudo apt-get source libxerces-c28
sudo apt-get source libxalan110

第 2 步。

add "export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH" to /etc/ld.so.conf

第 3 步。

you may need to change owner of source packages from root to normal user

步骤 4. 构建 Xerces

export XERCESCROOT=/home/user/xerces-c2-2.8.0+deb1
cd $XERCESCROOT
cd src/xercesc
./runConfigure -plinux -cgcc -xg++ -minmem -nsocket -rpthread -b64 -P /usr/local
make
sudo XERCESCROOT=$XERCESCROOT make install

步骤 5. 构建 Xalan

export XERCESCROOT=/usr/local
cd $XERCESCROOT
/usr/local$ cd ~
export XERCESCROOT=/home/user/xerces-c2-2.8.0+deb1
cd $XERCESCROOT
cd ~
export XALANCROOT=/home/user/xalan-1.10/c
cd $XALANCROOT
./runConfigure -p linux -c gcc -x g++ -b64 -P /usr/local
make
sudo XALANCROOT=$XALANCROOT make install

第 6 步。

检查 /usr/local/lib 和 /usr/local/include 的目录,确认 Xerces 和 Xalan 都已安装

对于这些 XML 库和软件包的 Ubuntu 特定安装,需要成为一个 wiki,因为目前没有明确的指南,而且必须解释其他操作系统的安装方法以适应此安装。

还有:

最后,阅读这篇 SO 帖子:

【讨论】:

  • 感谢 danihp! ;-) 它在通过终端编译时工作我把选项 -l xalan-c
猜你喜欢
  • 2012-03-19
  • 2023-03-09
  • 2022-06-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多