![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: SetParameter in XSL [Thread Next] Re: SetParameter in XSLTo: NULL Date: 2/5/2007 1:09:00 PM
On Feb 5, 2:13 pm, "ignignokt" <davis...@gmail.com> wrote:
> On Feb 5, 1:34 pm, Martin Honnen <mahotr...@yahoo.de> wrote:
>
>
>
>
>
> > ignignokt wrote:
> > > I have a question. After I set up the parameter and pass it to the
> > > xsl file, nothing seems to show up. How do I display the results in
> > > the html page?
>
> > Assuming you run the script in a HTML document you need to set the
> > parameter, call the transform method of the processor and assign the
> > output to the innerHTML of some HTML element e.g.
> > xslproc = xslt.createProcessor();
> > xslproc.input = xmldoc;
> > xslproc.addParameter("param1", "Hello");
> > xslproc.transform();
> > document.getElementById('someDiv').innerHTML = xslproc.output;
>
> > --
>
> > Martin Honnen --- MVP XML
> > http://JavaScript.FAQTs.com/
>
> Ive done that and still nothing:
>
> HTML:
> <html>
> <script type="text/javascript">
> function Request(key)
> {
> var strQueryString=QueryString();
> strQueryString=strQueryString.replace(/\%20/g," ");
> if (strQueryString.length < 1)
> return "";
>
> arrTmp=strQueryString.split("&");
> for (var i=0; i<arrTmp.length; i++)
> {
> var arrTmp2=arrTmp[i].split("=");
> if (arrTmp2.length < 1)
> continue;
> var curKey=arrTmp2[0];
> var curValue=(arrTmp2.length < 2)?"":arrTmp2[1];
> if (curKey.toLowerCase() == key.toLowerCase())
> return curValue;
> }
> return "";
> }
>
> function QueryString()
> {
> var strFullUrl=document.location+"";
> var arrTmp=strFullUrl.split("?");
> if (arrTmp.length < 2)
> return "";
> return arrTmp[1];
> }
>
> var xslt = new ActiveXObject("Msxml2.XSLTemplate");
> var xsldoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
> var xslproc;
> xsldoc.async = false;
> xsldoc.load("c:\videocatalog\config\vid.xsl");
>
> if (xsldoc.parseError.errorCode != 0)
> {
> var myErr = xsldoc.parseError;
> WScript.Echo("You have error " + myErr.reason);
> }
>
> else
> {
> xslt.stylesheet = xsldoc;
> var xmldoc = new ActiveXObject("Msxml2.DOMDocument");
> xmldoc.async = false;
> xmldoc.load("c:\videocatalog\config\vid.xml");
>
> if (xmldoc.parseError.errorCode != 0)
> {
> var myErr = xmldoc.parseError;
> WScript.Echo("You have error " + myErr.reason);
> }
> else
> {
> xslproc = xslt.createProcessor();
> xslproc.input = xmldoc;
> xslproc.addParameter("choice", Request("disc"));
> xslproc.transform();
> document.getElementByID('someDiv').innerHTML= xslproc.output;
> }
> }
>
> </script>
>
> <body>
>
> <div id="someDiv"></div>
>
> </body>
> </html>
>
> XSL:
> <?xml version='1.0' encoding='ISO-8859-1'?>
> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
> Transform">
> <xsl:output method="html"/>
> <xsl:param name="choice" />
> <xsl:template match="/">
>
> <html>
> <body>
> <h2>
> <font face="Arial" size="6">Video Catalog v1.0</font>
> </h2>
> <xsl:for-each select="catalog/disc[label=$choice]">
> <table width="100%" border="1">
> <tbody>
> <tr bgColor="#0033ff">
> <td width="100%">
> <font face="Arial" size="5">
> <font color="#ffffff"><strong>Disc - </strong>
> <strong><xsl:value-of select="file/label"/></strong>
> </font>
> </font>
> </td>
> </tr>
> </tbody>
> </table>
>
> <xsl:for-each select="file">
> <table width="100%" border="1"><tbody>
> <tr bgColor="#00ccff">
> <td><p align="center">
> <font face="Arial" size="4">
> <strong>Filename</strong>
> </font>
> </p>
> </td>
> <td>
> <p align="center">
> <font face="Arial" size="4">
> <strong>Size</strong>
> </font>
> </p>
> </td>
>
> <td>
> <p align="center">
> <font face="Arial" size="4">
> <strong>Date Created</strong>
> </font>
> </p>
> </td>
> </tr>
>
> <tr>
> <td>
> <p align="center">
> <font face="Arial">
> <xsl:value-of select="name"/>
> </font>
> </p>
> </td>
> <td>
> <p align="center">
> <font face="Arial">
> <xsl:value-of select="size"/>
> </font>
> </p>
> </td>
> <td>
> <p align="center">
> <font face="Arial">
> <xsl:value-of select="created"/>
> </font>
> </p>
> </td>
> </tr>
>
> <tr>
> <td><img src="{image01}"/></td>
> <td><img src="{image02}"/></td>
> <td><img src="{image03}"/></td>
> <td><img src="{image04}"/></td>
> <td><img src="{image05}"/></td>
> <td><img src="{image06}"/></td>
> </tr>
> </tbody>
> </table>
> </xsl:for-each>
> </xsl:for-each>
>
> </body>
> </html>
> </xsl:template>
> </xsl:stylesheet>- Hide quoted text -
>
> - Show quoted text -
I have resolved this issue:
var test = xslproc.output;
document.write(test)
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
