Using the xsl:for-each command

In this recipe, we will examine the usage of the for-each command in XSLT. This function is helpful when we need to transform a number of identical elements in the array. We will use the for-each command to map (transform) the list of the available cars.

Getting ready

We will modify the example from the The chaining functions recipe. For our recipe, we will define a new schema to show how the for-each command works. We define a schema that presents a list of the available cars to be rented. The schema is as follows:

 <xsd:element name = "WScars"> <xsd:complexType> <xsd:sequence> <xsd:element name = "listCars" maxOccurs = "unbounded"> <xsd:complexType> <xsd:sequence> <xsd:element name = "carType" type = "xsd:string"/> ...

Get BPEL and Java Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.