OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   RE: [xml-dev] Problem passing parameter to XSL thru JSP

[ Lists Home | Date Index | Thread Index ]

  Thanks Andrew.. It worked.... Thanks a lot....


yogini...

--- Andrew Welch <andrew@thebristoldirectory.com>
wrote:
>   
> Hi,
> 
> Try this code instead:
> 
>   var xml = new
> ActiveXObject("MSXML2.DomDocument.3.0");
>   xml.async = false;
>   xml.load("cd_catalog.xml");
> 
>   var xsl = new
> ActiveXObject("MSXML2.FreeThreadedDomDocument.3.0");
> 
>   xsl.async = false;
>   xsl.load("cd_catalog_filter.xsl");
> 
>   var template = new
> ActiveXObject("MSXML2.XSLTemplate")
>   template.stylesheet = xsl
>   processor = template.createProcessor()
> 
>   processor.input = xml
> 
>   var art="bonnie";
> 
>   processor.addParameter("art", art)
>     
>   processor.transform()
> 
>   document.open()
>   document.write(processor.output)
>   document.close()
> 
> 
> Some points:
> 
> -look at addParameter and processor.output for the
> differences
> -This uses msxml3, if you dont have it use your
> progid's instead
> -JSP means Java Server Pages and not Javascript
> (very different things!)
> 
> cheers
> 
> andrew
> 
> ===
> 
> 
> -----Original Message-----
> From: bv java [mailto:bvcons@yahoo.com]
> Sent: Wednesday, January 16, 2002 2:51 PM
> To: xml-dev@lists.xml.org
> Subject: [xml-dev] Problem passing parameter to XSL
> thru JSP
> 
> 
> 
> Hi,
>    I am facing problem in passing parameter to XSL
> thru javascript.. Please have a look at the
> following
> code and let me know if there is anything wrong in
> it...
> 
> XSL code:
> 
> 
> <?xml version="1.0"?>
>   <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
>           
> 
> <xsl:param name="art" select="Bonnie"></xsl:param> 
>       <xsl:template name="testp" match="/">
>         
>       
>         <html>
>           <body>
>             <table border="2" bgcolor="yellow">
>             <tr>
>               <th>Title</th>
>               <th>Artist</th>
>             </tr>
>             
>             <xsl:for-each
> select="CATALOG/CD[ARTIST=$art]">
>             <tr>
>               <td><xsl:value-of
> select="TITLE"/></td>
>               <td><xsl:value-of
> select="ARTIST"/></td>
>             </tr>
>             </xsl:for-each>
>             </table>
>           </body>
>         </html>
> 
>      </xsl:template>
> 
>     
>        
>  
> </xsl:stylesheet>
> 
>
*******************************************************
> 
> 
> javascript code:
> 
> <html>
>   <body>
>      <script language=javascript>
> // Load XML 
> 	var xml = new
> ActiveXObject("MSXML2.FreeThreadedDOMDocument")
> 	    xml.async = false
> 	    xml.load("cd_catalog.xml")
> 
> // Load the XSL
> 	var xsl = new
> ActiveXObject("MSXML2.FreeThreadedDOMDocument")
> 	    xsl.async = false
> 	    xsl.load("cd_catalog_filter.xsl")
> 
> 
> 	var xout = new
> ActiveXObject("MSXML2.FreeThreadedDOMDocument")
> 
> 
>         var myTemplate = new
> ActiveXObject("MSXML2.XSLTemplate")
>             myTemplate.stylesheet = xsl
> 	var art="bonnie";
> 	var myProc = myTemplate.createProcessor();
> 	    myProc.input = xml
>         myProc.output = xout
> 
>         myProc.setParameter ("art","Bonnie");
>              myProc.transform()  
> 
> 
> 
> 
> // Transform
> document.write(xml.transformNode(xsl))
> </script>
> 
> </body>
> </html>
> 
>
*******************************************************
> 
> Please let me know if there is any other way of
> doing
> it.. 
> 
> THanks
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Send FREE video emails in Yahoo! Mail!
> http://promo.yahoo.com/videomail/
> 
>
-----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org
> <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
> 
> The list archives are at
> http://lists.xml.org/archives/xml-dev/
> 
> To subscribe or unsubscribe from this list use the
> subscription
> manager: <http://lists.xml.org/ob/adm.pl>
> 
> 


__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS