title: XSLT Translation: I have an XML file with nested data and I need to translate it into a flat xml file
body: <p>Here is what I am working with...</p>
  
  <pre><code>&lt;response code="OK"&gt;
        &lt;enrollments&gt;
             &lt;enrollment enddate="9999-12-31T00:00:00Z" startdate="1753-01-01T00:00:00Z" status="1" flags="2228225" guid="a469dd60-8350-4749-8281-7772b6798bcc" reference="MajorMinor.109457483" domainid="616401" entityid="6557156" userid="1554956" id="6557282"&gt;
  -                &lt;data&gt;
  -                   &lt;status&gt;
                          &lt;performance code="2" signal="Red"/&gt;&lt;pace signal="Green"/&gt;
                      &lt;/status&gt;
                  &lt;/data&gt;
                  &lt;user guid="a992267a-a2ca-4e0c-a8d1-447d0243a4d8" reference="109457483" id="1554956" lastlogindate="1753-01-01T00:00:00Z" email="bak05016@thisone.edu" username="rbaker4" userspace="Thisone" lastname="Baker" firstname="Ryan"/&gt;
                     &lt;domain id="616401" name="This one"/&gt;
  -             &lt;grades seconds="0" complete="1" passingscore="0.7" letter="F" possible="100" achieved="45"&gt;
  -               &lt;items&gt;
                     &lt;item title="" categoryid="1" periodid="0" itemid="DEFAULT"/&gt;
                     &lt;item title="Test 1" categoryid="1" periodid="0" itemid="JECIY"/&gt;
                     &lt;item title="This test will be fun" status="261" letter="F" possible="100" achieved="10" categoryid="1" periodid="0" itemid="7I673" duedate="9999-12-31T23:59:59.9999999Z" scoreddate="2013-03-05T23:31:43.653Z" responseversion="4"/&gt;
                     &lt;item title="Do this homework recieve credit" status="261" letter="B" possible="100" achieved="80" categoryid="1" periodid="0" itemid="39AM7" duedate="9999-12-31T23:59:59.9999999Z" scoreddate="2013-03-07T16:54:08.033Z" responseversion="1"/&gt;
               &lt;/items&gt;
  -        &lt;categories&gt;
               &lt;category id="1" name="Include" letter="F" possible="200" achieved="90"/&gt;&lt;category id="0" name="Exclude" possible="0" achieved="0"/&gt;
           &lt;/categories&gt;
       &lt;/grades&gt;
     &lt;/enrollment&gt;
   &lt;/enrollments&gt;
  &lt;/response code&gt;
  </code></pre>
  
  <p>So I am taking this code and running an XSLT translation using the following code.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;xsl:output method="xml" /&gt;
  
  &lt;xsl:template match="/"&gt;
  
  &lt;Enrollments xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:noNamespaceSchemaLocation="results.xsd"&gt;
        &lt;xsl:for-each select="response/enrollments/enrollment"&gt;
        &lt;Enrollment&gt;
          &lt;FirstName&gt;
            &lt;xsl:value-of select="user/@firstname"/&gt;
          &lt;/FirstName&gt;
          &lt;LastName&gt; 
            &lt;xsl:value-of select="user/@lastname"/&gt;
          &lt;/LastName&gt;
          &lt;ID&gt;
            &lt;xsl:value-of select="user/@id"/&gt;
          &lt;/ID&gt;
          &lt;Email&gt;
            &lt;xsl:value-of select="user/@email"/&gt;
          &lt;/Email&gt;
          &lt;Grade&gt;
            &lt;xsl:value-of select="grades/@achieved"/&gt;
          &lt;/Grade&gt;
          &lt;Assignments&gt;
            &lt;xsl:value-of select="grades/items/item/@title"/&gt;
              &lt;/xsl:for-each&gt;
          &lt;/Assignments&gt;
        &lt;/Enrollment&gt;
        &lt;/xsl:for-each&gt;
      &lt;/Enrollments&gt;
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>My problem is with the assignments tag in the xslt returns know results from the xml data. I need a way to get it to return the information for the grade scored. in a way that for each item a new column would be created in the table with the column heading being the name of the assignment ex. "Do this homework receive credit" and then the content of the table is the grade they scored. the original xml document I am working with has about 4000 rows and  we need to translate it to put it into our database in a usable format. </p>