|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: setParameter method in Netscape
Why don't you use Sarissa that has a cross-browser Javascript library,
it's free as in beer, and open-source too?
http://sarissa.sourceforge.net
On Fri, 18 Mar 2005 08:29:57 -0500, Maria Amuchastegui
<mamuchastegui@xxxxxxxxxxx> wrote:
> Now I am trying to duplicate the same functionality in Netscape, i.e. use
> the setParameter method to pass a parameter to a stylesheet. The parameter
> seems to be getting passed but the data is not sorting. I read "The
> XSLT/JavaScript Interface in Gecko" but the code does not seem to work. Any
> suggestions on how to get it to work?
>
> Here is the HTML/XML:
>
> <html>
> <head>
> <script language="JavaScript">
> function sortXML(column,order)
> {
> var xslStylesheet;
> var xsltProcessor = new XSLTProcessor();
> var myDOM;
> var xmlDoc;
>
> // load the xslt file
> var myXMLHTTPRequest = new XMLHttpRequest();
> myXMLHTTPRequest.open("GET", "Sort.xsl", false);
> myXMLHTTPRequest.send(null);
> xslStylesheet = myXMLHTTPRequest.responseXML;
> xsltProcessor.importStylesheet(xslStylesheet);
>
> // create a new XML document in memory
> var xmlDoc = document.implementation.createDocument("", "",
> null);
> var myNode = document.getElementById('ChargeableMessages');
> var clonedNode =
> xmlDoc.importNode(myNode.childNodes.item(1), true);
> xmlDoc.appendChild(clonedNode);
>
> // set the parameter using the parameter passed to the
> outputgroup function
> xsltProcessor.setParameter(null, "sortKey", column);
> xsltProcessor.setParameter(null, "sortOrder", order);;
> var fragment =
> xsltProcessor.transformToFragment(xmlDoc,document);
> document.getElementById("container").innerHTML = "";
> myDOM = fragment;
> document.getElementById("container").appendChild(fragment);
> }
>
> </script>
> </head>
>
> <body onload="sortXML('id','descending');">
>
> <div id="container"></div>
>
> <xml id="ChargeableMessages" style="display:none;">
> <chargeablemessages>
> <message>
> <id>1-01</id>
> <date>2005-04-23</date>
> <location>Quebec QC</location>
> <number>418 683 1234</number>
> <duration>1</duration>
> <charges>0.43</charges>
> <savings>.043</savings>
> <amount/>
> </message>
> <message>
> <id>1-02</id>
> <date>2005-04-28</date>
> <location>Montreal QC</location>
> <number>514 485 6611</number>
> <duration>2</duration>
> <charges>3.44</charges>
> <savings/>
> <amount/>
> </message>
> <message>
> <id>1-03</id>
> <date>2005-05-01</date>
> <location>Winnipeg MB</location>
> <number>204 475 4565</number>
> <duration>22</duration>
> <charges>0.55</charges>
> <savings/>
> <amount/>
> </message>
> </chargeablemessages>
> </xml>
> </body>
> </html>
>
> And here is the stylesheet:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> <xsl:output method="html"/>
> <xsl:param name="sortKey"/>
> <xsl:param name="sortOrder"/>
> <xsl:template match="/">
> <xsl:apply-templates select="chargeablemessages"/>
> </xsl:template>
> <xsl:template match="chargeablemessages">
> <h3>Long distance calls - Click on any column heading to
> sort</h3>
> <table border="1">
> <tbody>
> <tr>
> <th><a href="#"
> onclick="sortXML('id','ascending');">ID</a></th>
> <th><a href="#"
> onclick="sortXML('date','ascending');">Date</a></th>
> <th><a href="#"
> onclick="sortXML('location','ascending');">Location</a></th>
> <th><a href="#"
> onclick="sortXML('number','ascending');">Number</a></th>
> <th><a href="#"
> onclick="sortXML('duration','ascending');">Duration</a></th>
> <th><a href="#"
> onclick="sortXML('charges','ascending');">Charges</a></th>
> </tr>
> <xsl:apply-templates select="//message">
> <xsl:sort select="*[name() =
> $sortKey]" order="{$sortOrder}"/>
> </xsl:apply-templates>
> </tbody>
> </table>
> </xsl:template>
> <xsl:template match="//message">
> <tr>
> <td><xsl:value-of select="id"/></td>
> <td><xsl:value-of select="date"/></td>
> <td><xsl:value-of select="location"/></td>
> <td><xsl:value-of select="number"/></td>
> <td><xsl:value-of select="duration"/></td>
> <td><xsl:value-of select="charges"/></td>
> </tr>
> </xsl:template>
> </xsl:stylesheet>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








