473,779 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using the .addParameter() function

I have a drop-down list now and I got it so when something is selected
from the drop down list it calls a JavaScript function. I want it so
the value selected from the drop-down list is sent as a parameter to
the xslt file. When I select a value from the drop-down list nothing
appears. I want just a basic listing of Title, Image, and Description
outputed. I have done a basic JavaScript that uses the .write()
function and that worked so the value is getting sent to the
JavaScript function from the drop-down list. So the problem has to be
with the .addParameter function. What could I be missing?

Here is my javascript and drop-down menu.
<body MS_POSITIONING= "FlowLayout ">
<form id="Form1" method="post" runat="server">
<SELECT name="select1" onchange='CallX ML(this.form.se lect1);'>
<OPTION value="Ratchet and Clank">Ratchet and Clank</OPTION>
<OPTION value="Sly Cooper">Sly Cooper</OPTION>
</SELECT>
</form>
</body>


<script language="javas cript">
function CallXML(dropdow n)
{
var myindex = dropdown.select edIndex;
var SelValue = dropdown.option s[myindex].value;
xml = new ActiveXObject(" Msxml2.DOMDocum ent.4.0");
xml.async = false;
xml.load("Games .xml");
xslt = new ActiveXObject(" Msxml2.FreeThre adedDOMDocument .4.0");
xslt.async = false;
xslt.load("Game s.xslt");
xslTemp = new ActiveXObject(" Msxml2.XSLTempl ate.4.0");
xslTemp.stylesh eet = xslt;
var xslProc = xslTemp.createP rocessor();
xslProc.input = xml;
xslProc.addPara meter(Title, SelValue);
xslProc.transfo rm;
xslProc.output;
}
</script>

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/DevelopmentWebs ite">
<xsl:output method="html"/>
<xsl:param name="Title"/>
<xsl:template match="/">

<h2>My Game Collection</h2>
<table border="1">
<xsl:for-each select="lc:Ente rtainment/lc:GameList[lc:Title =
$Title]">
<tr>
<th colspan="2"><xs l:value-of select="lc:Titl e"/></th>
</tr>
<tr>
<td>
<xsl:element name="IMG">
<xsl:attribut e name="SRC">
<xsl:value-of select="lc:Imag e"/>
</xsl:attribute>
</xsl:element>
</td>
<td><xsl:valu e-of select="lc:Desc ription"/></td>
</tr>
</xsl:for-each>
</table>

</xsl:template>
</xsl:stylesheet>
Jul 20 '05 #1
12 6083
I don't see how you use the result from the transformation. There must be
some code that displays the result of the transformation -- e.g. assignment
to the "innerHTML" property of some html objext.
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

"Mark Constant" <co*******@mi x-net.net> wrote in message
news:ce******** *************** ***@posting.goo gle.com...
I have a drop-down list now and I got it so when something is selected
from the drop down list it calls a JavaScript function. I want it so
the value selected from the drop-down list is sent as a parameter to
the xslt file. When I select a value from the drop-down list nothing
appears. I want just a basic listing of Title, Image, and Description
outputed. I have done a basic JavaScript that uses the .write()
function and that worked so the value is getting sent to the
JavaScript function from the drop-down list. So the problem has to be
with the .addParameter function. What could I be missing?

Here is my javascript and drop-down menu.
<body MS_POSITIONING= "FlowLayout ">
<form id="Form1" method="post" runat="server">
<SELECT name="select1" onchange='CallX ML(this.form.se lect1);'>
<OPTION value="Ratchet and Clank">Ratchet and Clank</OPTION>
<OPTION value="Sly Cooper">Sly Cooper</OPTION>
</SELECT>
</form>
</body>


<script language="javas cript">
function CallXML(dropdow n)
{
var myindex = dropdown.select edIndex;
var SelValue = dropdown.option s[myindex].value;
xml = new ActiveXObject(" Msxml2.DOMDocum ent.4.0");
xml.async = false;
xml.load("Games .xml");
xslt = new ActiveXObject(" Msxml2.FreeThre adedDOMDocument .4.0");
xslt.async = false;
xslt.load("Game s.xslt");
xslTemp = new ActiveXObject(" Msxml2.XSLTempl ate.4.0");
xslTemp.stylesh eet = xslt;
var xslProc = xslTemp.createP rocessor();
xslProc.input = xml;
xslProc.addPara meter(Title, SelValue);
xslProc.transfo rm;
xslProc.output;
}
</script>

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/DevelopmentWebs ite">
<xsl:output method="html"/>
<xsl:param name="Title"/>
<xsl:template match="/">

