XPath is a way to refer to parts of an XML document, for example, a JDF ticket. A simple subset of the XPath language is used in the description of an element, attribute or value to identify other elements, attributes and/or values.
The simple subset of XPath used is:
Element subelement hierarchy is indicated by a slash.
For example: element/element
Element attribute hierarchy is indicated by a slash and an at (@) symbol.
For example: element/@attribute
Paths beginning with a single slash: '/' indicate root elements.
For example: /JDF indicates the root JDF node
Paths beginning with a double slash '//' indicate elements with any parent.
For example: //ResourcePool indicates a ResourcePool element in any element
Paths containing square brackets that enclose a predicate describe an element that is restricted by the predicate.
Different types of predicates are used in this document:
E[@A = V]
The XPath specifies an element E whose attribute A has the value V.
E[contains(@A = V)]
The XPath specifies an element E whose attribute A has some value that contains V.
E[@A]
The XPath specifies an element E in which attribute A is present.
The JDF ticket is an XML file that contains a default namespace. The prefix "jdf:" maps that default namespace. The XPath expression must use the prefix "jdf:" to be able to query the nodes in the XML files. Without the prefix, the XPath query is not valid. "jdf:" must be lower-case since an XPath query is case-sensitive. The default namespace in the JDF ticket is:
<JDF ID = "JDF_Id_Job1" Type = "ProcessGroup" xmlns = "http://www.CIP4.org/JDFSchema_1_1" ...>
XPath="/jdf:JDF/jdf:ResourcePool/jdf:ApprovalParams/jdf:GeneralID[@IDUsage='SubmittersDescription']/@IDValue"
This XPath refers to the following part of the JDF ticket:
<JDF>
<ResourcePool>
<ApprovalParams>
<GeneralID IDUsage="SubmittersDescription" IDValue="<value>"/>
</ApprovalParams>
</ResourcePool>
</JDF>