Filemaker xml output via xslt with column names -


i new xslt programming , xlm. have created code below works fine, except instead variable names each column, shows "colno" how column names output?

<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:fmp="http://www.filemaker.com/fmpxmlresult"   exclude-result-prefixes="fmp" > <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>    <xsl:variable name="kmetadata" select="fmp:metadata/fmp:field"/>   <xsl:variable name="colno"        select="count($kmetadata[following-sibling::fmp:field/@name]) + 1" />    <xsl:template match="/fmp:fmpxmlresult">     <person>       <xsl:apply-templates select="fmp:resultset/fmp:row" />     </person>   </xsl:template>    <xsl:template match="fmp:row">     <elements>       <xsl:apply-templates select="fmp:col" />      </elements>   </xsl:template>    <xsl:template match="fmp:col">      <xsl:element name="colno">       <xsl:value-of select="fmp:data" />     </xsl:element>   </xsl:template> </xsl:stylesheet> 

it hard make suggestion without input xml. @ first sight <xsl:element name="colno"> says "output element <colno>". think should use <xsl:element name="{xpath/to/columnname}">

edit:

according input xml template "col" element should like

<xsl:template match="col">     <xsl:variable name="colposition" select="position()" />     <!-- prevent spaces in name attribute of field element -->     <xsl:variable name="colname" select="translate($kmetadata[$colposition]/@name, ' ', '_')" />     <xsl:element name="{$colname}">         <xsl:value-of select="data"/>     </xsl:element> </xsl:template> 

then output looks

<?xml version="1.0" encoding="utf-8"?> <person>     <elements>         <firstname>richard</firstname>         <lastname>katz</lastname>         <middlename>david</middlename>         <requestdt>1/1/2001</requestdt>         <salutation>mr</salutation>         <bargaining_unit>csea (02,03,04)</bargaining_unit>         <field_134>b</field_134>     </elements> </person> 

Comments