Access Metadata within script

Post Reply
ArielRauch
Advanced member
Posts: 231
Joined: Thu Aug 07, 2014 10:04 am

Access Metadata within script

Post 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
freddyp
Advanced member
Posts: 1023
Joined: Thu Feb 09, 2012 3:53 pm

Access Metadata within script

Post 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
ArielRauch
Advanced member
Posts: 231
Joined: Thu Aug 07, 2014 10:04 am

Access Metadata within script

Post 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:))
freddyp
Advanced member
Posts: 1023
Joined: Thu Feb 09, 2012 3:53 pm

Access Metadata within script

Post 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
ArielRauch
Advanced member
Posts: 231
Joined: Thu Aug 07, 2014 10:04 am

Access Metadata within script

Post 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
Post Reply