I am having a xml document with uses xinclude for access several other xml files.
Chapter in Main Doc
This is not a complete solution but it may be enough for your needs. The following XSLT 2.0 style-sheet copies a document, expanding out XIncludes (with caveats noted following).
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
exclude-result-prefixes='xsl xi fn'>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="xi:include[@href][@parse='xml' or not(@parse)][fn:unparsed-text-available(@href)]">
<xsl:apply-templates select="fn:document(@href)" />
</xsl:template>
<xsl:template match="xi:include[@href][@parse='text'][fn:unparsed-text-available(@href)]">
<xsl:apply-templates select="fn:unparsed-text(@href,@encoding)" />
</xsl:template>
<xsl:template match="xi:include[@href][@parse=('text','xml') or not(@parse)][not(fn:unparsed-text-available(@href))][xi:fallback]">
<xsl:apply-templates select="xi:fallback/text()" />
</xsl:template>
<xsl:template match="xi:include" />
</xsl:stylesheet>
This solution does not implement the attributes: xpointer, accept and accept-language.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xi="http://www.w3.org/2001/XInclude"
exclude-result-prefixes='xsl xi'>
<xsl:output method="xml" indent="yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="xi:include[@href][@parse='xml' or not(@parse)]">
<xsl:apply-templates select="document(@href)" />
</xsl:template>
<xsl:template match="xi:include" />
</xsl:stylesheet>