Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
The
processing-instruction()
construct can also be written with empty parentheses, in which case it will match any processing instruction. As an alternative, you can provide a name within the parentheses, in which case it will only match processing instructions with that name. For compatibility with XPath 1.0, the name can optionally be written in quotes, as a string literal. This means you can match an
processing instruction using either of the constructs:
processing-instruction(xml-stylesheet)
processing-instruction(“xml-stylesheet”)
The two forms are precisely equivalent, except that using an invalid name is an error in the first case but not the second (you just won't select anything).
Matching Elements and Attributes
The syntax for matching elements and attributes is more complex, because it allows you to take advantage of the type information attached to these nodes as a result of schema validation. The type annotation of an element or attribute node may be any type defined in an XML Schema, or a built-in type. In the case of attributes, it must be a simple type, for elements it can be either a simple or a complex type. All simple types are allowed, including list types and union types. However, although any type defined in a schema can appear as a node annotation, the only types you can refer to directly are those that:
Here's the basic syntax for element and attribute tests (it is organized slightly differently from the official W3 C grammar):
Expression | Syntax |
ElementTest | BasicElementTest | SchemaElementTest |
AttributeTest | BasicAttributeTest | SchemaAttributeTest |
BasicElementTest | element ( ( ElementNameOrWildCard ( , TypeName ? ?)? )? ) |
BasicAttributeTest | attribute ( ( AttribNameOrWildcard ( , TypeName)? )? ) |