Jump to content

Processing Instruction

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by HRoestBot (talk | contribs) at 19:12, 21 November 2010 (robot Adding: de:Verarbeitungsanweisung). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

A Processing Instruction (PI) is a SGML and XML node type, which may occur anywhere in the document, intended to carry instructions to the application.[1][2]

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 with '<? and '>'.[3]

A XML processing instruction is enclosed within '<?' and '?>', and contains a "target" and optionally some content, which is the node value, that can not contain the sequence '?>'.[4]

<?PITarget PIContent?>

The XML Declaration at the beginning of an XML document (shown below) is not a processing instruction, however its similar syntax has often resulted in it being referred to as a processing instruction.[5]

<?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 stylesheet using the 'xml-stylesheet' target, which was standardized in 1999.[6] It can be used for both XSLT and CSS stylesheets.

<?xml-stylesheet type="text/xsl" href="style.xsl"?>
<?xml-stylesheet type="text/css" href="style.css"?>

Another use is the PHP programming language, which can be embedded within an HTML document as shown in the following example.[5]

<?php echo $a; ?>

The DocBook XSLT stylesheets understand a number of processing instructions to override the default behaviour.[7]

A draft specification for Robots exclusion standard rules inside XML documents.[8]

References

  1. ^ [1]
  2. ^ [2]
  3. ^ [3]
  4. ^ Hossein Bidgoli (2004). The Internet encyclopedia, Volume 3. John Wiley and Sons. p. 877. ISBN 0471222038.
  5. ^ a b Elliotte Rusty Harold, W. Scott Means. XML in a nutshell. p. 23.
  6. ^ [4]
  7. ^ [5]
  8. ^ [6]