Page 1 of 1

Best practice for inserting the same XML fragment more than once

Posted: Tue Feb 28, 2023 9:21 pm
by TMiles
I am creating a reference work which will ultimately be organised by subjects, and each subject will contain various entries. Because of the nature of the field, I want to include some entries in more than one subject.

I have been working with two XML files:
  • one document holding all the entires (each with a unique ID);
  • another document structuring the subjects, into which I insert the relevent entries using xi:include elements, and from which I would generate the final document
I have discovered that inserting the same XML fragment more than once (i.e. inserting xi:include elements referring to the same unique ID) makes the document invalid. Wanting to repeat content from the same source within the same document is nonetheless a common scenario. What is considered best practice?

Re: Best practice for inserting the same XML fragment more than once

Posted: Wed Mar 01, 2023 8:40 am
by Radu
Hi,

XInclude 1.0 indeed has this limitation.
But Oxygen at least has support for XInclude 1.1 which allows to set a new XML ID to the xi:included root element:
https://www.oxygenxml.com/doc/ug-editor ... 1_features
Support for xi:include 1.1 will not work for command line transformations as I think from what I remember that open source XML parsers like Xerces have not added it.

Regards,
Radu