Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

XML XSLT parameters Javascript - how to make it work in Mozilla...

Avatar of yellow1234
yellow1234 asked on
13 Comments1 Solution4855 ViewsLast Modified:
Yes - I ve seen similair questions before and I searched the web but I cannot get it to work in Mozilla -  (works fine in IE with the ActiveXObjects). What I like to achieve is a much more complicated then this - but I ve seen to many times pages and pages of code where a basic example would have done OK... so I narrowed down the code to this:
The basic idea is that through Javascript you set a variable in the xsl document, the xml and xsl is loaded again and the hml document shows the data according to the parameter. I quess my question is what's the ActiveX equivalent in Mozilla and how do i set a parameter then?  Thanks everybody - 3 files below - copy and paste it and you'll see works OK in IE

1. The XML file (four books - Author, Title and Price): books.xml
<?xml version='1.0' encoding='ISO-8859-1'?>
<Title>On holiday in Turkey</Title>
<Author>O Arslan</Author>
<Title>South Coast of Turkey</Title>
<Author>Peter Jones</Author>
<Title>Istanbul and the West Coast</Title>
<Author>John Apple</Author>
<Title>The Turkish Black Sea Coast</Title>
<Author>John Deniz</Author>

2.  The XSL file, to display the items sorted by price: sort.xsl
Note the parameter at the top for sorting
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="sortOrder" select="'ascending'" />
<xsl:template match="/">
      <xsl:for-each select="Catalog/Book">
                <xsl:sort select="Price" data-type="number" order="{$sortOrder}"/>
            <xsl:call-template name="ShowBooks" />

<xsl:template name="ShowBooks">
      <xsl:value-of select="Author"/> /
      <xsl:value-of select="Title"/>  / USD
      <xsl:value-of select="Price"/>  <br />


3. The HTML file including Javascript. The Javascript
loads the XML and XSL and displays it in a <div>
When changing the select, the Javascript runs again, assigning a value
to the parameter in the xsl file:

<script language="javascript">

function sortlist(myvalue)   {

    var xslt = new ActiveXObject("Msxml2.XSLTemplate");
    var xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
    var xslProc;
    xslDoc.async = false;
    xslDoc.resolveExternals = false;
    xslt.stylesheet = xslDoc;
    var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
    xmlDoc.async = false;
    xmlDoc.resolveExternals = false;
    xslProc = xslt.createProcessor();
    xslProc.input = xmlDoc;

    xslProc.addParameter("sortOrder", myvalue);

    var str;
    str = xslProc.output;


<body  onLoad="sortlist('ascending')">

<form name='ascdesc'>
Sort price
<select  name ='SortOrder'
      <option value='ascending' selected>Ascending</option>
      <option value='descending'>Descending</option>

<div id='books'></div>



Avatar of sybe

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 13 Comments.
See Answers