Document syntax
Processing instruction
A <?target data?> node carrying instructions for an application, passed through the parser without being interpreted as content.
A processing instruction has a target — an NCName saying which application should care — and everything up to the closing ?> is opaque data for that application. The parser guarantees only that the syntax is well-formed; it attaches no meaning at all.
The best-known one is xml-stylesheet, which associates an XSLT or CSS stylesheet with a document and is why a raw RSS feed sometimes renders as a styled page in a browser. Targets beginning with the letters xml, in any case, are reserved.
- Defined in
- XML 1.0 §2.6
- Category
- Document syntax
- Also written
- PI, <?target data?>
Shown, not asserted
All 2 claims are executed on every test run, against the same engines the tools use. If the behaviour changes, the test fails rather than this page quietly becoming wrong.
Processing instructions before the root element are still nodes in the tree.
document.xml <?xml-stylesheet href="feed.xsl" type="text/xsl"?> <x><?sort by="name"?></x>expression count(//processing-instruction())What the engine returns
2Their data is opaque: it is not parsed into attributes.
document.xml <?xml-stylesheet href="feed.xsl" type="text/xsl"?> <x/>expression string(//processing-instruction()[1])What the engine returns
href="feed.xsl" type="text/xsl"
Where it bites
A definition on its own is trivia. These are the pages where this term decides whether a document works.
- Parse errorsProcessing instruction not terminatedWhat an unclosed processing instruction reports.
- FormatsXSLT stylesheetxml-stylesheet is how a document points at the transform that renders it.
- FormatsRSS 2.0Feeds carry a stylesheet PI so a browser shows something other than raw markup.
Related terms
- XML declarationThe optional <?xml version="1.0" encoding="UTF-8"?> at the very start of a document, declaring its version and character encoding.
- CommentA <!-- … --> block that carries no document content and is not part of any element's text.
- XSLTA language for transforming XML into other XML, HTML or text, written as templates that match patterns in the source tree.
- NCNameA non-colonised name: an XML name with no colon in it, which is what a namespace prefix and a local name each have to be.
Get started
Bring order to the XML your team can't afford to ignore.
Create a free account and get a private workspace to search, validate, diff, and monitor your XML feeds, sitemaps, schemas, and vendor integrations.