Abishek
Abishek

Reputation: 31

How to pass an arraylist from Java to xsl and access this individual arraylist elements in XSL?

I am passing an arraylist from Java to Xsl using transformer.setParameter.

ArrayList books=new ArrayList<String>;
transformer.setparameter("booksinXSL","books");

Now I need to access this array's elements in XSL.

<xsl:param name="booksinXSL">

Now If I use this line of code in XSL it throws an error:Invalid conversion of ArrayList to NodeSet.

<value-of select="$booksinXSL[0]">

but if I set it as the below line it prints the entire array [book1,book2] without any error

<value-of select="$booksinXSL">

Upvotes: 3

Views: 3583

Answers (1)

gpu3d
gpu3d

Reputation: 1184

XSL does not have the concept on arrays defined, but you can define a variable to contain a set of nodes and then iterate through these nodes. You can see a useful example at this page.

Upvotes: 2

Related Questions