Section 15.9.  Processing instructions

Prev don't be afraid of buying books Next

15.9. Processing instructions

An XML comment is for those occasions where you need to say something to another human being without reference to the DTD or schema, and without changing the way the document looks to readers or applications. A processing instruction (PI) is for those occasions where you need to say something to a computer program without reference to the DTD or schema and without changing the way that the document is processed by other computer programs. This is only supposed to happen rarely.

Processing instructions start with a fixed string "<?". That is followed by a name and, after that, any characters except for the string that ends the PI, "?>". The XML declaration shown in Example 15-10 is an example.

The name at the beginning of the PI is called the PI target. This name would typically be specified in the documentation for the tool or specification. In this case, the PI target is the XML processor itself.

After the PI target comes white space and then some totally proprietary command. This command is not parsed in the usual way at all. Characters that would usually indicate markup are totally ignored. The command is passed directly to the application and it does what it wants to with it.

The command ends when the processor sees the string "?>". There is absolutely no standard for the characters in the middle. PIs could use attribute syntax for convenience, as the XML declaration does, but they could also choose not to.

Processing instructions are appropriate when you are specifying information about a document that is unrelated to its structure and content. As we describe in 18.10, "Referencing XSLT stylesheets", on page 412, XSL provides a processing instruction for associating stylesheets. Similarly, Office uses a PI to determine which application to use to open an XML document:

 <?mso-application prog?> 

Note that this sort of processing instruction does not really add anything to the content or structure of the document. It says something about how to process the document. It says: "This document has an associated stylesheet (or application)."

It is not always obvious what is abstract information and what is merely processing information. If your information must be embedded in documents of many types, or with DTDs or schemas that you cannot change, then processing instructions are typically the appropriate technique.

Amazon


XML in Office 2003. Information Sharing with Desktop XML
XML in Office 2003: Information Sharing with Desktop XML
ISBN: 013142193X
EAN: 2147483647
Year: 2003
Pages: 176

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net