Dataset class

The Dataset class is a base class that offers a number of functions common to all types of metadata datasets. There is a separate inheriting class for each metadata data model supported by the scripting API: XML data model, JDF data model, XMP data model, and Opaque data model.

Instances of the Dataset class (or rather of its inheriting classes) can be obtained with the Job.createDataset(), Job.getDataset() and Job.getEmbeddedDataset() functions in the flow element module.

See also external metadata and embedded metadata.

Getting dataset attributes

getPath( ) : String

For an external dataset, returns the absolute file path (including filename and extension) for the backing file for this dataset. This is used predominantly for placing the backing file in the correct location while creating a new dataset. However it might conceivably be used to bypass the data model access mechanisms and provide direct access to the backing file.

For an embedded dataset, returns the absolute path to the file that embeds the metadata (rather than the metadata packet as a separate entity).

hasValidData( ) : Boolean

Returns true if the backing file exists, can be read, and conforms to the syntax and semantics of the dataset's underlying data model. Otherwise returns false.

getModel( ) : String

Returns the name of the data model for the dataset ("XML", "JDF", "XMP" or "Opaque"). In effect this determines the actual class of this instance.

Returns true if this data set corresponds to embedded metadata, i.e. if it has been returned by the Job.getEmbeddedDataset() function. Otherwise returns false.

Returns "CP2" for a CP2 dataset; otherwise behaves as before.

isWritable( ) : Boolean

Returns true if this data set supports updating its corresponding embedded metadata (only embedded metadata can be updated). Otherwise returns false.

Creating prefix maps

createEmptyMap( ) : Map

Returns a new empty prefix map object.

createDefaultMap( ) : Map

Returns a new prefix map object that already contains all mappings that occur in the backing file. For an Opaque dataset this function returns an empty prefix map object.

For XML and JDF datasets, the default namespace (if any) is included in the default map with one or more special prefixes. This allows XPath queries to refer to the default namespace using these special prefixes. (XPath does not support the default namespace concept, so you always have to explicitly provide a namespace prefix).

The following table summarizes the contents of the default map for each data model.

Data model

Default namespace defined in backing file

Namespace prefixes defined in the backing file

XML

Included in default map with special prefixes "default_switch_ns" and "dn" unless these prefixes are otherwise defined in the file

Included in default map using the prefix specified in xmlns:<prefix> attribute

JDF

Included in default map with special prefix "jdf" unless this prefix is otherwise defined in the file

XMP

Not applicable

Opaque

Not applicable

Not applicable

For a CP2 dataset, the "cp2" prefix (with corresponding namespace) is always included in the map, even if the underlying XMP does not define it (because if does not contain Certified PDF 2 metadata or because it uses another prefix). Otherwise the function behaves as before.