Applying Style Sheets Dynamically
Inserting an <?xml-stylesheet> directive in an XML document is not the only way to associate a style sheet with that document. As you’ll see in Chapters 9, 10, and 11, you can also use programming techniques to attach the style sheet on the fly. The basic technique is to use the Document Object Model’s transformNode() method. The method takes the name of a style sheet as a parameter and assigns it to the document object you’ve specified.
As an example, you could take the XML document in Listing 2.1, remove the <?xml-stylesheet> directive, and place the document on a Web server. You would also place the XSLT style sheet containing the HTML transformation in the same directory on the server. Then, you could use ...
Get Special Edition Using XSLT now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.