Name
<xsl:processing-instruction> — Creates a processing instruction in the output document.
Category
Instruction
Required Attributes
- name
Defines the name of this processing instruction.
Optional Attributes
None.
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
XSLT section 7.3, 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 template.xsl with this XML document. Here is our stylesheet:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<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>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 stylesheet with this XML document:
<?xml version="1.0"?> <list> <title>A few of my favorite albums</title> <listitem>A Love Supreme</listitem> <listitem>Beat Crazy</listitem> <listitem>Here Come the Warm Jets</listitem> <listitem>Kind of Blue</listitem> <listitem>London Calling</listitem> <listitem>Remain in Light</listitem> <listitem>The Joshua Tree</listitem> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access