views:

168

answers:

1

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"&gt;
    <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/.

A: 

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"&gt;
  <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"&gt;
  <CompositeObject>
    <GUIOutput xml:base="test2.xml">
      <Input>Input</Input>
      <Title>IDC2_1</Title>
    </GUIOutput>
  </CompositeObject>
</VisionServer>
szielenski
I think the problem may be that I am not dealing with loading test1.xml from a file, I'm receiving it from an input stream. That may mean it has no context from which to load test2.xml, but I don't know how to fix that.
NinjaDebugger
That's a big omission. Why don't you post your code?
lavinio