Created
January 23, 2012 22:03
-
-
Save dericed/1665773 to your computer and use it in GitHub Desktop.
xsl to translate filemaker output to dublist.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<xsl:stylesheet version="1.0" xmlns:fmp="http://www.filemaker.com/fmpxmlresult" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="fmp xsl"> | |
<xsl:output encoding="UTF-8" method="xml" version="1.0" indent="yes"/> | |
<xsl:key name="N" match="/fmp:FMPXMLRESULT/fmp:METADATA/fmp:FIELD" use="@NAME"/> | |
<xsl:key name="N" match="/fmp:FMPXMLRESULT/fmp:METADATA/fmp:FIELD" use="following-sibling::fmp:FIELD/@NAME"/> | |
<xsl:template match="fmp:FMPXMLRESULT"> | |
<xsl:apply-templates select="fmp:RESULTSET"/> | |
</xsl:template> | |
<xsl:template match="fmp:FMPXMLRESULT/fmp:RESULTSET"> | |
<PBSDubList> | |
<DubItems> | |
<xsl:for-each select="fmp:ROW"> | |
<xsl:variable name="row_pos" select="position()"/> | |
<xsl:variable name="asset_pk"><xsl:value-of select="fmp:COL[count(key('N','asset_serial_pk'))]/fmp:DATA"/></xsl:variable> | |
<DubItem> | |
<xsl:for-each select="fmp:COL[count(key('N', 'device_id'))]/fmp:DATA"> | |
<xsl:variable name="pos" select="position()"/> | |
<TapeId> | |
<xsl:value-of select="../../fmp:COL[count(key('N','device_id'))]/fmp:DATA[$pos]"/> | |
</TapeId> | |
</xsl:for-each> | |
<xsl:for-each select="fmp:COL[count(key('N', 'material_id'))]/fmp:DATA"> | |
<xsl:variable name="pos" select="position()"/> | |
<MediaId> | |
<xsl:value-of select="../../fmp:COL[count(key('N','material_id'))]/fmp:DATA[$pos]"/> | |
</MediaId> | |
</xsl:for-each> | |
<xsl:for-each select="fmp:COL[count(key('N', 'timecode_in'))]/fmp:DATA"> | |
<xsl:variable name="pos" select="position()"/> | |
<SOM> | |
<xsl:value-of select="substring(../../fmp:COL[count(key('N','timecode_in'))]/fmp:DATA[$pos],1,2)"/> | |
<xsl:text>:</xsl:text> | |
<xsl:value-of select="substring(../../fmp:COL[count(key('N','timecode_in'))]/fmp:DATA[$pos],4,2)"/> | |
<xsl:text>:</xsl:text> | |
<xsl:value-of select="substring(../../fmp:COL[count(key('N','timecode_in'))]/fmp:DATA[$pos],7,2)"/> | |
<xsl:text>;</xsl:text> | |
<xsl:value-of select="substring(../../fmp:COL[count(key('N','timecode_in'))]/fmp:DATA[$pos],10,2)"/> | |
</SOM> | |
</xsl:for-each> | |
<xsl:for-each select="fmp:COL[count(key('N', 'duration'))]/fmp:DATA"> | |
<xsl:variable name="pos" select="position()"/> | |
<Duration> | |
<xsl:value-of select="substring(../../fmp:COL[count(key('N','duration'))]/fmp:DATA[$pos],1,2)"/> | |
<xsl:text>:</xsl:text> | |
<xsl:value-of select="substring(../../fmp:COL[count(key('N','duration'))]/fmp:DATA[$pos],4,2)"/> | |
<xsl:text>:</xsl:text> | |
<xsl:value-of select="substring(../../fmp:COL[count(key('N','duration'))]/fmp:DATA[$pos],7,2)"/> | |
<xsl:text>;</xsl:text> | |
<xsl:value-of select="substring(../../fmp:COL[count(key('N','duration'))]/fmp:DATA[$pos],10,2)"/> | |
</Duration> | |
</xsl:for-each> | |
<xsl:for-each select="fmp:COL[count(key('N', 'PBCoreTitle_via_xml::title'))]/fmp:DATA"> | |
<xsl:variable name="pos" select="position()"/> | |
<Title> | |
<xsl:value-of select="../../fmp:COL[count(key('N','PBCoreTitle_via_xml::title'))]/fmp:DATA[$pos]"/> | |
</Title> | |
</xsl:for-each> | |
<xsl:for-each select="fmp:COL[count(key('N', 'PBCoreDescription_via_xml::description'))]/fmp:DATA"> | |
<xsl:variable name="pos" select="position()"/> | |
<Notes> | |
<xsl:value-of select="../../fmp:COL[count(key('N','PBCoreDescription_via_xml::description'))]/fmp:DATA[$pos]"/> | |
</Notes> | |
</xsl:for-each> | |
</DubItem> | |
</xsl:for-each> | |
</DubItems> | |
</PBSDubList> | |
</xsl:template> | |
</xsl:stylesheet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment