开发者

XercesDOMParser and XIncludes

开发者 https://www.devze.com 2022-12-18 04:40 出处:网络
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,

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" />

while testguioutput.xml contains

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

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.

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/.


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:

<?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:

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

At the command line I executed:

"XInclude.exe test1.xml test1_expanded.xml" without quotes.

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>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号