Xinclude elements from the same document

<oXygen/> general issues.
Posts: 161
Joined: Wed Apr 20, 2005 5:43 pm
Location: Victoria, BC, Canada

Xinclude elements from the same document

Post by martindholmes » Wed Jul 04, 2007 1:49 am

I'm trying to get around the huge amount of duplication that typically happens in TEI documents, where titles, authors and similar info tend to appear in two or three different places. I'm doing this by using XInclude to include data from one part of the document in another part of the same document, like this:

<title type="main"><xi:include href="" xpointer="element(mainTitle)/*"><xi:fallback>[Main title is missing]</xi:fallback></xi:include></title>

<title level="a" type="main" xml:id="mainTitle">Towards Higher Ground</title>

Here, the contents of the second title element, which has the xml:id "mainTitle", should (I think) be xincluded into the first title element. I'm not 100% sure I have the xpointer syntax right, but my main problem right now is that oXygen doesn't seem to be able to process any XInclude statement which refers to another location in the same document; this is the error I get when I try to validate the document against an RNG schema:

Include operation failed, reverting to fallback. Resource error reading file as XML (href=''). Reason: An xpointer was specified that points to a location in the source infoset. This location cannot be accessed due to the streaming nature of the processor.

Is there any way I can get oXygen to validate a document like this?


Site Admin
Posts: 2102
Joined: Thu Jan 09, 2003 2:58 pm

Post by george » Wed Jul 04, 2007 12:15 pm

Hi Martin,

The XInclude is processed as the document is parsed so references to the same document will not work. However there is a simple solution, place the common content in a separate file and XInclude it from all the places you need it.

Best Regards,
George Cristian Bina

Post Reply