Main Page

XML document

var oProcessor = new XSLTProcessor()
oProcessor.setParameter(null, “message”, “Hello World!”);
var oResultDom = oProcessor.transformToDocument(oXmlDom);
Two other methods are related to parameters,
, which are
used to get the current value of a parameter and remove the parameter value, respectively. Each method
takes the namespace URI (once again, typically
) and the local name of the parameter:
var oProcessor = new XSLTProcessor()
oProcessor.setParameter(null, “message”, “Hello World! “);
alert(oProcessor.getParameter(null, “message”); //outputs “Hello World!”
oProcessor.removeParameter(null, “message”);
var oResultDom = oProcessor.transformToDocument(oXmlDom);
These methods aren’t used often and are provided mostly for convenience.
This chapter introduced you to the client-side XML capabilities of Internet Explorer and Mozilla. The
first topic covered was the use of an XML DOM model on the client side using the MSXML library in IE
and a native, DOM-compliant interface in Mozilla. You learned the differences between the two models,
as well as a way to bridge that gap to make your code more straightforward.
Next, you learned about each browser ’s support for XPath, a language designed to locate specific parts
of an XML document. This section included discussion on the different implementations in IE and
Mozilla. You learned that IE chose a non-standard API, whereas Mozilla chose to follow the DOM Level
3 XPath specification. Again, methods of creating a standard cross-browser approach were discussed.
The last topic discussed was the concept of JavaScript XML manipulation and transformation using
XSLT. You learned about the two ways to accomplish XSLT transformations using JavaScript in IE,
through the
method and the
object. You also learned about Mozilla’s
object and how it compares to IE’s implementation. Using
, you
learned how to create a
method for use in Mozilla.
Remember, the material covered in this chapter only works in Internet Explorer and Mozilla because
other browsers have not yet implemented any JavaScript support for XML, XPath, and XSLT.
XML in JavaScript
18_579088 ch15.qxd 3/28/05 11:42 AM Page 479

JavaScript EditorFree JavaScript Editor     Ajax Editor