I'm practicing some XSL and using this XML document as a simple example:
<?xml version="1.1" encoding="UTF-8"?>
<zoo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="zoo.xsd" >
<animals>
<animal type="lion">
<name>Zeus</name>
<gender>M</gender>
<eats>antelope</eats>
<eats>monkey</eats>
</animal>
<animal type="monkey">
<name>Fredo</name>
<gender>M</gender>
<eats>banana</eats>
<iseatenby>lion</iseatenby>
</animal>
<animal type="lion">
<name>Here</name>
<gender>F</gender>
<eats>antelope</eats>
<eats>monkey</eats>
</animal>
<animal type="antelope">
<name>Annie</name>
<gender>F</gender>
<eats>grass</eats>
<iseatenby>lion</iseatenby>
</animal>
<animal type="elephant">
<name>Moses</name>
<gender>M</gender>
<eats>leaves</eats>
</animal>
</animals>
</zoo>
I've been able to get some basic info via my XSL doc, but I'm stuck on one thing right now: how can I get all of the results if there are more than one? For example, in my document, some animals have multiple "eats" elements. I want to display them in a comma-separated string; eventually I want to transform each animal's elements into attributes and just have a single attribute for each. (Using my previous example, the new animal element lion's "eats" attribute would look like this: eats="antelope, monkey"
)
Could someone please explain how I would do something like this with XSL?? Any help is much appreciated. :)