Processing Instruction: Difference between revisions

Content deleted Content added
HRoestBot (talk | contribs)
m Bare URLs: 3 changed to inline references.
Line 1:
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.<ref>[http://www.sagehill.net/docbookxsl/ProcessingInstructions.html Chapter 9. Customization methods: Processing instructions]</ref><ref>[http://www.w3.org/TR/NOTE-sgml-xml-971215 Comparison of SGML and XML; World Wide Web Consortium Note, 15 December 1997]</ref>
 
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 '>'.<ref>[{{cite book |title= SGML and HTML Explained |last= Bryan |first= Martin |publisher= Addison Wesley Longman |year= 1997 |url= http://www.is-thought.co.uk/book/sgml-8.htm#PI] |isbn= 0201403943}}</ref>
 
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 '?>'.<ref>{{cite book | title = The Internet encyclopedia, Volume 3 | author = Hossein Bidgoli | page = 877 | publisher = John Wiley and Sons | year = 2004 | isbn = 0471222038 }}</ref>
<source lang="xml"><?PITarget PIContent?></source>
 
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.<ref name="nutshell"/>
<source lang="xml"><?xml version="1.0" encoding="UTF-8" ?></source>
 
Line 17:
<source lang="xml"><?xml-stylesheet type="text/css" href="style.css"?></source>
 
Another use is the [[PHP programming language]] [[PHP]], which can be embedded within an [[HTML]] document as shown in the following example.<ref name="nutshell">{{cite book | title = XML in a nutshell | author = Elliotte Rusty Harold, W. Scott Means | page = 23 }}</ref>
<source lang="php"><?php echo $a; ?></source>