<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.filemaker.com/fmpxmlresult">
	
  <xsl:template match="/">
		<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
			<ERRORCODE>0</ERRORCODE>
			<PRODUCT BUILD="" NAME="" VERSION=""/>
			<DATABASE DATEFORMAT="M/d/yyyy" LAYOUT="" NAME="" RECORDS="{count(/*/*)}" TIMEFORMAT="h:mm:ss a"/>
			<xsl:call-template name="METADATA"/>
		</FMPXMLRESULT>
	</xsl:template>
  
	<xsl:template name="METADATA" match="//GILTIGA[1]">
		<METADATA>
      <FIELD>
        <xsl:attribute name="EMPTYOK">YES</xsl:attribute>
        <xsl:attribute name="MAXREPEAT">1</xsl:attribute>
        <xsl:attribute name="NAME">KOD</xsl:attribute>
        <xsl:attribute name="TYPE">TEXT</xsl:attribute>
      </FIELD>
      <FIELD>
        <xsl:attribute name="EMPTYOK">YES</xsl:attribute>
        <xsl:attribute name="MAXREPEAT">1</xsl:attribute>
        <xsl:attribute name="NAME">NAMN</xsl:attribute>
        <xsl:attribute name="TYPE">TEXT</xsl:attribute>
      </FIELD>
      <FIELD>
        <xsl:attribute name="EMPTYOK">YES</xsl:attribute>
        <xsl:attribute name="MAXREPEAT">1</xsl:attribute>
        <xsl:attribute name="NAME">PARTI</xsl:attribute>
        <xsl:attribute name="TYPE">TEXT</xsl:attribute>
      </FIELD>
      <FIELD>
        <xsl:attribute name="EMPTYOK">YES</xsl:attribute>
        <xsl:attribute name="MAXREPEAT">1</xsl:attribute>
        <xsl:attribute name="NAME">RÖSTER</xsl:attribute>
        <xsl:attribute name="TYPE">TEXT</xsl:attribute>
      </FIELD>
      <FIELD>
        <xsl:attribute name="EMPTYOK">YES</xsl:attribute>
        <xsl:attribute name="MAXREPEAT">1</xsl:attribute>
        <xsl:attribute name="NAME">RÖSTER_FGVAL</xsl:attribute>
        <xsl:attribute name="TYPE">TEXT</xsl:attribute>
      </FIELD>
      <FIELD>
        <xsl:attribute name="EMPTYOK">YES</xsl:attribute>
        <xsl:attribute name="MAXREPEAT">1</xsl:attribute>
        <xsl:attribute name="NAME">PROCENT</xsl:attribute>
        <xsl:attribute name="TYPE">TEXT</xsl:attribute>
      </FIELD>
      <FIELD>
        <xsl:attribute name="EMPTYOK">YES</xsl:attribute>
        <xsl:attribute name="MAXREPEAT">1</xsl:attribute>
        <xsl:attribute name="NAME">PROCENT_FGVAL</xsl:attribute>
        <xsl:attribute name="TYPE">TEXT</xsl:attribute>
      </FIELD>
      <FIELD>
        <xsl:attribute name="EMPTYOK">YES</xsl:attribute>
        <xsl:attribute name="MAXREPEAT">1</xsl:attribute>
        <xsl:attribute name="NAME">PROCENT_ÄNDRING</xsl:attribute>
        <xsl:attribute name="TYPE">TEXT</xsl:attribute>
      </FIELD>
		</METADATA>
		<xsl:call-template name="RESULTSET"/>
	</xsl:template>

  <xsl:template name="RESULTSET" match="//GILTIGA">
		<RESULTSET>
			<xsl:attribute name="FOUND"><xsl:value-of select="count(//GILTIGA)"/></xsl:attribute>
			<xsl:for-each select="//GILTIGA">
				<ROW>
					<xsl:attribute name="MODID">0</xsl:attribute>
					<xsl:attribute name="RECORDID">0</xsl:attribute>
          <COL>
            <DATA>
              <xsl:value-of select="../@KOD"/>
            </DATA>
          </COL>
          <COL>
            <DATA>
              <xsl:value-of select="../@NAMN"/>
            </DATA>
          </COL>
          <xsl:for-each select="@*">
						<COL>
							<DATA>
								<xsl:value-of select="."/>
							</DATA>
						</COL>
					</xsl:for-each>
				</ROW>
			</xsl:for-each>
		</RESULTSET>
	</xsl:template>
</xsl:stylesheet>

