JDF data model

The JDF data model describes a class that inherits all functions described in the Dataset class.

Query language

The JDF data model expects an XML backing file that conforms to the JDF 1.3 specification. A JDF instance describes a nested structure of JDF nodes and their resources. The result is a nicely structured XML file which can be validated by an XML schema. The JDF specification uses XPath 1.0 notation to refer to items in a JDF instance. Thus it is appropriate to use this notation to locate items in a query.

The current implementation of the JDF data model in fact considers the underlying XML file with some limited JDF-specific functionality layered on top.

Namespaces

Namespace prefixes in the query expression are resolved into namespace URIs using the prefix map provided to the query functions as a second argument. If the map argument is omitted or null, the default prefix map is used for resolving prefixes.

A JDF instance is required to set its default namespace to the JDF namespace, and all XML elements and attributes described in the JDF specification reside in this namespace. XPath 1.0 however does not have the concept of a default namespace. Therefore the default prefix map for the JDF data model includes a definition of the "jdf" prefix (in addition to any other prefixes defined in the backing file), and JDF query expressions should explicitly use this prefix.

A JDF instance may contain elements or attributes in other namespaces, allowing third-party extensions to the specification. The query functions allow providing a prefix map to enable accessing these extensions.

Generic XPath querying

The JDF data model implementation offers two types of query mechanisms. The first mechanism allows evaluating an arbitrary XPath 1.0 expression with the same semantics as those in the XML data model, i.e. the expression's value is converted to one of the data types string, number or Boolean using XPath 1.0 semantics.

This generic mechanism supports complex queries that may involve multiple elements or attributes (for example, counting the number of elements in a particular node set).

evalToString( xpath : String, prefix-map : Map ) : String

Evaluates the XPath 1.0 expression against the backing file, and returns the result after converting it to a string value with the XPath 1.0 string() function.

evalToNumber( xpath : String, prefix-map: Map ) : Number

Evaluates the XPath 1.0 expression against the backing file, and returns the result after converting it to a numeric value with the XPath 1.0 number() function.

evalToBoolean( xpath : String, prefix-map: Map ) : Boolean

Evaluates the XPath 1.0 expression against the backing file, and returns the result after converting it to a Boolean value with the XPath 1.0 boolean() function.

JDF data type querying

The second query mechanism uses an XPath 1.0 location path (not an arbitrary expression) to indicate a single XML attribute or a single XML element, and thus to indicate a single text value. This text value is then interpreted and converted to a script object according to the JDF data type semantics described in the JDF specification.

The current implementation supports a limited subset of the JDF data types, as described in the following table.

Query function

Supported JDF data types

getString()

string, NMTOKEN, telem, text

any other data type (since everything is stored as text)

getNumber()

double, integer, LongInteger

getBoolean()

boolean

getDate()

date, dateTime, gYearMonth

The query functions described below return the null object (as opposed to an empty string or a zero number) if:


getString( xpath : String, prefix-map : Map ) : String

Returns the text value of the item at the specified XPath 1.0 location path. The text content of an element is concatenated into a single string. Leading and trailing whitespace is removed. Whitespace including linebreaks may occur in the body of the string.

getNumber( xpath : String, prefix-map: Map ) : Number

Same as getString but interprets the string as a decimal number with support for negative and positive infinity (-INF and INF) as per the JDF specification. Numbers outside the range of the scripting language are clipped to negative of positive infinity.

getBoolean( xpath : String, prefix-map: Map ) : Boolean

Same as getString but interprets the string as a boolean ("true" or "false") as per the JDF specification.

getDate( xpath : String, prefix-map : Map ) : Date

Same as getString but interprets the string as a date and/or a time according to the JDF specification (based on the ISO 8601 format). The class of the returned Date object is specific to the scripting environment in use.