Processing Instruction

A Processing Instruction (PI) is an 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 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 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"?>

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 uses processing instructions.[8]

gollark: Hmm, 6 million actually.
gollark: (* in the styropyro server, excluding what I am sure is a lot of weird disused hidden ones)
gollark: You could even run 50 copies of yourself in parallel and monitor all channels ever!
gollark: There are about 18 million in my local copy.
gollark: Solution: upload your brain into a computer and monitor <#452775413509259265> eternally.

References

  1. Chapter 9. Customization methods: Processing instructions
  2. Comparison of SGML and XML; World Wide Web Consortium Note, 15 December 1997
  3. Bryan, Martin (1997). SGML and HTML Explained. Addison Wesley Longman. ISBN 0-201-40394-3. Retrieved 2010-08-18.
  4. Hossein Bidgoli (2004). The Internet encyclopedia, Volume 3. John Wiley and Sons. p. 877. ISBN 0-471-22203-8.
  5. Elliotte Rusty Harold, W. Scott Means. XML in a nutshell. p. 23. ISBN 978-0-596-00764-5.
  6. http://www.w3.org/TR/xml-stylesheet/
  7. http://docbook.sourceforge.net/release/xsl/current/doc/pi/pi-fo.html
  8. "Archived copy". Archived from the original on 2010-09-21. Retrieved 2010-08-18.CS1 maint: archived copy as title (link)
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.