Name
<xsl:processing-instruction>
Creates a processing instruction in the output document.
Category
Instruction.
Required Attribute
name
Defines the name (also known as the target) of this processing instruction.
Optional Attribute
- [2.0]
select
Defines an expression that creates the data for the processing instruction. If the
select
attribute is used, the<xsl:processing-instruction>
must be empty.
Content
An XSLT template. The contents of the template become the data of the processing instruction.
Appears in
<xsl:processing-instruction>
appears
inside a template.
Defined in
[1.0] XSLT section 7.3, “Creating Processing Instructions.”
[2.0] XSLT section 11.6, “Creating Processing Instructions.”
Example
We’ll demonstrate a stylesheet that adds a processing instruction to an XML document. The processing instruction will associate the stylesheet docbook.xsl with this XML document. Here is our stylesheet:
<?xml version="1.0"?> <!-- processing-instruction.xsl --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml"/> <xsl:template match="/"> <xsl:processing-instruction name="xml-stylesheet">href="docbook/ html/docbook.xsl" type="text/xsl"</xsl:processing-instruction> <xsl:copy-of select="."/> </xsl:template> </xsl:stylesheet>
(The <xsl:processing-instruction>
element
should all be on one line.) This stylesheet simply uses the <xsl:copy-of>
element to copy the input document to the result tree, adding a processing instruction along the way. We’ll use our ...
Get XSLT, 2nd Edition 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.