Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>XSLT 2.0 would be fine for this. (If you need an XSLT 2.0 processor, I would recommend <a href="http://saxon.sourceforge.net/" rel="nofollow">Saxon</a>.)</p> <p>For example, this simple XML document:</p> <pre><code>&lt;doc&gt; &lt;foo/&gt; &lt;bar id="orig-id"/&gt; &lt;/doc&gt; </code></pre> <p>and this XSLT 2.0 stylesheet:</p> <pre><code>&lt;xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt; &lt;xsl:output indent="yes"/&gt; &lt;xsl:strip-space elements="*"/&gt; &lt;xsl:param name="threshold" select="10"/&gt; &lt;xsl:template match="@*|node()" mode="clone"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates select="@*|node()" mode="clone"/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="/*/bar/@id" mode="clone"&gt; &lt;xsl:param name="doc-id" tunnel="yes"/&gt; &lt;xsl:attribute name="id" select="$doc-id"/&gt; &lt;/xsl:template&gt; &lt;xsl:template match="/" name="createDocs"&gt; &lt;xsl:param name="dashNbr" select="1"/&gt; &lt;xsl:variable name="doc-id" select="concat(generate-id(),'-',$dashNbr)"/&gt; &lt;xsl:result-document href="{$doc-id}.xml"&gt; &lt;xsl:apply-templates select="/*" mode="clone"&gt; &lt;xsl:with-param name="doc-id" select="$doc-id" tunnel="yes"/&gt; &lt;/xsl:apply-templates&gt; &lt;/xsl:result-document&gt; &lt;xsl:if test="$threshold &gt; $dashNbr"&gt; &lt;xsl:call-template name="createDocs"&gt; &lt;xsl:with-param name="dashNbr" select="$dashNbr + 1"/&gt; &lt;/xsl:call-template&gt; &lt;/xsl:if&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>produces 10 files with unique <code>id</code> attributes. The file names are based on the id.</p> <p>Examples:</p> <p>d1-1.xml</p> <pre><code>&lt;doc&gt; &lt;foo/&gt; &lt;bar id="d1-1"/&gt; &lt;/doc&gt; </code></pre> <p>d1-2.xml</p> <pre><code>&lt;doc&gt; &lt;foo/&gt; &lt;bar id="d1-2"/&gt; &lt;/doc&gt; </code></pre> <p>d1-10.xml</p> <pre><code>&lt;doc&gt; &lt;foo/&gt; &lt;bar id="d1-10"/&gt; &lt;/doc&gt; </code></pre> <p>You would only need to change the value of the <code>threshold</code> param to the number of files you want created and change the <code>match</code> for the attribute you want to modify.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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