XIncProc XInclude Processor >

API Usage

Here a simple example of XIncProc XInclude Api Usage

The expression to find node "genre" with XPointer Framework is very simple: "bk101" (see Shorthand Pointer)

Code to find "genre" node with XPointer engine is as simple as this:

  1. Set a source into an InputStream (source including xinclude instructions of course) :
                InputStream sourceStream = new FileInputStream(...);
            
  2. Call a parse function that resolve xinclude instructions into a new outputstream. NB: The source's base URI is needed for xml:base fixup.
                XIncProcEngine.parse(sourceStream, baseUri, outputStream);
            
    Et voila !

For example, that source document :

    <x xmlns:xi="http://www.w3.org/2001/XInclude">
        <xi:include href="include1.xml"/>
    </x>

including this document:

<foo/>

The parsed result document will be this:

    <?xml version="1.0" encoding="UTF-8"?><x>
    <foo xml:base="include1.xml"/>
    </x>