An XSLT solution to this problem

  • Explicitly define input as a set of root nodes, as in the following example:

Solving the root node problem

<xsl:transform version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:variable name="input" select="document(documents/document/@href)"/>

  <xsl:template match="/">
    <rootElementNames>
      <xsl:for-each select="$input">
        <xsl:copy-of select="*[1]"/>
      </xsl:for-each>
    </rootElementNames>
  </xsl:template>

</xsl:transform>
  • This will copy every root element, not just the first root element.
  • The list of document URIs is taken from a controlling XML config file, which is what's used as the source of this particular query.
<<<  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15    >>>