XSLT » Elements » xsl:processing-instruction

Syntax:
<xsl:processing-instruction
  name="process-name"
>
</xsl:processing-instruction>

The xsl:processing-instruction element writes (generates) a processing instruction to the output. The content of this element becomes the text of the processing instruction. The syntax is:

<xsl:processing-instruction name="pi_name">
   processing instruction text goes here ...
</xsl:processing-instruction>

 
This text should not contain any character references. In other words, all characters must be directly represented by the selected character encoding (i.e., an < cannot be represented by an &lt;).
 
This is not a self-closing element. The separate closing element is mandatory.
 

Examples

Code:
<xsl:processing-instruction name="xml-stylesheet">
  type="text/xsl" href="style_rules.css" title="Large Print"
</xsl:processing-instruction>
Output:
<?xml-stylesheet href="style_rules.css" type="text/css" title="Large Print"?>
Explanation:

Processing instructions are rarely used in XML. However, the W3C standard permits the application of a CSS (Cascading Style Sheet) file to an XML document. This is accomplished with an <?xml_stylesheet ... ?> processing instruction which is directly compariable to the HTML <link type="text/css" href="style.css> tag. This code fragment demonstrates how to do this.

For additional information see: http://www.w3.org/TR/xml-stylesheet

Language(s): XSLT

See Also: