AnsweredAssumed Answered

Simplest mod for XSLT example to import XML data?

Question asked by jpbarna on Jan 19, 2018
Latest reply on Jan 22, 2018 by beverly

Hi:

 

I'm not expert in XML and I have to import some data into FMP. I know the basics, that I have to transform my data into what FMP expects, via the XSLT xml file.

 

So, what I have to import is formatted as this, and I'm "succeeding at it" if I exclude the information marked red, that is one level below the instance level I'm capturing, so I'm not being able to do it.

 

<?xml version="1.0" encoding="utf-8"?>

<file>

    <instance>

      <ID>1</ID>

      <start>0</start>

      <end>19.06</end>

      <code>12. Bruno Cortez</code>

      <label>

        <group>Team</group>

        <text>Gremio</text>

      </label>

      <label>

        <group>Action</group>

        <text>Passes accurate</text>

      </label>

      <label>

        <group>Half</group>

        <text>1st half</text>

      </label>

      <pos_x>35.0</pos_x>

      <pos_y>60.0</pos_y>

    </instance>

If I run a straight import using the included with FMP msdso_elem.xslt, I get data into Filemaker but I miss some in the middle fields. I know I have to add a loop somewhere to catch that data, but I'm unsure about how and where.

 

The fields I miss are these:

 

<label>

        <group>Team</group>

        <text>Gremio</text>

      </label>

      <label>

        <group>Action</group>

        <text>Passes accurate</text>

      </label>

      <label>

        <group>Half</group>

        <text>1st half</text>

      </label>

 

And I expect to get 3 fields in FMP, named Team, Action and Half respectively.

 

The XSLT file I'm based on is this, and I just try to modify it.

 

<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"/>

  <METADATA>

  <xsl:for-each select="/*/*[position()=1]/*">

  <FIELD>

  <xsl:attribute name="EMPTYOK">YES</xsl:attribute>

  <xsl:attribute name="MAXREPEAT">1</xsl:attribute>

  <xsl:attribute name="NAME"><xsl:value-of select="name()"/></xsl:attribute>

  <xsl:attribute name="TYPE">TEXT</xsl:attribute>

  </FIELD>

  </xsl:for-each>

  </METADATA>

  <RESULTSET>

  <xsl:attribute name="FOUND"><xsl:value-of select="count(child::*)"/></xsl:attribute>

  <xsl:for-each select="child::*">

  <ROW>

  <xsl:attribute name="MODID">0</xsl:attribute>

  <xsl:attribute name="RECORDID">0</xsl:attribute>

  <xsl:for-each select="child::*">

  <COL>

  <DATA>

  <xsl:value-of select="."/>

  </DATA>

  </COL>

  </xsl:for-each>

  </ROW>

  </xsl:for-each>

  </RESULTSET>

  </FMPXMLRESULT>

  </xsl:template>

</xsl:stylesheet>

 

Can you help me with this?

 

Thanks!

Outcomes