title: XSLT question. How to pair field tags with data when original XML has them in separate sections?
body: <p>I hope I don't lose anyone by mentioning Filemaker.  I am trying to turn it's XML export into something usable by SSIS.  FM's native XML export has field names and data in separate sections of the same XML file.  This lists what I need it to do, what I currently did, and the original FM export at the bottom for reference.  I have not seen XML translations before this morning, so bear with me :D.  I can post more info as necessary.</p>
  
  <pre><code>&lt;!-- What we actually want example --&gt;
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;PRODUCTRECS&gt;
  &lt;PRODUCT&gt;
      &lt;name&gt;Dr. Zim&lt;/name&gt;
      &lt;address&gt;1234 Internet Way&lt;/address&gt;
      &lt;city/&gt;&lt;state/&gt;&lt;zip/&gt;
  &lt;/PRODUCT&gt;
  ...
  &lt;/PRODUCTRECS&gt;
  </code></pre>
  
  <p>Is there a way with XSLt to read the field names at the top and put the field names around the actual data when we translate it?  Currently, I just pick out the position with IF statements like so (which works but is very dependent and messy):</p>
  
  <pre><code>&lt;!-- Current nightmare code, check for each individually and print it out --&gt;
  &lt;xsl:template match="fmp:FMPXMLRESULT"&gt;
  &lt;PRODUCTRECS&gt;
  &lt;xsl:for-each select="fmp:RESULTSET/fmp:ROW"&gt;
      &lt;PRODUCT&gt;
  &lt;xsl:for-each select="fmp:COL"&gt;
  &lt;xsl:if test="position()=1"&gt;
      &lt;name&gt;&lt;xsl:value-of select="fmp:DATA"/&gt;&lt;/name&gt;
  &lt;/xsl:if&gt;
  ...
  &lt;/xsl:for-each&gt;
      &lt;/PRODUCT&gt;
  &lt;/xsl:for-each&gt;
  &lt;/PRODUCTRECS&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>This is what Filemaker outputs by default:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult"&gt;
  &lt;ERRORCODE&gt;0&lt;/ERRORCODE&gt;
  &lt;PRODUCT BUILD="01-01-2009" NAME="FileMaker Pro" VERSION="10.0v3"/&gt;
  &lt;DATABASE DATEFORMAT="M/d/yyyy" LAYOUT="" NAME="filename.fp7" RECORDS="10" TIMEFORMAT="h:mm:ss a"/&gt;
  &lt;METADATA&gt;
    &lt;FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="name" TYPE="TEXT"/&gt;
    &lt;FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="address" TYPE="TEXT"/&gt;
    &lt;FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="city" TYPE="TEXT"/&gt;
    &lt;FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="state" TYPE="TEXT"/&gt;
    &lt;FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="zip" TYPE="TEXT"/&gt;
  &lt;/METADATA&gt;
  &lt;RESULTSET FOUND="10"&gt;
  &lt;ROW MODID="0" RECORDID="1"&gt;
    &lt;COL&gt;&lt;DATA&gt;Dr. Zim&lt;/DATA&gt;&lt;/COL&gt;
    &lt;COL&gt;&lt;DATA&gt;1234 Internet Way&lt;/DATA&gt;&lt;/COL&gt;
    &lt;COL&gt;&lt;DATA&gt;&lt;/DATA&gt;&lt;/COL&gt;
    &lt;COL&gt;&lt;DATA&gt;&lt;/DATA&gt;&lt;/COL&gt;
    &lt;COL&gt;&lt;DATA&gt;&lt;/DATA&gt;&lt;/COL&gt;
    ...
  &lt;/ROW&gt;
  ...
  &lt;/RESULTSET&gt;
  &lt;/FMPXMLRESULT&gt;
  </code></pre>
  
  <p>Looking forward to the guru XSLTers out there.  :)  Another question I had was how to format a numeric price when the original is stored as Text (00009.99000000) in the XML in to a currency of $9.99, but I can work on this one.</p>