我花了一些时间搜索stackoveflow数据库;找不到帮助以下内容的示例。这是FMP出口:
<?xml version="1.0" encoding="UTF-8" ?>
<FMPDSORESULT xmlns="http://www.filemaker.com/fmpdsoresult">
<ERRORCODE>0</ERRORCODE>
<DATABASE>catalogus.fmp12</DATABASE>
<LAYOUT>items</LAYOUT>
<ROW MODID="178" RECORDID="560">
<sub_group>This is the title</sub_group>
<description>This is the description</description>
<item_number><DATA>010050</DATA><DATA>010350</DATA></item_number>
<item_name><DATA>UNIVERSAL PUMP</DATA><DATA>SPARE PARTS SET</DATA></item_name>
</ROW>
</FMPDSORESULT>
样式表一切顺利:
<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:fm="http://www.filemaker.com/fmpdsoresult" exclude-result-prefixes="fm">
<xsl:output version='1.0' encoding='UTF-8' indent='yes' method='xml' />
<xsl:template match="/">
<items>
<xsl:for-each select="fm:FMPDSORESULT/fm:ROW">
<item>
<sub_group>
<xsl:value-of select="./fm:sub_group" />
</sub_group>
<description>
<xsl:value-of select="./fm:description" />
</description>
<subitems>
<xsl:for-each select="?????????????????????">
<related>
<xsl:value-of select="."/>
</related>
</xsl:for-each>
</subitems>
</item>
</xsl:for-each>
</items>
</xsl:template>
</xsl:stylesheet>
这给出了:
<?xml version="1.0" encoding="UTF-8"?>
<items>
<item>
<sub_group>This is the title</sub_group>
<description>This is the description</description>
<subitems>
</subitems>
</item>
</items>
我希望得到类似的东西:
This is the title
This is the description
010050 Universal Pump
010350 Spare Parts Set
获取这些相关值的正确格式应该是什么? 感谢帮助。对我来说,这个xml / InDesign项目是更熟悉xml的完美方式。
答案 0 :(得分:0)
我无法找出输出所需的确切格式。尝试更换有问题的部分:
<subitems>
<xsl:for-each select="?????????????????????">
<related>
<xsl:value-of select="."/>
</related>
</xsl:for-each>
</subitems>
使用:
<subitems>
<xsl:for-each select="fm:item_number/fm:DATA">
<xsl:variable name="i" select="position()" />
<subitem>
<item_number>
<xsl:value-of select="."/>
</item_number>
<item_name>
<xsl:value-of select="../../fm:item_name/fm:DATA[$i]"/>
</item_name>
</subitem>
</xsl:for-each>
</subitems>
这应该产生以下结果:
<?xml version="1.0" encoding="UTF-8"?>
<items>
<item>
<sub_group>This is the title</sub_group>
<description>This is the description</description>
<subitems>
<subitem>
<item_number>010050</item_number>
<item_name>UNIVERSAL PUMP</item_name>
</subitem>
<subitem>
<item_number>010350</item_number>
<item_name>SPARE PARTS SET</item_name>
</subitem>
</subitems>
</item>
</items>