<h2>My Game Collection</h2>
<table border="1">
<xsl:for-each select="lc:Ente rtainment/lc:GameList[lc:Title =
$Title]">
<tr>
<th colspan="2"><xs l:value-of select="lc:Titl e"/></th>
</tr>
<tr>
<td>
<xsl:element name="IMG">
<xsl:attribut e name="SRC">
<xsl:value-of select="lc:Imag e"/>
</xsl:attribute>
</xsl:element>
</td>
<td><xsl:valu e-of select="lc:Desc ription"/></td>
</tr>
</xsl:for-each>
</table>

</xsl:template>
</xsl:stylesheet>

Jul 20 '05 #2
"Dimitre Novatchev" <dn********@yah oo.com> wrote in message news:<bp******* ******@ID-152440.news.uni-berlin.de>...
I don't see how you use the result from the transformation. There must be
some code that displays the result of the transformation -- e.g. assignment
to the "innerHTML" property of some html objext.
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

"Mark Constant" <co*******@mi x-net.net> wrote in message
news:ce******** *************** ***@posting.goo gle.com...
I have a drop-down list now and I got it so when something is selected
from the drop down list it calls a JavaScript function. I want it so
the value selected from the drop-down list is sent as a parameter to
the xslt file. When I select a value from the drop-down list nothing
appears. I want just a basic listing of Title, Image, and Description
outputed. I have done a basic JavaScript that uses the .write()
function and that worked so the value is getting sent to the
JavaScript function from the drop-down list. So the problem has to be
with the .addParameter function. What could I be missing?

Here is my javascript and drop-down menu.
<body MS_POSITIONING= "FlowLayout ">
<form id="Form1" method="post" runat="server">
<SELECT name="select1" onchange='CallX ML(this.form.se lect1);'>
<OPTION value="Ratchet and Clank">Ratchet and Clank</OPTION>
<OPTION value="Sly Cooper">Sly Cooper</OPTION>
</SELECT>
</form>
</body>


<script language="javas cript">
function CallXML(dropdow n)
{
var myindex = dropdown.select edIndex;
var SelValue = dropdown.option s[myindex].value;
xml = new ActiveXObject(" Msxml2.DOMDocum ent.4.0");
xml.async = false;
xml.load("Games .xml");
xslt = new ActiveXObject(" Msxml2.FreeThre adedDOMDocument .4.0");
xslt.async = false;
xslt.load("Game s.xslt");
xslTemp = new ActiveXObject(" Msxml2.XSLTempl ate.4.0");
xslTemp.stylesh eet = xslt;
var xslProc = xslTemp.createP rocessor();
xslProc.input = xml;
xslProc.addPara meter(Title, SelValue);
xslProc.transfo rm;
xslProc.output;
}
</script>

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/DevelopmentWebs ite">
<xsl:output method="html"/>
<xsl:param name="Title"/>
<xsl:template match="/">

<h2>My Game Collection</h2>
<table border="1">
<xsl:for-each select="lc:Ente rtainment/lc:GameList[lc:Title =
$Title]">
<tr>
<th colspan="2"><xs l:value-of select="lc:Titl e"/></th>
</tr>
<tr>
<td>
<xsl:element name="IMG">
<xsl:attribut e name="SRC">
<xsl:value-of select="lc:Imag e"/>
</xsl:attribute>
</xsl:element>
</td>
<td><xsl:valu e-of select="lc:Desc ription"/></td>
</tr>
</xsl:for-each>
</table>

</xsl:template>
</xsl:stylesheet>


Even if I change the line xslProc.output; to Title.innerHTML =
xslProc.output nothing happens.
Jul 20 '05 #3
> Even if I change the line xslProc.output; to Title.innerHTML =
xslProc.output nothing happens.


So, what is your complete example?

I'd recommend that you have a look at the examples from the MSXML SDK and
try them, like this one:

<HTML>
<HEAD>
<TITLE>sample </TITLE>
<SCRIPT language = "javascript ">
function init()
{
var srcTree = new ActiveXObject(" Msxml2.DOMDocum ent.4.0");
srcTree.async=f alse;
srcTree.load("h ello.xml");

var xsltTree= new ActiveXObject(" Msxml2.DOMDOCUM ENT.4.0");
xsltTree.async = false;
xsltTree.load(" hello.xsl");

resTree.innerHT ML = srcTree.transfo rmNode(xsltTree );
}
</SCRIPT>
</HEAD>

<BODY onload = "init()" >
<div id="resTree"></div>
</BODY>

</HTML>You can incrementally add your code step by step, until you get your
application working.=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL


Jul 20 '05 #4
"Dimitre Novatchev" <dn********@yah oo.com> wrote in message news:<bp******* ******@ID-152440.news.uni-berlin.de>...
Even if I change the line xslProc.output; to Title.innerHTML =
xslProc.output nothing happens.


So, what is your complete example?

I'd recommend that you have a look at the examples from the MSXML SDK and
try them, like this one:

<HTML>
<HEAD>
<TITLE>sample </TITLE>
<SCRIPT language = "javascript ">
function init()
{
var srcTree = new ActiveXObject(" Msxml2.DOMDocum ent.4.0");
srcTree.async=f alse;
srcTree.load("h ello.xml");

var xsltTree= new ActiveXObject(" Msxml2.DOMDOCUM ENT.4.0");
xsltTree.async = false;
xsltTree.load(" hello.xsl");

resTree.innerHT ML = srcTree.transfo rmNode(xsltTree );
}
</SCRIPT>
</HEAD>

<BODY onload = "init()" >
<div id="resTree"></div>
</BODY>

</HTML>You can incrementally add your code step by step, until you get your
application working.=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL


I tried what you gave for an example above and it worked fine. It is
when I try to start using the .addParameter() function. All I am
getting for an output now is the header from my .xslt page which is
more then I was getting before. Basically what I want to be outputted
for right now is everything I have for Sly Cooper from my xml file.

Here is my Javascript function
<script language="javas cript">
function CallXML()
{
var xsltTree = new ActiveXObject(" Msxml2.FreeThre adedDOMDocument .4.0");
xsltTree.async = false;
xsltTree.load(" Games.xslt")

var srcTree = new ActiveXObject(" Msxml2.DOMDocum ent.4.0");
srcTree.async = false;
srcTree.load("G ames.xml");

var xsltThread = new ActiveXObject(" Msxml2.XSLTempl ate.4.0");
xsltThread.styl esheet = xsltTree;
var xsltProc = xsltThread.crea teProcessor();
xsltProc.input = xsltTree;
xsltProc.addPar ameter("Title", "Sly Cooper");

resTree.innerHT ML = srcTree.transfo rmNode(xsltTree );
}
</script>

Here is my Games.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/DevelopmentWebs ite">
<xsl:output method="html"/>
<xsl:param name="Title"/>
<xsl:template match="/">

<h2>My Game Collection</h2>
<table border="1">
<xsl:for-each select="lc:Ente rtainment/lc:GameList[lc:Title =
$Title]">
<tr>
<th colspan="2"><xs l:value-of select="lc:Titl e"/></th>
</tr>
<tr>
<td>
<xsl:element name="IMG">
<xsl:attribut e name="SRC">
<xsl:value-of select="lc:Imag e"/>
</xsl:attribute>
</xsl:element>
</td>
<td><xsl:valu e-of select="lc:Desc ription"/></td>
</tr>
</xsl:for-each>
</table>

</xsl:template>
</xsl:stylesheet>

and here is what I have in the Games.xml file for Sly Cooper to show
you that I do have something in the xml file for Sly Cooper.
<?xml version="1.0" encoding="utf-8" ?>
<Entertainmen t xmlns="http://mark/DevelopmentWebs ite">
<GameList>
<ID>1</ID>
<Console>PS2</Console>
<Title>Sly Cooper</Title>
<Description> A witty game that is fun for everybody</Description>
<Image>images\S lyCooper.jpg</Image>
</GameList>
<GameList>
<ID>2</ID>
<Console>PS2</Console>
<Title>Ratche t and Clank</Title>
<Description>Fu n</Description>
</GameList>
</Entertainment>
Jul 20 '05 #5
This works perfectly for me -- I haven't changed your xslt code and probably
the reason for the problem is in your html:

1. Html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<script language="javas cript">
function CallXML()
{
var xsltTree = new ActiveXObject(" Msxml2.FreeThre adedDOMDocument .4.0");
xsltTree.async = false;
xsltTree.load(" Games.xslt")

var srcTree = new ActiveXObject(" Msxml2.DOMDocum ent.4.0");
srcTree.async = false;
srcTree.load("G ames.xml");

var xsltThread = new ActiveXObject(" Msxml2.XSLTempl ate.4.0");
xsltThread.styl esheet = xsltTree;
var xsltProc = xsltThread.crea teProcessor();
xsltProc.input = xsltTree;
xsltProc.addPar ameter("Title", "Sly Cooper");

resTree.innerHT ML = srcTree.transfo rmNode(xsltTree );
}
</script>
<title>Untitled </title>
</head>

