Multiple descriptors translate to for-each in XSLT



Assuming i have such simple xml file:



<store>
<author name="Jack">
<book>Book 1</book>
<book>Book 2</book>
</author>
<author name="Mike">
<book>Book 1</book>
</author>
</store>


As you noticed Jack has 2 books. I need following output after XSLT translation:



<list>
<author>
<name>Jack</name>
<book>Book 1</book>
</author>
<author>
<name>Jack</name>
<book>Book 2</book>
</author>
<author>
<name>Mike</name>
<book>Book 1</book>
</author>
</list>


As you noticed in the output (after xslt translation) we have 2 authors Jack with each book it has. Can we do that in XSLT. Is there some analogue of for-each like in C/Java and etc?


What if for example Jack will have 7 books is it possible to automate this, so after translation it would be 7 Jack's descriptors. Thank you.


No comments:

Post a Comment