我會改寫整個問題,因爲我幾乎有解決方案,並構建不好我的問題:XSLT置換加逗號,「與」
我的代碼:
<xsl:for-each select="documentarycredits/documentarycreditdata">
<xsl:if test="tradetypes/option[@id='tradefinguar']='selected'">Trade Finance Guarantee</xsl:if>
<xsl:if test="tradetypes/option[@id='tradefinstand']='selected'">Trade Finance Standby Letters of Credit serving as Financial Guarantees</xsl:if>
<xsl:if test="tradetypes/option[@id='tradefindoc']='selected'">Trade Finance Documentary Credits</xsl:if>
<xsl:if test="position()!=last()">
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:if test="position()=last()-1">
<xsl:text> and </xsl:text>
</xsl:if>
<xsl:if test="position()=last()">
<xsl:text></xsl:text>
</xsl:if>
</xsl:for-each>
這似乎工作除了它有'和'例如'A和B'。
理想情況下,我想要A和B,其他任何東西都可以有E.G. A,B,C和F
即使我有20個值的下拉列表,我也想應用相同的值。
感謝
編輯對JLRish &添Ç回答評論:
<tradetypes>
<option id="tradefinguar">selected</option>
<option id="tradefinstand"/>
<option id="tradefindoc"/>
</tradetypes>
有這將導致許多單獨的XSLT屏幕所以它可能有不止上述三個可以選擇以倍數表示,例如A,A,B,C,A和B,但理想情況下,我希望知道是否已經選擇了一個已經生產過的產品。
也許XSL-如果是更好地使用 – topcat3
你能提供你的輸入XML的相關部分?你在用什麼XSLT處理器? – JLRishe
我已經添加了這個問題。我接近得到它,但需要調整我的想法。 – topcat3