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.
<!-- What we actually want example -->
<?xml version="1.0" encoding="UTF-8"?>
<PRODUCTRECS>
<PRODUCT>
<name>Dr. Zim</name>
<address>1234 Internet Way</address>
<city/><state/><zip/>
</PRODUCT>
...
</PRODUCTRECS>
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):
<!-- Current nightmare code, check for each individually and print it out -->
<xsl:template match="fmp:FMPXMLRESULT">
<PRODUCTRECS>
<xsl:for-each select="fmp:RESULTSET/fmp:ROW">
<PRODUCT>
<xsl:for-each select="fmp:COL">
<xsl:if test="position()=1">
<name><xsl:value-of select="fmp:DATA"/></name>
</xsl:if>
...
</xsl:for-each>
</PRODUCT>
</xsl:for-each>
</PRODUCTRECS>
</xsl:template>
This is what Filemaker outputs by default:
<?xml version="1.0" encoding="UTF-8" ?>
<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
<ERRORCODE>0</ERRORCODE>
<PRODUCT BUILD="01-01-2009" NAME="FileMaker Pro" VERSION="10.0v3"/>
<DATABASE DATEFORMAT="M/d/yyyy" LAYOUT="" NAME="filename.fp7" RECORDS="10" TIMEFORMAT="h:mm:ss a"/>
<METADATA>
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="name" TYPE="TEXT"/>
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="address" TYPE="TEXT"/>
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="city" TYPE="TEXT"/>
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="state" TYPE="TEXT"/>
<FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="zip" TYPE="TEXT"/>
</METADATA>
<RESULTSET FOUND="10">
<ROW MODID="0" RECORDID="1">
<COL><DATA>Dr. Zim</DATA></COL>
<COL><DATA>1234 Internet Way</DATA></COL>
<COL><DATA></DATA></COL>
<COL><DATA></DATA></COL>
<COL><DATA></DATA></COL>
...
</ROW>
...
</RESULTSET>
</FMPXMLRESULT>
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.