Assembling XML data from multiple subset XML document files using XSLT
XSLT can be used to manipulate and combine data from multiple XML sources into a new file. In this document, we will review the process of calling using smaller XML data sources to build a new XML data source.
Including an XML data set into another
If we step away from the details of how to code the process, the process is a common programmatic procedure that is used in many languages to declare data sources or logical function definitions, and then use them within the local logic or data structure.
If you have one or more files with data that you would like to include as part of a larger file
Example:
If the following is the content of navigation.xml
<mynavigation>
<menu_item>
<label>XSLT to manipulate XML</label>
<link_href></link_href>
<description>This resource provides an overview and a detailed discussion on how to use XSLT to manipulate XML data</description>
</menu_item>
<menu_item>
<label>XML format future</label>
<link_href></link_href>
<description>Discover how XML is in the future of boundless data exchange and storage</description>
</menu_item>
<mynavigation>
At the top of your new document, and within a DOCTYPE declaration, and then within the data contained in this document, insert the imported data as a node as shown in the example below.
<!DOCTYPE xsl:stylesheet [
<!ENTITY main_navigation SYSTEM 'navigation.xml'>
]>
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<div id="main_navigation">
&main_navigation;
</div><!-- / main_navigation -->
</xsl:template>
</xsl:stylesheet>
The syntax in this case is very similar to creating a character entity (such as & or ©) and then using it in the document


