Supported Platforms
processing-instruction
Syntax
processing-instruction instruction-name;
processing-instruction instruction-name { instruction-value; }
Release Information
Statement introduced in version 1.1 of the SLAX language, which is supported in Junos OS Release 12.2 and later releases.
Description
Add an XML processing instruction to the result tree. A processing instruction is a mechanism to convey application-specific information inside an XML document. The application can detect processing instructions and change their behavior accordingly. The instruction name is mandatory and becomes the target of the processing instruction. It can be a hard-coded string, a variable, or an XPath expression. The optional body generates the processing instruction’s content, which consists of one or more name-value pairs. The generated instruction is enclosed within the tags <? and ?>.
Junos OS SLAX scripts generally do not require the processing-instruction statement, because the result tree is processed directly by Junos OS. However, you might add a processing instruction to an XML document that is written to disk through the <xsl:document> instruction element or one of its related extension elements.
Attributes
instruction-name | — | Identifier for the processing instruction, which can be a string, a variable, or an XPath expression. |
instruction-value | — | Instruction content, which consists of name-value pairs. |
SLAX Example
The following code creates the processing instruction xml-stylesheet. The instruction content contains two name-value pairs: type and href.
processing-instruction "xml-stylesheet" { expr 'type="text/css" '; expr 'href="style.css"'; }
The corresponding output in the result tree is:
<?xml-stylesheet type="text/css" href="style.css"?>
The following example writes an XML document to the file /var/tmp/output.xml
using the <xsl:document> instruction element. The script adds a processing instruction named instruction to the document.
version 1.1; match / { <op-script-results> { <xsl:document href="/var/tmp/output.xml" indent="yes" method="xml"> { <document-element> { <element>; processing-instruction "instruction" { expr 'name="testing"'; } <element>; } } } }
The script generates the file /var/tmp/output.xml
, which contains the processing instruction enclosed within <? and ?> tags.
<?xml version="1.0"?> <document-element> <element/> <?instruction name="testing"?> <element/> </document-element>