title: XSLT Batch Processing
body: <p>I have the following XML structure:</p>
  
  <pre><code>&lt;School&gt;
    &lt;SchoolInfo&gt;
      &lt;SchoolName&gt;The Big School&lt;/SchoolName&gt;
      &lt;Opened&gt;2008&lt;/Opened&gt;
      &lt;SchoolID&gt;SCH1122&lt;/SchoolID&gt;
      &lt;Geograpics&gt;
        &lt;Location&gt;London&lt;/Location&gt;
        &lt;PostCode&gt;ZZ11 1ZZ&lt;/PostCode&gt;
      &lt;/Geographics&gt;
    &lt;/SchoolInfo&gt;
    &lt;Pupil&gt;
      &lt;Name&gt;Tom&lt;/Name&gt;
      &lt;LastName&gt;Jones&lt;/LastName&gt;
      &lt;Class&gt;12B&lt;/Class&gt;
      &lt;Age&gt;16&lt;/Age&gt;
    &lt;/Pupil&gt;
    &lt;Pupil&gt;
      &lt;Name&gt;Steve&lt;/Name&gt;
      &lt;LastName&gt;Jobs&lt;/LastName&gt;
      &lt;Class&gt;09A&lt;/Class&gt;
      &lt;Age&gt;17&lt;/Age&gt;
    &lt;/Pupil&gt;
    &lt;Pupil&gt;
      &lt;Name&gt;Joe&lt;/Name&gt;
      &lt;LastName&gt;Blogs&lt;/LastName&gt;
      &lt;Class&gt;13A&lt;/Class&gt;
      &lt;Age&gt;15&lt;/Age&gt;
    &lt;/Pupil&gt;
  &lt;/School&gt;
  </code></pre>
  
  <p>If my XML structure were to contain say.. 400 Pupils and I wanted to process them in batches of 50 and write to seperate PSV's for each 50 pupils, so the first 50, then 50-100, then 100-150 and so on and write each batch to a new file.. Can this be done using XSLT or would it have to be programatic?</p>
  
  <p>I now have the code to process to PSV etc im just being held up on how to process in batch as I quite frankly haven't a clue!</p>
  
  <p>--
  PSV: Pipe Seperated Values</p>
  
  <pre><code>SCH1122|London|Tom|12B|16
  SCH1122|London|Steve|09A|17
  SCH1122|London|Joe|13A|15
  </code></pre>
  
  <p>The code used to convert the XML is as follows:</p>
  
  <pre><code>private string PerformTransformation(string FilePath)
  {
      string fullXsltFile;
  
      if (chkDateIncrement.Checked == false)
          fullXsltFile = Resources.XSLTTest; // Resources.XSLT;
      else
          fullXsltFile = Resources.XSLTTest;
  
      XmlDocument xsltTransformDocument = new XmlDocument();
      xsltTransformDocument.LoadXml(fullXsltFile);
  
      FileInfo xmlFileInfo = new FileInfo(FilePath);
      string outputFile = CreateXmlOutputFileName(xmlFileInfo);
  
      // load the Xslt with any settings
      XslCompiledTransform transformation = new XslCompiledTransform();
      XsltSettings settings = new XsltSettings(true, false);
      settings.EnableScript = true;
      transformation.Load(xsltTransformDocument, settings, new XmlUrlResolver());
  
      using (XmlReader reader = XmlReader.Create(FilePath))
      {
         using (FileStream stream = new FileStream(outputFile, FileMode.Create))
         {
             transformation.Transform(reader, null, stream);
             stream.Close();
         }
         reader.Close();
      }
      return outputFile;
  }
  </code></pre>
  
  <p>I am also using the microsofts processer with VS2010 so sadly does not support v2.0, therefore would have to be v1.0 XSLT</p>
  
  <p>Preferably a method of doing this with the standard xslt1.0 build would be best as getting in additional components is not the easiest thing to do.</p>