Click to See Complete Forum and Search --> : need help using multiple element per parent element


talal
04-03-2004, 09:53 PM
I am trying to include multiple cast element per movie element in the xml file.

In the inline doctype the declaration is:
<!ELEMENT movie (title, rating, year, director, cast+)>
<!ELEMENT cast (#PCDATA)>

The code in xml is:
<movie>
<title>Dawn of the Dead</title>
<rating code = "R" />
<year>2004</year>
<director>Zack Snyder</director>
<cast>Ving Rhames-</cast>
<cast>Sarah Polley-</cast>
</movie>

The code I am using to display is from xsl file, which is:
<tr>
<td><b>Cast</b></td>
<td><xsl:value-of select = "cast" /></td>
</tr>

But it is only displaying the first cast element data, please let me know what I am doing wrong here.

This is my first xml class project, so right now I am just familiar to basic xml. Thanks for any help in advance.

Talal

Khalid Ali
04-03-2004, 10:11 PM
to me it looks like yuor xsl is not parsing all the nodes typically when you
do this
<xsl:value-of select = "/cast" />
it should retrieve all of the nodes with that name.

talal
04-04-2004, 12:24 AM
I am posting my both xml and xsl files. The last data record in xml file has two cast elements and I want to display them.

cast is an element under /videostore/movie.

thanks,
Talal

Khalid Ali
04-04-2004, 10:57 AM
Replace

<tr>
<td><b>Cast</b></td>
<td><xsl:value-of select = "cast" />-</td>
</tr>


with the following piece of code


<xsl:for-each select = "cast">
<tr>
<td><b>Cast</b></td>
<td><xsl:value-of select = "." />-</td>
</tr>
</xsl:for-each>


I hope this helps

talal
04-04-2004, 02:46 PM
Khalid, thanks for the good advice, it works now.

Also, can you explain what the "." means in the following element,
<xsl:value-of select = "." />

thanks,
Talal

Khalid Ali
04-04-2004, 04:59 PM
it points to the current element that xsl for each pointer is processing, in this case which is cast