<body onload="CallXML ()">
<div id="resTree"></div>

</body>
</html>

2. XSLT code (Games.xslt):

<?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/DevelopmentWebs ite">

<xsl:output method="html"/>
<xsl:param name="Title" select="'Sly Cooper'"/>

<xsl:template match="/">
<h2>My Game Collection</h2>
<table border="1">
<xsl:for-each
select="lc:Ente rtainment/lc:GameList
[lc:Title = $Title]">
<tr>
<th colspan="2">
<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:Imag e"/>
</xsl:attribute>
</xsl:element>
</td>
<td>
<xsl:value-of select="lc:Desc ription"/>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>

3. XML source (Games.xml):

<?xml version="1.0" encoding="utf-8" ?>
<Entertainmen t xmlns="http://mark/DevelopmentWebs ite">
<GameList>
<ID>1</ID>
<Console>PS2</Console>
<Title>Sly Cooper</Title>
<Description> A witty game that is fun for everybody</Description>
<Image>images\S lyCooper.jpg</Image>
</GameList>
<GameList>
<ID>2</ID>
<Console>PS2</Console>
<Title>Ratche t and Clank</Title>
<Description>Fu n</Description>
</GameList>
</Entertainment>

The wanted result is produced and displayed nicely in IE6:

<h2 xmlns:lc="http://mark/DevelopmentWebs ite">My Game Collection</h2>
<table xmlns:lc="http://mark/DevelopmentWebs ite" border="1">
<tr>
<th colspan="2">Sly Cooper</th>
</tr>
<tr>
<td><IMG SRC="images\Sly Cooper.jpg"></td>
<td>A witty game that is fun for everybody</td>
</tr>
</table>
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

"Mark Constant" <co*******@mi x-net.net> wrote in message
news:ce******** *************** ***@posting.goo gle.com...
"Dimitre Novatchev" <dn********@yah oo.com> wrote in message

news:<bp******* ******@ID-152440.news.uni-berlin.de>...
Even if I change the line xslProc.output; to Title.innerHTML =
xslProc.output nothing happens.


So, what is your complete example?

I'd recommend that you have a look at the examples from the MSXML SDK and try them, like this one:

<HTML>
<HEAD>
<TITLE>sample </TITLE>
<SCRIPT language = "javascript ">
function init()
{
var srcTree = new ActiveXObject(" Msxml2.DOMDocum ent.4.0");
srcTree.async=f alse;
srcTree.load("h ello.xml");

var xsltTree= new ActiveXObject(" Msxml2.DOMDOCUM ENT.4.0");
xsltTree.async = false;
xsltTree.load(" hello.xsl");

resTree.innerHT ML = srcTree.transfo rmNode(xsltTree );
}
</SCRIPT>
</HEAD>

<BODY onload = "init()" >
<div id="resTree"></div>
</BODY>

</HTML>You can incrementally add your code step by step, until you get your application working.=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL


I tried what you gave for an example above and it worked fine. It is
when I try to start using the .addParameter() function. All I am
getting for an output now is the header from my .xslt page which is
more then I was getting before. Basically what I want to be outputted
for right now is everything I have for Sly Cooper from my xml file.

Here is my Javascript function
<script language="javas cript">
function CallXML()
{
var xsltTree = new ActiveXObject(" Msxml2.FreeThre adedDOMDocument .4.0");
xsltTree.async = false;
xsltTree.load(" Games.xslt")

var srcTree = new ActiveXObject(" Msxml2.DOMDocum ent.4.0");
srcTree.async = false;
srcTree.load("G ames.xml");

var xsltThread = new ActiveXObject(" Msxml2.XSLTempl ate.4.0");
xsltThread.styl esheet = xsltTree;
var xsltProc = xsltThread.crea teProcessor();
xsltProc.input = xsltTree;
xsltProc.addPar ameter("Title", "Sly Cooper");

resTree.innerHT ML = srcTree.transfo rmNode(xsltTree );
}
</script>

Here is my Games.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/DevelopmentWebs ite">
<xsl:output method="html"/>
<xsl:param name="Title"/>
<xsl:template match="/">

