devxlogo

Apply an XSL Filter to an XML Document

Apply an XSL Filter to an XML Document

Question:
I copied an XML document and an XSL document out of my XML for Dummies book. It said that to make the XSL document affect the XML document, I had to use a script and the object tag in HTML, and I had to get something from a CAB file from the Microsoft server. When I viewed the page it said “undefined.” How can I apply an XSL document to an XML one?

Answer:

There are a couple of different ways that you can “apply” an XSL document to an XML one, depending upon what you are trying to do. If you simply want the XML document to always use the XSL filter as a style sheet (somewhat analogous to CSS), then you can simply place a header for the XSL document as a namespace link:

However, one of the benefits for using XSL style sheets as independent entities is that you can apply different style sheets, depending upon the desired output. Using the MSXML DOM, you can accomplish this through the transformNode() function. In an IE5 Web page, you could output this as follows:

You should never explicitly need a CAB file when working with IE5 for the XML capabilities, as those files are already implicitly available in the IE5 download.

See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist