Page 1 of 1

Xinclude elements from the same document

Posted: Wed Jul 04, 2007 1:49 am
by martindholmes
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?

Cheers,
Martin

Posted: Wed Jul 04, 2007 12:15 pm
by george
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