for-each of XSLT

There is a request that show some information on the page if the special products included in an xml file, and this need to be done by xslt.

Usually, we use for-each to look through all nodes and detect by if test=”condition” to check the result, but there is a problem that how to exit loop when we get correct result, so that don’t display multiple times?

XML data:

If the special products are more than one, the information will be repeat shown.

The solution is:

first, we need to change for-each code to only select the nodes which includes special product, the code is:

select=”node[condition1 or condition2 or …]

then we use xsl:if test=”position()<2″ in for-each loop, to show the information only one time.

XSL code:

 

Tagged with:
Posted in Uncategorized

Leave a Reply

Categories

Related Posts