Processing Instruction
A processing instruction (PI) is an
Processing instructions are exposed in the Document Object Model as Node.PROCESSING_INSTRUCTION_NODE
, and they can be used in XPath and XQuery with the 'processing-instruction()' command.
Syntax
An SGML processing instruction is enclosed within <?
and >
.[3]
An XML processing instruction is enclosed within <?
and ?>
, and contains a target and optionally some content, which is the node value, that cannot contain the sequence ?>
.[4]
<?PITarget PIContent?>
The XML Declaration at the beginning of an XML document (shown below) is another example of a processing instruction,[5] however it may not technically be considered one.[6]
<?xml version="1.0" encoding="UTF-8" ?>
Examples
The most common use of a processing instruction is to request the XML document be rendered using a
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
<?xml-stylesheet type="text/css" href="style.css"?>
The DocBook XSLT stylesheets understand a number of processing instructions to override the default behaviour.[8]
A draft specification for
References
- ISBN 978-0974152134.
- ^ Comparison of SGML and XML; World Wide Web Consortium Note, 15 December 1997
- ISBN 0-201-40394-3. Retrieved 2010-08-18.
- ISBN 0-471-22203-8.
- ^ "XML 1.0 - slide "Processing Instructions (PIs)"". www.w3.org. Retrieved 2023-02-08.
- ISBN 978-0-596-00764-5.
- ^ "Associating Style Sheets with XML documents 1.0 (Second Edition)".
- ^ "Part 2. FO Processing Instruction Reference".
- ^ "Robots Processing Instruction Homepage". Archived from the original on 2010-09-21. Retrieved 2010-08-18.