<h2>My Game Collection</h2>
<table border="1">
<xsl:for-each select="lc:Ente rtainment/lc:GameList[lc:Title =
$Title]">
<tr>
<th colspan="2"><xs l:value-of select="lc:Titl e"/></th>
</tr>
<tr>
<td>
<xsl:element name="IMG">
<xsl:attribut e name="SRC">
<xsl:value-of select="lc:Imag e"/>
</xsl:attribute>
</xsl:element>
</td>
<td><xsl:valu e-of select="lc:Desc ription"/></td>
</tr>
</xsl:for-each>
</table>

</xsl:template>
</xsl:stylesheet>

and here is what I have in the Games.xml file for Sly Cooper to show
you that I do have something in the xml file for Sly Cooper.
<?xml version="1.0" encoding="utf-8" ?>
<Entertainmen t xmlns="http://mark/DevelopmentWebs ite">
<GameList>
<ID>1</ID>
<Console>PS2</Console>
<Title>Sly Cooper</Title>
<Description> A witty game that is fun for everybody</Description>
<Image>images\S lyCooper.jpg</Image>
</GameList>
<GameList>
<ID>2</ID>
<Console>PS2</Console>
<Title>Ratche t and Clank</Title>
<Description>Fu n</Description>
</GameList>
</Entertainment>

Jul 20 '05 #6
Oooppss...

The errors are in your script:
function CallXML()
{
var xsltTree = new ActiveXObject(" Msxml2.FreeThre adedDOMDocument .4.0");
xsltTree.async = false;
xsltTree.load(" Games.xslt")

var srcTree = new ActiveXObject(" Msxml2.DOMDocum ent.4.0");
srcTree.async = false;
srcTree.load("G ames.xml");

var xsltThread = new ActiveXObject(" Msxml2.XSLTempl ate.4.0");
xsltThread.styl esheet = xsltTree;
var xsltProc = xsltThread.crea teProcessor();
xsltProc.input = xsltTree;
Must be:

xsltProc.input = srcTree;

xsltProc.addPar ameter("Title", "Sly Cooper");

resTree.innerHT ML = srcTree.transfo rmNode(xsltTree );
Must be:

xsltProc.transf orm();
resTree.innerHT ML = xsltProc.output ;
}

The complete correct function is:

function CallXML()
{
var xsltTree = new ActiveXObject(" Msxml2.FreeThre adedDOMDocument .4.0");
xsltTree.async = false;
xsltTree.load(" Games.xslt")

var srcTree = new ActiveXObject(" Msxml2.DOMDocum ent.4.0");
srcTree.async = false;
srcTree.load("G ames.xml");

var xsltThread = new ActiveXObject(" Msxml2.XSLTempl ate.4.0");
xsltThread.styl esheet = xsltTree;
var xsltProc = xsltThread.crea teProcessor();
xsltProc.input = srcTree;
xsltProc.addPar ameter("Title", "Sly Cooper");

xsltProc.transf orm();
resTree.innerHT ML = xsltProc.output ;
}
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

"Dimitre Novatchev" <dn********@yah oo.com> wrote in message
news:bp******** *****@ID-152440.news.uni-berlin.de... This works perfectly for me -- I haven't changed your xslt code and probably the reason for the problem is in your html:

1. Html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<script language="javas cript">
function CallXML()
{
var xsltTree = new ActiveXObject(" Msxml2.FreeThre adedDOMDocument .4.0");
xsltTree.async = false;
xsltTree.load(" Games.xslt")

var srcTree = new ActiveXObject(" Msxml2.DOMDocum ent.4.0");
srcTree.async = false;
srcTree.load("G ames.xml");

var xsltThread = new ActiveXObject(" Msxml2.XSLTempl ate.4.0");
xsltThread.styl esheet = xsltTree;
var xsltProc = xsltThread.crea teProcessor();
xsltProc.input = xsltTree;
xsltProc.addPar ameter("Title", "Sly Cooper");

resTree.innerHT ML = srcTree.transfo rmNode(xsltTree );
}
</script>
<title>Untitled </title>
</head>

<body onload="CallXML ()">
<div id="resTree"></div>

</body>
</html>

2. XSLT code (Games.xslt):

<?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/DevelopmentWebs ite">

<xsl:output method="html"/>
<xsl:param name="Title" select="'Sly Cooper'"/>

