<xsl:attribute name="{fn:node-name(.)}" select="." />         </xsl:for-each>         <xsl:apply-templates select="child::node()" />     </xsl:element> </xsl:template> What's next? Call an XSLT processor like Saxon in a XInclude aware manner . $ exec java \     -classpath saxon.jar \     -Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.xerces.parsers.XIncludeParserConfiguration \     net.sf.saxon.Transform \     -xi:on \     -s:demoxi.html