title: Split Xml into multiple files using xslt: Failed to transform document Exception: Could not find function: current-group
body: <p>XSLT: </p>
  
    
  
  <pre><code>&lt;xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  
    &lt;xsl:output method="xml" indent="yes"/&gt;
  
    &lt;xsl:template match="/Objects"&gt;
      &lt;xsl:apply-templates/&gt;
    &lt;/xsl:template&gt;
  
    &lt;xsl:template match="business"&gt;
      &lt;xsl:for-each-group select="WorkItem" group-starting-with="WorkItem[(position() -1)mod 3 = 0]"&gt;
        &lt;xsl:variable name="file" select="concat('WorkItem',position(),'.xml')"/&gt;
        &lt;xsl:result-document href="{$file}"&gt;
          &lt;Objects&gt;
            &lt;business&gt;
              &lt;xsl:copy-of select="current-group()" /&gt;
            &lt;/business&gt;
          &lt;/Objects&gt;
        &lt;/xsl:result-document&gt;
      &lt;/xsl:for-each-group&gt;
    &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>InputXML: </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes" ?&gt;
    &lt;Objects&gt;
      &lt;business&gt;
      &lt;WorkItem&gt;
      ..............
      &lt;/WorkItem&gt;
      &lt;WorkItem&gt;
      ..............
      &lt;/WorkItem&gt;
      &lt;WorkItem&gt;
      ..............
      &lt;/WorkItem&gt;
      &lt;WorkItem&gt;
      ..............
      &lt;/WorkItem&gt;
      &lt;WorkItem&gt;
      ..............
      &lt;/WorkItem&gt;
      &lt;WorkItem&gt;
      ..............
      &lt;/WorkItem&gt;
    &lt;/business&gt;
  &lt;/Objects&gt;
  </code></pre>
  
  <p>Expected Output: 2 separate files with three Workitems in each.</p>
  
  <p>Error received:</p>
  
  <pre><code>Error: XSLT Service failed. Failed to transform document Exception:   
    javax.xml.transform.TransformerException: Could not find function: current-group
  </code></pre>