<xsl:template match="/">
<h2>My Game Collection</h2>
<table border="1">
<xsl:for-each
select="lc:Ente rtainment/lc:GameList
[lc:Title = $Title]">
<tr>
<th colspan="2">
<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:Imag e"/>
</xsl:attribute>
</xsl:element>
</td>
<td>
<xsl:value-of select="lc:Desc ription"/>
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>

3. XML source (Games.xml):

<?xml version="1.0" encoding="utf-8" ?>
<Entertainmen t xmlns="http://mark/DevelopmentWebs ite">
<GameList>
<ID>1</ID>
<Console>PS2</Console>
<Title>Sly Cooper</Title>
<Description> A witty game that is fun for everybody</Description>
<Image>images\S lyCooper.jpg</Image>
</GameList>
<GameList>
<ID>2</ID>
<Console>PS2</Console>
<Title>Ratche t and Clank</Title>
<Description>Fu n</Description>
</GameList>
</Entertainment>

The wanted result is produced and displayed nicely in IE6:

<h2 xmlns:lc="http://mark/DevelopmentWebs ite">My Game Collection</h2>
<table xmlns:lc="http://mark/DevelopmentWebs ite" border="1">
<tr>
<th colspan="2">Sly Cooper</th>
</tr>
<tr>
<td><IMG SRC="images\Sly Cooper.jpg"></td>
<td>A witty game that is fun for everybody</td>
</tr>
</table>
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

"Mark Constant" <co*******@mi x-net.net> wrote in message
news:ce******** *************** ***@posting.goo gle.com...
"Dimitre Novatchev" <dn********@yah oo.com> wrote in message

news:<bp******* ******@ID-152440.news.uni-berlin.de>...
> Even if I change the line xslProc.output; to Title.innerHTML =
> xslProc.output nothing happens.

So, what is your complete example?

I'd recommend that you have a look at the examples from the MSXML SDK and try them, like this one:

<HTML>
<HEAD>
<TITLE>sample </TITLE>
<SCRIPT language = "javascript ">
function init()
{
var srcTree = new ActiveXObject(" Msxml2.DOMDocum ent.4.0");
srcTree.async=f alse;
srcTree.load("h ello.xml");

var xsltTree= new ActiveXObject(" Msxml2.DOMDOCUM ENT.4.0");
xsltTree.async = false;
xsltTree.load(" hello.xsl");

resTree.innerHT ML = srcTree.transfo rmNode(xsltTree );
}
</SCRIPT>
</HEAD>

<BODY onload = "init()" >
<div id="resTree"></div>
</BODY>

</HTML>You can incrementally add your code step by step, until you get your application working.=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL


I tried what you gave for an example above and it worked fine. It is
when I try to start using the .addParameter() function. All I am
getting for an output now is the header from my .xslt page which is
more then I was getting before. Basically what I want to be outputted
for right now is everything I have for Sly Cooper from my xml file.

Here is my Javascript function
<script language="javas cript">
function CallXML()
{
var xsltTree = new ActiveXObject(" Msxml2.FreeThre adedDOMDocument .4.0");
xsltTree.async = false;
xsltTree.load(" Games.xslt")

var srcTree = new ActiveXObject(" Msxml2.DOMDocum ent.4.0");
srcTree.async = false;
srcTree.load("G ames.xml");

var xsltThread = new ActiveXObject(" Msxml2.XSLTempl ate.4.0");
xsltThread.styl esheet = xsltTree;
var xsltProc = xsltThread.crea teProcessor();
xsltProc.input = xsltTree;
xsltProc.addPar ameter("Title", "Sly Cooper");

resTree.innerHT ML = srcTree.transfo rmNode(xsltTree );
}
</script>

Here is my Games.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/DevelopmentWebs ite">
<xsl:output method="html"/>
<xsl:param name="Title"/>
<xsl:template match="/">

<h2>My Game Collection</h2>
<table border="1">
<xsl:for-each select="lc:Ente rtainment/lc:GameList[lc:Title =
$Title]">
<tr>
<th colspan="2"><xs l:value-of select="lc:Titl e"/></th>
</tr>
<tr>
<td>
<xsl:element name="IMG">
<xsl:attribut e name="SRC">
<xsl:value-of select="lc:Imag e"/>
</xsl:attribute>
</xsl:element>
</td>
<td><xsl:valu e-of select="lc:Desc ription"/></td>
</tr>
</xsl:for-each>
</table>

</xsl:template>
</xsl:stylesheet>

