我在XSLT方面很弱,所以這可能看起來很明顯。下面是一些示例XMLXSLT,一個接一個的處理元素
<term>
<name>cholecystocolonic fistula</name>
<definition>blah blah</definition>
<reference>cholecystocolostomy</reference>
</term>
這裏是我寫的前一陣子處理它
<xsl:template name="term">
{
"dictitle": "<xsl:value-of select="name" disable-output-escaping="yes" />",
"html": "<xsl:value-of select="definition" disable-output-escaping="yes"/>",
"reference": "<xsl:value-of select="reference" disable-output-escaping="yes"/>
}
</xsl:template>
基本上我從XML創建JSON的XSLT。
現在需求已經改變,現在XML可以有多個定義標籤和引用標籤。它們可以以任何順序出現,即定義,參考,參考,定義,參考。
如何更新XSLT以適應此?可能值得一提的是,因爲我的XSLT處理器正在使用.NET,所以我只能使用XSLT 1.0命令。
非常感謝!
編輯 - 澄清
這是我想創造的那種JSON的,下面給出示例XML
<term>
<name>cholecystocolonic fistula</name>
<definition>blah blah</definition>
<reference>cholecystocolostomy</reference>
<definition>XSLT is not as easy as it should be</definition>
<reference>qui</reference>
</term>
{
dictitle: "cholecystocolonic fistula",
html: "blah blah",
reference: "cholecystocolostomy",
html: "XSLT is not as easy as it should be",
reference: "qui"
}
啊,我不知道這一點,這有點煩人:/ – qui 2010-06-01 11:18:10
標記爲答案,因爲它已經引導我遠離這種方法;( – qui 2010-06-01 11:32:31