title: SaxonApiException: The context item for axis step ./CLIENT is absent
body: <p>I am trying to convert and XML to an XML using XSLT 2.0 in saxon/java. I am using a sample XML I found on stack overflow  thread "Applying Muenchian grouping for a simple XML with XSLT"</p>
  
  <p>However I am getting an error :  XPDY0002: The context item for axis step ./CLIENT is absent.</p>
  
  <p>My test XSL:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xsl:stylesheet 
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="2.0"&gt;
  
  &lt;xsl:output omit-xml-declaration="no" indent="yes" /&gt;
  &lt;xsl:strip-space elements="*" /&gt;
  
  &lt;xsl:template match="CLIENTS" name="main"&gt;
  &lt;CLIENTS&gt;
    &lt;xsl:for-each-group select="CLIENT" group-by="NAME"&gt;
    &lt;xsl:comment&gt;&lt;xsl:value-of select="current-grouping-key()"/&gt;         &lt;/xsl:comment&gt;
      &lt;CLIENT&gt;
        &lt;xsl:sequence select="NAME" /&gt;
        &lt;xsl:for-each select="current-group()"&gt;
          &lt;ACCOUNT&gt;
            &lt;xsl:sequence select="*[not(self::NAME)]" /&gt;
          &lt;/ACCOUNT&gt;
        &lt;/xsl:for-each&gt;
      &lt;/CLIENT&gt;
    &lt;/xsl:for-each-group&gt;
   &lt;/CLIENTS&gt;
  &lt;/xsl:template&gt;
  
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>My Test XML:</p>
  
  <pre><code>&lt;CLIENTS&gt;
   &lt;CLIENT&gt;
  &lt;NAME&gt;John&lt;/NAME&gt;
  &lt;ACCOUNT_NUMBER&gt;1424763562761&lt;/ACCOUNT_NUMBER&gt;
  &lt;LAST_USED&gt;2012-10-03&lt;/LAST_USED&gt;
  &lt;AMOUNT&gt;5000&lt;/AMOUNT&gt;
  &lt;/CLIENT&gt;
  &lt;CLIENT&gt;
  &lt;NAME&gt;John&lt;/NAME&gt;
  &lt;ACCOUNT_NUMBER&gt;543667543732&lt;/ACCOUNT_NUMBER&gt;
  &lt;LAST_USED&gt;2012-10-02&lt;/LAST_USED&gt;
  &lt;AMOUNT&gt;10000&lt;/AMOUNT&gt;
  &lt;/CLIENT&gt;
  &lt;/CLIENTS&gt;
  </code></pre>
  
  <p>My Java ( which works with other transforms) :</p>
  
  <pre><code>void xmlXSLTParser(){
  
  String xslFile = commonPath + "/xslt/inputPointCSVTOXML_style2.xsl";
  String inputFile = "file:///" + commonPath + pointWorkFile;
  String outputFile = commonPath + pointWorkFile + ".final";
  
  try {
      Processor proc = new Processor(false);
      XsltCompiler comp = proc.newXsltCompiler();
      XsltExecutable exp = comp.compile(new StreamSource(new   File(xslFile)));
      Serializer out = new Serializer();
      out.setOutputProperty(Serializer.Property.METHOD, "xml");
      out.setOutputProperty(Serializer.Property.INDENT, "yes");
      out.setOutputFile(new File(outputFile));
  
      XsltTransformer trans = exp.load();
      trans.setInitialTemplate(new QName("main"));
      //trans.setParameter(new QName("url-of-csv"),new  XdmAtomicValue(inputFile));
      trans.setDestination(out);
      trans.transform();
  
      System.out.println("Output written to text file");
  } catch (SaxonApiException e) {
      println("XSLT Error :" + e );
  }
  }
  
  }
  </code></pre>
  
  <p>My Error in detail:</p>
  
  <pre><code>Error at char 6 in xsl:for-each-group/@select on line 10 column 59 of    inputPointCSVTOXML_style2.xsl:
  
  XPDY0002: The context item for axis step ./CLIENT is absent
  XSLT Error :net.sf.saxon.s9api.SaxonApiException: The context item for      axis step ./CLIENT is absent
  </code></pre>