Mark Constant
Usenet Archive
- Joined
- Apr 9, 2003
- Messages
- 38
- Reaction score
- 0
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:Entertainment/lc-->:<--$Hardware
Here is my drop-down list
<select name="select1" onchange='CallXML(this.form.select1, "PS2");'> <option selected>Please Select a Genre</option> <option value="All">All</option> <option value="Fighting">Fighting</option> <option value="FPS">First Person Shooter</option> <option value="Platformer">Platformer</option> <option value="Sports">Sports</option> <option value="TPA">Third Person Action</option> </select>
Here is my Javascript file.
function CallXML(dropdown, hardware)
{
var myIndex = dropdown.selectedIndex;
var SelValue = dropdown.options[myIndex].value;
var xsltTree = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0"); xsltTree.async = false; xsltTree.load("Entertainment.xslt")
var srcTree = new ActiveXObject("Msxml2.DOMDocument.4.0"); srcTree.async = false; srcTree.load("Entertainment.xml");
var xsltThread = new ActiveXObject("Msxml2.XSLTemplate.4.0"); xsltThread.stylesheet = xsltTree; var xsltProc = xsltThread.createProcessor; xsltProc.input = srcTree; xsltProc.addParameter("Hardware", hardware); xsltProc.addParameter("Genre", SelValue);
xsltProc.transform;
GameTable.innerHTML = xsltProc.output;
}
Here is my XSLT file
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:lc="http://mark/Homepage"> <xsl
utput method="html"/> <xsl
aram name="Hardware"/> <xsl
aram name="Genre"/>
<xsl:template match="/">
<xsl:choose>
<xsl:when test="$Genre = 'All'">
<xsl:call-template name="All" />
</xsl:when>
<xsl
therwise>
<xsl:call-template name="NotAll" />
</xsl
therwise>
</xsl:choose>
</xsl:template>
<xsl:template name="All">
<table border="0">
<xsl:for-each select="lc:Entertainment/lc:$Hardware">
<tr>
<th colspan="2" bgcolor="Green"><xsl:value-of
select="lc:Title"/></th>
</tr>
<tr>
<td>
<xsl:element name="IMG">
<xsl:attribute name="SRC">
<xsl:value-of select="lc
icture"/>
</xsl:attribute>
</xsl:element>
</td>
<td>
<xsl:value-of select="lc
escription"/>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template name="NotAll">
<table border="0">
<xsl:for-each select="lc:Entertainment/lc:$Hardware[lc:Genre = $Genre]"> <tr> <th colspan="2" bgcolor="Green"><xsl:value-of select="lc:Title"/></th> </tr> <tr> <td> <xsl:element name="IMG"> <xsl:attribute name="SRC"> <xsl:value-of select="lc
icture"/> </xsl:attribute> </xsl:element> </td> <td> <xsl:value-of select="lc
escription"/> </td> </tr> </xsl:for-each> </table> </xsl:template>
</xsl:stylesheet>
Here is a portion of my XML file
<Entertainment xmlns="http://mark/Homepage/"> <PS2> <Genre>Fighting</Genre> <Picture>images\ps2\MortalKombat.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>
"Expected token 'EOF' found ':'.
lc:Entertainment/lc-->:<--$Hardware
Here is my drop-down list
<select name="select1" onchange='CallXML(this.form.select1, "PS2");'> <option selected>Please Select a Genre</option> <option value="All">All</option> <option value="Fighting">Fighting</option> <option value="FPS">First Person Shooter</option> <option value="Platformer">Platformer</option> <option value="Sports">Sports</option> <option value="TPA">Third Person Action</option> </select>
Here is my Javascript file.
function CallXML(dropdown, hardware)
{
var myIndex = dropdown.selectedIndex;
var SelValue = dropdown.options[myIndex].value;
var xsltTree = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0"); xsltTree.async = false; xsltTree.load("Entertainment.xslt")
var srcTree = new ActiveXObject("Msxml2.DOMDocument.4.0"); srcTree.async = false; srcTree.load("Entertainment.xml");
var xsltThread = new ActiveXObject("Msxml2.XSLTemplate.4.0"); xsltThread.stylesheet = xsltTree; var xsltProc = xsltThread.createProcessor; xsltProc.input = srcTree; xsltProc.addParameter("Hardware", hardware); xsltProc.addParameter("Genre", SelValue);
xsltProc.transform;
GameTable.innerHTML = xsltProc.output;
}
Here is my XSLT file
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:lc="http://mark/Homepage"> <xsl
<xsl:template match="/">
<xsl:choose>
<xsl:when test="$Genre = 'All'">
<xsl:call-template name="All" />
</xsl:when>
<xsl
<xsl:call-template name="NotAll" />
</xsl
</xsl:choose>
</xsl:template>
<xsl:template name="All">
<table border="0">
<xsl:for-each select="lc:Entertainment/lc:$Hardware">
<tr>
<th colspan="2" bgcolor="Green"><xsl:value-of
select="lc:Title"/></th>
</tr>
<tr>
<td>
<xsl:element name="IMG">
<xsl:attribute name="SRC">
<xsl:value-of select="lc
</xsl:attribute>
</xsl:element>
</td>
<td>
<xsl:value-of select="lc
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<xsl:template name="NotAll">
<table border="0">
<xsl:for-each select="lc:Entertainment/lc:$Hardware[lc:Genre = $Genre]"> <tr> <th colspan="2" bgcolor="Green"><xsl:value-of select="lc:Title"/></th> </tr> <tr> <td> <xsl:element name="IMG"> <xsl:attribute name="SRC"> <xsl:value-of select="lc
</xsl:stylesheet>
Here is a portion of my XML file
<Entertainment xmlns="http://mark/Homepage/"> <PS2> <Genre>Fighting</Genre> <Picture>images\ps2\MortalKombat.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>