title: Reading values of XML tag in variables inside XSLT
body: <p>I could not find a similar question anywhere, so thats why posting this new question.
   I have an XML that I want to read and convert into SQL using XSLT. The trick part is that the XML elements(i.e. the names) are not known and the XSD for the XML is generated on the fly.
  But what is known is certain attributes of the elements.</p>
  
  <p>The XML looks like this :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;et:ItemRecordList xmlns:et="urn:org:easetech:easytest:schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:org:easetech:easytest:schema ItemRecord.xsd "&gt;
  
    &lt;ItemRecord recordId="idvalue0" tableName="item_record"&gt;
      &lt;itemId columnName="item_id" idColumn="true" length="36" nullable="false"&gt;itemId&lt;/itemId&gt;
      &lt;databaseInstitution columnName="database_institution" length="255" nullable="false"&gt;0&lt;/databaseInstitution&gt;
      &lt;lastModifiedDate columnName="last_modified_date" length="255" nullable="false"&gt;2001-12-31T12:00:00&lt;/lastModifiedDate&gt;
    &lt;/ItemRecord&gt;
  &lt;/et:ItemRecordList&gt;
  </code></pre>
  
  <p>I want to use this XML and convert it into an INSERT SQL statement using XXSLT.</p>
  
  <p>I created an XSLT like this :</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="text" encoding="UTF-8" /&gt;
  &lt;xsl:template match="/"&gt;
  &lt;xsl:for-each select="/*/*"&gt;
  
  INSERT INTO
  &lt;xsl:value-of select="@tableName" /&gt;
  (
  &lt;xsl:for-each select="/*/*/*"&gt;
   &lt;xsl:variable name="columnName"&gt;&lt;xsl:value-of select="@columnName"/&gt;&lt;/xsl:variable&gt;
   &lt;xsl:choose&gt;
   &lt;xsl:when test="@columnName"&gt; 
      &lt;xsl:value-of select="$columnName"/&gt;
      &lt;xsl:if test="position()!=last()"&gt;
          &lt;xsl:text&gt;, &lt;/xsl:text&gt;
      &lt;/xsl:if&gt;
  &lt;/xsl:when&gt; 
  &lt;/xsl:choose&gt;  
  &lt;/xsl:for-each&gt;
  ) 
  &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>which gives me the output like this :</p>
  
  <pre><code>INSERT INTO item_record (item_id, database_institution, last_modified_date)
  </code></pre>
  
  <p>But I don't know how to create the value part of the query. The value is the value we get using </p>
  
  <pre><code> &lt;xsl:value-of select="." /&gt;
  </code></pre>
  
  <p>I tried concatenating the values, but unfortunately concat didnt work for me. I also played around with xsl:variable but couldnt make it work. If someone could help me with the XSLT that I can use to create to output like below that would be really appreciated.</p>
  
  <pre><code>   INSERT INTO item_record (item_id, database_institution, last_modified_date) values (itemId,0,2001-12-31T12:00:00)
  </code></pre>