[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Problem passing parameter to XSL thru JSP


activexobject in jsp
  
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@y...]
Sent: Wednesday, January 16, 2002 2:51 PM
To: xml-dev@l...
Subject:  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>



PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.