Main Page

XML document

var oProcessor = new XSLTProcessor()
oProcessor.importStylesheet(oXslDom);
oProcessor.setParameter(null, “message”, “Hello World!”);
var oResultDom = oProcessor.transformToDocument(oXmlDom);
Two other methods are related to parameters,
getParameter()
and
removeParameter()
, 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
null
) and the local name of the parameter:
var oProcessor = new XSLTProcessor()
oProcessor.importStylesheet(oXslDom);
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.
Summary
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
transformNode()
method and the
XSLProcessor
object. You also learned about Mozilla’s
XSLTProcessor
object and how it compares to IE’s implementation. Using
XSLTProcessor
, you
learned how to create a
transformNode()
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.
479
XML in JavaScript
18_579088 ch15.qxd 3/28/05 11:42 AM Page 479


JavaScript EditorFree JavaScript Editor     Ajax Editor


©