I was doing a test website where on one page somebody could select a
Genre from a drop-down list and it would display every sub-listing
under that specific Genre. If the user selected All it would display
everything. Now I have tried to implement it into my real homepage and
I am having a little problem. Now not only do I pass the Genre to my
XSLT but I pass the Hardware selection to the XSLT file. I get this
error.
"Expected token 'EOF' found ':'.
lc:Entertainmen t/lc-->:<--$Hardware
Here is my drop-down list
<select name="select1" onchange='CallX ML(this.form.se lect1, "PS2");'>
<option selected>Please Select a Genre</option>
<option value="All">All </option>
<option value="Fighting ">Fighting</option>
<option value="FPS">Fir st Person Shooter</option>
<option value="Platform er">Platforme r</option>
<option value="Sports"> Sports</option>
<option value="TPA">Thi rd Person Action</option>
</select>
Here is my Javascript file.
function CallXML(dropdow n, hardware)
{
var myIndex = dropdown.select edIndex;
var SelValue = dropdown.option s[myIndex].value;
var xsltTree = new ActiveXObject(" Msxml2.FreeThre adedDOMDocument .4.0");
xsltTree.async = false;
xsltTree.load(" Entertainment.x slt")
var srcTree = new ActiveXObject(" Msxml2.DOMDocum ent.4.0");
srcTree.async = false;
srcTree.load("E ntertainment.xm l");
var xsltThread = new ActiveXObject(" Msxml2.XSLTempl ate.4.0");
xsltThread.styl esheet = xsltTree;
var xsltProc = xsltThread.crea teProcessor();
xsltProc.input = srcTree;
xsltProc.addPar ameter("Hardwar e", hardware);
xsltProc.addPar ameter("Genre", SelValue);
xsltProc.transf orm();
GameTable.inner HTML = xsltProc.output ;
}
Here is my XSLT file
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:lc="http://mark/Homepage">
<xsl:output method="html"/>
<xsl:param name="Hardware"/>
<xsl:param name="Genre"/>
<xsl:template match="/">
<xsl:choose>
<xsl:when test="$Genre = 'All'">
<xsl:call-template name="All" />
</xsl:when>
<xsl:otherwis e>
<xsl:call-template name="NotAll" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="All">
<table border="0">
<xsl:for-each select="lc:Ente rtainment/lc:$Hardware">
<tr>
<th colspan="2" bgcolor="Green" ><xsl:value-of
select="lc:Titl e"/></th>
</tr>
<tr>
<td>
<xsl:element name="IMG">
<xsl:attribut e name="SRC">
<xsl:value-of select="lc:Pict ure"/>
</xsl:attribute>
</xsl:element>
</td>
<td>
<xsl:value-of select="lc:Desc ription"/>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template name="NotAll">
<table border="0">
<xsl:for-each select="lc:Ente rtainment/lc:$Hardware[lc:Genre =
$Genre]">
<tr>
<th colspan="2" bgcolor="Green" ><xsl:value-of
select="lc:Titl e"/></th>
</tr>
<tr>
<td>
<xsl:element name="IMG">
<xsl:attribut e name="SRC">
<xsl:value-of select="lc:Pict ure"/>
</xsl:attribute>
</xsl:element>
</td>
<td>
<xsl:value-of select="lc:Desc ription"/>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>
Here is a portion of my XML file
<Entertainmen t xmlns="http://mark/Homepage/">
<PS2>
<Genre>Fighting </Genre>
<Picture>images \ps2\MortalKomb at.gif</Picture>
<Rating>5</Rating>
<Title>Mortal Kombat Deadly Alliance</Title>
<userCount>0</userCount>
<userRating>0 </userRating>
</PS2>
<PS2>
<Genre>Fighting </Genre>
<Picture>images \ps2\NoGif.gif</Picture>
<Rating>4</Rating>
<Title>Virtua Fighter 4: Evolution</Title>
<userCount>0</userCount>
<userRating>0 </userRating>
</PS2>