XPath is a way to refer to parts of an XML document, for example, a JDF ticket. A simple subset of the XPath language [XPath] 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 a parent.
For example: //ResourcePool indicates a ResourcePool element in an element
Predicates are always embedded in square brackets. Predicates are used to find a specific node or a node that contains a specific value.
This document can contain the following types of predicates:
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.
XPath: /JDF/ResourcePool/Media/GeneralID[@IDUsage="oce:Orientation"]/@IDValue
This XPath refers to the following part of an XML document:
<JDF>
<ResourcePool>
<Media>
<GeneralID IDUsage="oce:Orientation" IDValue="LongEdgeFeed"/>
</Media>
</ResourcePool>
</JDF>
XPath: /JDF[contains(@Types="Trimming")]/ResourcePool/TrimmingParams/GeneralID[@IDUsage="oce:CutWidth"]/@IDValue
This XPath refers to the following part of an XML document:
<JDF Types="Trimming">
<ResourcePool>
<TrimmingParams>
<GeneralID IDUsage="oce:CutWidth" IDValue="<double>"/>
</TrimmingParams>
</ResourcePool>
</JDF>
/JDF/ResourcePool/Contact[contains(@ContactTypes="Owner") and @ID="<text>"]/@oce:UserID/oce:ComChannel[@ChannelType="ComputerName"]/@Locator
This XPath refers to the following part of an XML document:
<JDF>
<ResourcePool>
<Contact ID="<text>" ContactTypes="Owner" oce:UserID="<text>">
<oce:ComChannel ChannelType="ComputerName" Locator="<hostname>"/>
</Contact>
</ResourcePool>
</JDF>