and here is what I have in the Games.xml file for Sly Cooper to show
you that I do have something in the xml file for Sly Cooper.
<?xml version="1.0" encoding="utf-8" ?>
<Entertainmen t xmlns="http://mark/DevelopmentWebs ite">
<GameList>
<ID>1</ID>
<Console>PS2</Console>
<Title>Sly Cooper</Title>
<Description> A witty game that is fun for everybody</Description>
<Image>images\S lyCooper.jpg</Image>
</GameList>
<GameList>
<ID>2</ID>
<Console>PS2</Console>
<Title>Ratche t and Clank</Title>
<Description>Fu n</Description>
</GameList>
</Entertainment>


Jul 20 '05 #7
Well everything works now thank you. I just have one more question.
(Atleast I hope). I added an option in the select box called All that
will just display everything. <OPTION value="All">All Titles</OPTION>.
Now in the xslt code I added this condition.
<xsl:choose>
<xsl:when test="$Title = 'All'">
<xsl:for-each select="lc:Ente rtainment/lc:GameList">
</xsl:when>
<xsl:otherwis e>
<xsl:for-each select="lc:Ente rtainment/lc:GameList[lc:Title =
$Title]">
</xsl:otherwise>
</xsl:choose>

It is giving the error "The stylesheet does not contain a document
elment. The stylesheet may be empty, or it may not be a well-formed
XML document.
Jul 20 '05 #8
So what is your complete xslt code?

I hope that you'll learn to provide your code when asking about problems in
it.
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

"Mark Constant" <co*******@mi x-net.net> wrote in message
news:ce******** *************** ***@posting.goo gle.com...
Well everything works now thank you. I just have one more question.
(Atleast I hope). I added an option in the select box called All that
will just display everything. <OPTION value="All">All Titles</OPTION>.
Now in the xslt code I added this condition.
<xsl:choose>
<xsl:when test="$Title = 'All'">
<xsl:for-each select="lc:Ente rtainment/lc:GameList">
</xsl:when>
<xsl:otherwis e>
<xsl:for-each select="lc:Ente rtainment/lc:GameList[lc:Title =
$Title]">
</xsl:otherwise>
</xsl:choose>

It is giving the error "The stylesheet does not contain a document
elment. The stylesheet may be empty, or it may not be a well-formed
XML document.

Jul 20 '05 #9
"Dimitre Novatchev" <dn********@yah oo.com> wrote in message news:<bp******* ******@ID-152440.news.uni-berlin.de>...
So what is your complete xslt code?

I hope that you'll learn to provide your code when asking about problems in
it.
=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

"Mark Constant" <co*******@mi x-net.net> wrote in message
news:ce******** *************** ***@posting.goo gle.com...
Well everything works now thank you. I just have one more question.
(Atleast I hope). I added an option in the select box called All that
will just display everything. <OPTION value="All">All Titles</OPTION>.
Now in the xslt code I added this condition.
<xsl:choose>
<xsl:when test="$Title = 'All'">
<xsl:for-each select="lc:Ente rtainment/lc:GameList">
</xsl:when>
<xsl:otherwis e>
<xsl:for-each select="lc:Ente rtainment/lc:GameList[lc:Title =
$Title]">
</xsl:otherwise>
</xsl:choose>

It is giving the error "The stylesheet does not contain a document
elment. The stylesheet may be empty, or it may not be a well-formed
XML document.


I am sorry for not including all of my code. Like I said all I want is
if the user chooses All then it will display everything. If the user
chooses a Title then it only displays the title they want. I thought I
could do this by using a <xsl:choose> statement that looks first to
see if the selected value was All and if not it would call the
<xsl:otherwis e> statement and just display the title that the user
selected.

Games.xslt
<?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/DevelopmentWebs ite">
<xsl:output method="html"/>
<xsl:param name="Title"/>
<xsl:template match="/">

<h2>My Game Collection</h2>
<table border="0">
<xsl:choose>
<xsl:when test="$Title = 'All'">
<xsl:for-each select="lc:Ente rtainment/lc:GameList">
</xsl:when>
<xsl:otherwis e>
<xsl:for-each select="lc:Ente rtainment/lc:GameList[lc:Title =
$Title]">
</xsl:otherwise>
</xsl:choose>
<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:Imag e"/>
</xsl:attribute>
</xsl:element>
</td>
<td><xsl:valu e-of select="lc:Desc ription"/></td>
</tr>
</xsl:for-each>
</table>

