xslt を使用して、コーヒー項目の数をループする必要がありますが、20 回に制限する必要があります。10 個のコーヒー アイテムがある場合、20 回未満で 10 回ループする必要があります。20点以上のコーヒーはお受けできません。ループ コーヒー アイテムの後、変換された xml の CoffeeList ノードに追加します。
また、コーヒーアイテムに価値がない場合は無視してください。xsltファイルで実装する方法。あなたの助けに感謝します。
XML:
<Action>
<Coffee1> hello 1 </Coffee1>
<Coffee2> hello 2</Coffee2>
<Coffee3> </Coffee3>
<Coffee4> hello 4</Coffee4>
<Amount1>1.2000</Amount1>
<Amount2>2.0000</Amount2>
<Amount3>1.2100</Amount3>
<Amount4>2.0000</Amount4>
</Action>
出力:
<CoffeeList>
<Coffee coffeeCode="hello 1" amount="1.2000" />
<Coffee coffeeCode="hello 2 " amount="2.0000" />
<Coffee coffeeCode="hello 4" amount="1.2100" />
</CoffeeList>
XSLT: - 出力が必要なため、これを実装する方法がわかりません。
<xsl:for-each select="Action">
<xsl:sort select="Coffee" data-type="string" />
<xsl:if test="position() < 20">
<xsl:value-of select="Coffee"/>
</xsl:if>
</xsl:for-each>