XercesDOMParser and XIncludes

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

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

Existing code uses a wrapper around XercesDOMParser to parse the XML when it comes in, and after using setDoNamespaces and setDoXInclude to true, it tries to parse the XInclude, but I get the constant "Fatal: include failed and no fallback element found in document error {0} '", regardless of where testguioutput.xml is placed in the directory structure.

visualstudio 2008, /project/debug, include /project/or/project/debug/.

+3
1

xinclude, XInclude.exe, Xerces. , :

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>

:

"XInclude.exe test1.xml test1_expanded.xml" .

test1_expanded.xml:

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

Source: https://habr.com/ru/post/1730410/


All Articles