</xsl:template>
</xsl:stylesheet>

Here is my Games.xml file
<?xml version="1.0" encoding="utf-8" ?>
<Entertainmen t xmlns="http://mark/DevelopmentWebs ite">
<GameList>
<ID>1</ID>
<Console>PS2</Console>
<Title>Sly Cooper</Title>
<Description> A witty game that is fun for everybody</Description>
<Image>images\S lyCooper.jpg</Image>
</GameList>
<GameList>
<ID>2</ID>
<Console>PS2</Console>
<Title>Ratche t and Clank</Title>
<Description>Fu n</Description>
</GameList>
</Entertainment>

And here is the Javascript function in my HTML
<script language="javas cript">
function CallXML(dropdow n)
{
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(" Games.xslt")

var srcTree = new ActiveXObject(" Msxml2.DOMDocum ent.4.0");
srcTree.async = false;
srcTree.load("G ames.xml");

var xsltThread = new ActiveXObject(" Msxml2.XSLTempl ate.4.0");
xsltThread.styl esheet = xsltTree;
var xsltProc = xsltThread.crea teProcessor();
xsltProc.input = srcTree;
xsltProc.addPar ameter("Title", SelValue);

xsltProc.transf orm();
resTree.innerHT ML = xsltProc.output ;
}
</script>
Jul 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
35083
by: Jim Geissman | last post by:
Take a table, where not all the columns are populated: CREATE TABLE #T (A int, B int, C int, D int) INSERT #T (A,B) VALUES (1,2) INSERT #T (A,B) VALUES (3,4) INSERT #T (A,B) VALUES (5,6) INSERT #T (A,B) VALUES (7,8) INSERT #T (A,B) VALUES (9,10) The values for C and D can be computed as functions of A and B. For this
5
8286
by: Paolo | last post by:
Friends, I have created a form with a list box that shows all my Word files. I have then added the following code (found on comp.databases newsgroup) to the Open event of my form and it works fine: Private Sub Form_Open(Cancel As Integer) Dim file As String Dim files As String files = ""
8
25233
by: Nick Li | last post by:
Hi, I am trying to writing a c program to send email using system() function call on Unix(Sun Solaris). I tried the following: #include <stdio.h> #include <stdio.h> int main(void) {
5
1729
by: AK | last post by:
I'm writing a Windows Forms application in C++.NET. I've defined function F which takes 2 arguments a & b. I need to use the pointer of F inside another function G & I can't figure out how to do it properly. Here's what I have : U32 (*pf) (HANDLE, LPVOID); //declaring the function pointer U32 __stdcall F (HANDLE a, LPVOID b) //defining F
1
6383
by: Muhammad Qasim Choudry via DotNetMonster.com | last post by:
I want to Use IRR Function in C#.Net but cant find it but when i open Vb.Net projetc under Microsoft.VisualBasic.Financial module i can find that function but i want to use it in in C# for that it tried adding up a reference of Micorost.VisualBasic.dll but cant find that in .Net Refernce Tab. if any one have an idea of using IRR function or Microsoft. VisualBasic.Financial module in C# please make a quick reply
12
2282
by: Angel Tsankov | last post by:
I'm thinking about using a function tamplate to verify that an identifier is of an array type. May the following template be used for this purpose: template< typename T, int N > void check_array( T(&) ) { } And what about using size_t instead of int?
13
2236
by: arnuld | last post by:
this does not work, i know there is some problem in the "for loop" of "print_arr" function. i am not able to correct the weired results i am getting. i have no compile time error, it is only semantic-bug that is causing the trouble: EXPECTED: january, february, march....december GOT: january, january, january.........january ------------- PROGRAMME -------------- /* Stroustrup, 5.9, exercise 10
1
13692
by: santhoskumara | last post by:
I am using Internet Explorer browser, I want to know how to clear cache and cookies using javascript function or java, when each time the page is loaded. i know to do manually in IE using TOOLS option in IE. but i want to know using javascript function. urgent please can anyone advice me. with regards A.santhosh kumar
2
2866
myusernotyours
by: myusernotyours | last post by:
Hello everyone. I am using a C library from C++ code. The C library declares some function pointers using typedef, and then makes some variables using this function pointer as the type. Like: typedef void (*func) (int); //then the pointer... func ptr; For me to work with this library I need to assign one of my member functions to the library variable(the func pointer) above.
0
9632
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9471
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10136
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10071
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8958
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5501
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4036
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2867
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.