XercesDOMParser和XIncludes [英] XercesDOMParser and XIncludes

查看:171
本文介绍了XercesDOMParser和XIncludes的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让xincludes在现有的系统中使用XercesDOMParser在xercesc从客户端解析传入的xml。我使用Apache Xercesc v3.0.1,并且从输入流读取的传入XML是:

I am attempting to get xincludes working in an existing system that uses a XercesDOMParser in xercesc to parse incoming xml from a client. I am working with Apache Xercesc v3.0.1, and the incoming XML, read from an input stream, is:

<?xml version="1.0" encoding="UTF-8"?>
<VisionServer xmlns:xi="http://www.w3.org/2001/XInclude">
    <CompositeObject>
 <xi:include href="testguioutput.xml" />


.xml包含

<?xml version="1.0" encoding="UTF-8"?>
<GUIOutput>
    <Input>Input</Input>
    <Title>IDC2_1</Title>
</GUIOutput>

现有代码使用XercesDOMParser周围的包装器来解析XML,在使用后setDoNamespaces和setDoXInclude为true,它试图解析XInclude,但我得到一个持久的致命:包含失败,没有后退元素找到文档{0}错误,无论在目录结构中我放在testguioutput的哪里。 xml。

The existing code uses a wrapper around a XercesDOMParser to parse the XML as it comes in, and after using setDoNamespaces and setDoXInclude to true, it is attempting to parse the XInclude, but I get a persistent "Fatal: include failed and no fallback element found in document '{0}'" error, no matter where in the directory structure I put testguioutput.xml.

我在visualstudio 2008下工作,我的工作目录是默认的,运行/ project / debug,但是include失败,无论目标文件是否在/项目/或/ project / debug /.

I am working under visualstudio 2008, my working directory is default, and running out of /project/debug, but the include fails whether the target file is in /project/ or /project/debug/.

推荐答案

我能够使用XInclude.exe示例应用程序扩展xinclude标记包含在Xerces应用程序中。为此,我使用上面的文件创建了两个文件:

I was able to expand the xinclude tags using the XInclude.exe sample application that is included with the Xerces application. To do this, I created two files using your files above:

test1.xml:

test1.xml:

<?xml version="1.0" encoding="UTF-8"?>
<VisionServer xmlns:xi="http://www.w3.org/2001/XInclude">
  <CompositeObject>
    <xi:include href="test2.xml"/>
  </CompositeObject>
</VisionServer>

test2.xml:

test2.xml:

<?xml version="1.0" encoding="UTF-8"?>
<GUIOutput>
  <Input>Input</Input>
  <Title>IDC2_1</Title>
</GUIOutput>

在命令行执行:

生成的test1_expanded.xml文件:

The resulting test1_expanded.xml file:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<VisionServer xmlns="" xmlns:xi="http://www.w3.org/2001/XInclude">
  <CompositeObject>
    <GUIOutput xml:base="test2.xml">
      <Input>Input</Input>
      <Title>IDC2_1</Title>
    </GUIOutput>
  </CompositeObject>
</VisionServer>

这篇关于XercesDOMParser和XIncludes的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