Using XSLT to modify XML for Filemaker Pro data import
Posted: Tue Mar 22, 2005 12:25 am
Hi,
I'm a newbie to XSLT and have been reading a lot, but most of the ideas are still pretty foreign at this stage. Here is my basic challenge:
I want to take an XML document provided by the US National Weather Service: http://weather.gov/data/current_obs/KDCA.xml
And apply an XSLT provided by FileMaker so that the resulting transformation meets the FileMaker Pro grammar requirements.
The XSLT is as follows:
If I go in and put a tag at the beginning and end of the .xml document Filemaker is happy. Without a tag Filemaker doesn't think there is a "record" to import. Is there a way in the XSLT to generate atag around the entire XML document body so FileMaker is happy?
Thanks for any help.
Paul[/code]
I'm a newbie to XSLT and have been reading a lot, but most of the ideas are still pretty foreign at this stage. Here is my basic challenge:
I want to take an XML document provided by the US National Weather Service: http://weather.gov/data/current_obs/KDCA.xml
And apply an XSLT provided by FileMaker so that the resulting transformation meets the FileMaker Pro grammar requirements.
The XSLT is as follows:
Code: Select all
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<!--
File: msdso_elem.xslt
Transforms data in an ELEMENT based MSDSO grammar
into the FMPXMLRESULT grammar, suitable for import.
===============================================================
Copyright © 2002 FileMaker, Inc.
All rights reserved.
===============================================================
-->
<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>
Thanks for any help.
Paul[/code]