Filemaker XSL Importing blank fields

旧街凉风 提交于 2019-12-13 19:15:26

问题


In learning to import XML items to Filemaker 13 I've run into a problem using "xsl:for-each" to obtain multiple rows of data for import. The XML I've been using is the W3 Schools Music Example.

The XSL I'm using to convert this XML is as follows:

<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">

<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">

  <METADATA>
      <FIELD NAME="Title" TYPE="TEXT"/>
      <FIELD NAME="Artist" TYPE="TEXT"/>
      <FIELD NAME="Country" TYPE="TEXT"/>
      <FIELD NAME="Company" TYPE="TEXT"/>
      <FIELD NAME="Price" TYPE="NUMBER"/>
      <FIELD NAME="Year" TYPE="NUMBER"/>
  </METADATA>

  <RESULTSET>  
    <xsl:for-each select="catalog/cd">   
          <ROW>
        <COL>
          <DATA><xsl:value-of select="catalog/cd/title"/></DATA>
        </COL>
        <COL>
          <DATA><xsl:value-of select="catalog/cd/artist"/></DATA>
        </COL>
        <COL>
          <DATA><xsl:value-of select="catalog/cd/country"/></DATA>
        </COL>
        <COL>
          <DATA><xsl:value-of select="catalog/cd/company"/></DATA>
        </COL>
        <COL>
          <DATA><xsl:value-of select="catalog/cd/price"/></DATA>
        </COL>
        <COL>
          <DATA><xsl:value-of select="catalog/cd/year"/></DATA>
        </COL>       
      </ROW>
      </xsl:for-each>     
  </RESULTSET>
</FMPXMLRESULT>

</xsl:template>
</xsl:stylesheet>

If I remove the "xsl:for-each" lines, I will reliably get the first record from the XML imported into Filemaker. With the "xsl:for-each" lines in place as shown, I will get 26 blank records. There are 26 items in the XML, which is good, but I'm not getting any data.

As an aside, if the xsl select string is modified to read "catalog/cd/title[4]", which I believe should return the fourth record in the XML, I again get a blank record.

What am I missing here?


回答1:


Inside of the for-each the context node is a cd element so your paths need to be relative to that e.g. <xsl:value-of select="title"/>



来源:https://stackoverflow.com/questions/31302581/filemaker-xsl-importing-blank-fields

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!