Page 1 of 1

Access Metadata within script

Posted: Tue Sep 30, 2014 9:41 am
by ArielRauch
Hi,

I have a jdf file which I added to an asset (JDF pickup) and now I would like to access Metadata via a script expression.

I am struggling with the syntax.

Can someone send me an example about how to access the xml(jdf) data?



Thanks



Ariel

Access Metadata within script

Posted: Tue Sep 30, 2014 2:54 pm
by freddyp
The easiest method is to use job.getVariableAsString("[Metadata.Text....]");



Build the metadata query first and then copy and paste it. Beware of escaping the double quotes!



Freddy

Access Metadata within script

Posted: Tue Sep 30, 2014 2:58 pm
by ArielRauch
Wow, thanks - did not think of that way.



What about the other (probably more complicated way) via the metadata interface (getString())? Do you have any examples for it - (I know I should stop here - but my technical inside shouts for knowing the other possibility:))

Access Metadata within script

Posted: Wed Oct 01, 2014 10:32 am
by freddyp
var dataset = job.getDataset("Name of dataset, probably Jdf");

var metadata = new Document(dataset.getPath());

var namespaceMap = metadata.createDefaultMap();

var jobID = metadata.evalToString("/jdf:JDF/@JobID",namespaceMap);

s.log(1,jobID);



Freddy

Access Metadata within script

Posted: Wed Oct 01, 2014 10:35 am
by ArielRauch
thank you very much, Freddy.

I already implemented your first approach but I will probably change it to this solution.

Again thanks,



Ariel