Share via


Linking to an XSLT File

 

There are two ways to link an XSLT style sheet to an XML source document:

  • Embed the style sheet in the source document using the <?xml-stylesheet type="text/xsl" href="myxsl.xsl"?> processing instruction.

  • Use a script or a COM-enabled programming language to load the XML and XSLT files into DOM. Call the transformNode method to apply the transformation.

From a performance standpoint, it does not matter whether you link using a style sheet processing instruction or using the DOM. The difference between these two methods focuses on the underlying data, as outlined in the following table.

Link Using... If...
A style sheet processing instruction - The data is fairly static (changes little, if at all).
- There is no need for dynamic transformations which include the passing of parameters.
The DOM - The data is dynamic.
- You want to dynamically evaluate the data by passing parameters or performing dynamic transformations.
- You want a more modular approach that is easier to maintain.

Note

For ease in learning XSLT, many of the samples in this section use a style sheet processing instruction to link to the XSLT file. These samples would work just as well if you linked them using the DOM instead.

See Also

Linking Using a Processing Instruction
Linking Using the DOM
Displaying Transformation Results