Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Using an <a href="http://www.w3.org/TR/xslt20/" rel="noreferrer">XSLT 2.0</a> processor and the <a href="http://www.w3.org/TR/xpath-functions/#func-collection" rel="noreferrer"><code>collection()</code></a> function this is really easy</strong>.</p> <p>Below is an example using <strong><a href="http://www.saxonica.com/documentation/index/intro.html" rel="noreferrer">Saxon</a></strong>:</p> <pre><code>&lt;xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" &gt; &lt;xsl:output omit-xml-declaration="yes" indent="yes"/&gt; &lt;xsl:param name="pDirName" select="'D:/Temp/xmlFilesDelete'"/&gt; &lt;xsl:template match="/"&gt; &lt;wrap&gt; &lt;xsl:apply-templates select= "collection( concat('file:///', $pDirName, '?select=*.xml;recurse=yes;on-error=ignore' ) )/* "/&gt; &lt;/wrap&gt; &lt;/xsl:template&gt; &lt;xsl:template match="*"&gt; &lt;xsl:copy-of select="."/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>When this transformation is applied on any XML document (not used), it processes all xml files in the file-system subtree starting at the directory, whose value is specified by the global parameter <strong><code>$pDirName</code></strong>. </p> <p><strong>At the time this transformation was applied there were only two xml files</strong> there:</p> <pre><code>&lt;apples&gt;3&lt;/apples&gt; </code></pre> <p>and</p> <pre><code>&lt;oranges&gt;3&lt;/oranges&gt; </code></pre> <p><strong>The correct result is produced</strong>:</p> <pre><code>&lt;wrap&gt; &lt;apples&gt;3&lt;/apples&gt; &lt;oranges&gt;3&lt;/oranges&gt; &lt;/wrap&gt; </code></pre> <p>This is the simplest example possible that can be constructed. <strong>To fully answer the question, the directory can be specified on the command line invoking Saxon. Read more about the ways to invoke Saxon from the command-line <a href="http://www.saxonica.com/documentation/using-xsl/commandline.html" rel="noreferrer">here</a></strong>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload