Merging XML files with XInclude into a single XML file

Today, I faced the problem that I wanted to process a XML file including other XML files using XInclude with a not XInclude-aware tool.

My solution for that problem is to create a XSL-stylesheet which simply copies the original XML file. Then I do a XSL transformation of the source file with a XInclude-aware tool.

This is the stylesheet for copying:

<?xml version="1.0"?></pre>
<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output
 method="xml"
 encoding="UTF-8"
 omit-xml-declaration="no"
 standalone="yes"
 indent="yes"/>

<xsl:template match="*">
 <xsl:copy>
 <xsl:apply-templates select="node()|@*"/>
 </xsl:copy>
 </xsl:template>

<xsl:template match="@*|text()|comment()|processing-instruction()">
 <xsl:copy-of select="."/>
 </xsl:template>

</xsl:stylesheet>

A sample command line for processing

[~]$ xsltproc --xinclude copy_stylesheet.xsl source_file.xml > output.xml

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

Time limit is exhausted. Please reload the CAPTCHA.