Im not entirely sure if this is possible with XSLT and my lecturer had no idea what i was talking about so if anyone could help, thanks!!!
I have an XML file with a list of authors, each with a unique id, and a list of books, each with a child element with an IDREF as its value. The file is laid out like this:
<library>
<authors>
<author id="a001">
<name>Joyce</name>
</author>
</authors>
<books>
<book id="b001">
<name>Illiad</name>
<authorID>a001</authorID>
</book>
</books>
</library>
I am trying to write out a list of all books and, by using the authorID value, get information on the Author.
XSLT:
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>XSLT Test</title>
</head>
<body>
<xsl:for-each select="//book">
<div style="display:block; background-color:#999; padding:2px; margin:2px;">
<h2><xsl:value-of select="name"/></h2>
<p><xsl:value-of select="synopsis"/></p>
<ul>
<li>Author: <xsl:value-of select="//author[@id='X']/name"/></li>
</ul>
</div>
</xsl:for-each>
</body>
</html>
By replacing X with a value, eg a001, I can get Joyce back but how can i use the authorID value here instead, so that the system scales up nicely?