我发现学习 XSLT 确实非常困难 - 似乎缺乏尚未复杂得令人眼花缭乱的初学者指南。我希望有人可以帮助我,拜托。
我需要将下面的简单 XML 文件转换为 Filemaker 12 可以读取的 XML:
<properties>
<property>
<ref>12345</ref>
<location>somewhere
<price>12345</price>
<photos>
<photo>www.test.com/1.jpg</photo>
<photo>www.test.com/2.jpg</photo>
<photo>www.test.com/3.jpg</photo>
</photos>
<details>
<summary>nice house</summary>
<description>a very very nice house</description>
</details>
</property>
</properties>
我似乎无法弄清楚如何循环浏览照片(可能是 1 或 30 张)并获得摘要和描述。
任何人都可以帮忙吗?
非常感谢!
这是我到目前为止所拥有的:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="xsl">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
<ERRORCODE>0</ERRORCODE>
<PRODUCT BUILD="" NAME="FileMaker" VERSION="ProAdvanced 12.0v4"/>
<DATABASE DATEFORMAT="" LAYOUT="" NAME="" RECORDS="" TIMEFORMAT=""/>
<METADATA>
<FIELD EMPTYOK="NO" MAXREPEAT="1" NAME="ref" TYPE="TEXT" />
<FIELD EMPTYOK="NO" MAXREPEAT="1" NAME="location" TYPE="TEXT" />
<FIELD EMPTYOK="NO" MAXREPEAT="1" NAME="price" TYPE="NUMBER" />
<FIELD EMPTYOK="YES" MAXREPEAT="30" NAME="photo" TYPE="TEXT" />
<FIELD EMPTYOK="NO" MAXREPEAT="1" NAME="summary" TYPE="TEXT" />
<FIELD EMPTYOK="NO" MAXREPEAT="1" NAME="description" TYPE="TEXT" />
</METADATA>
<RESULTSET FOUND="">
<xsl:for-each select="properties/property">
<ROW RECORDID="" MODID="">
<COL><DATA><xsl:value-of select="ref"/></DATA></COL>
<COL><DATA><xsl:value-of select="location"/></DATA></COL>
<COL><DATA><xsl:value-of select="price"/></DATA></COL>
<xsl:for-each select="properties/property/photos">
<COL>
<DATA><xsl:value-of select="photo"/></DATA>
</COL>
</xsl:for-each>
<COL><DATA><xsl:value-of select="summary"/></DATA></COL>
<COL><DATA><xsl:value-of select="description"/></DATA></COL>
</ROW>
</xsl:for-each>
</RESULTSET>
</FMPXMLRESULT>
</xsl:template>
</xsl:stylesheet>