Best practice for inserting the same XML fragment more than once

Questions about XML that are not covered by the other forums should go here.
TMiles
Posts: 9
Joined: Fri Jan 20, 2023 1:05 am

Best practice for inserting the same XML fragment more than once

Post 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?
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

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

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply