Transferring Metadata to PrivateData

ArielRauch
Advanced member
Posts: 230
Joined: Thu Aug 07, 2014 10:04 am

Transferring Metadata to PrivateData

Post by ArielRauch »

Hi,

I am still struggling with fetching Metadata entered via a Submit point, into privateData.

I have also problems building an appropriate fixture to test it.



Some sample parts of a script would be very helpful.



Thanks



Ariel
ArielRauch
Advanced member
Posts: 230
Joined: Thu Aug 07, 2014 10:04 am

Transferring Metadata to PrivateData

Post by ArielRauch »

Actually even if I work with job.getVariableAsString how do I loop through fieldlist/field[1...n]/tag?
dkelly
TOP CONTRIBUTOR
Posts: 628
Joined: Mon Nov 29, 2010 8:45 pm
Location: Alpharetta GA USA
Contact:

Transferring Metadata to PrivateData

Post by dkelly »

You can enumerate through XML nodes using code like this:



var nodeList = theXML.getDocumentElement().getChildNodes();

for (var i=0; i < nodeList.length; i++) {

var theNode = nodeList.getItem(i);

if (theNode.getBaseName() == "ChildNode") {

var aValue = theNode.getAttributeValue( "a" );

s.log(1, "found ChildNode with attribute a=" + aValue);

}

}

User avatar
gabrielp
Advanced member
Posts: 577
Joined: Fri Aug 08, 2014 4:31 pm
Location: Boston
Contact:

Transferring Metadata to PrivateData

Post by gabrielp »

I think you would find it's a lot easier to just use something like this https://github.com/dominickp/SwitchWriteToPrivateData to "build metadata location path" to write it to private data. You would just have to put a hold on a folder somewhere and you can inspect the metadata in "single line text with variables". Much easier than trying to figure out the xpath or xml structure in the script, IMO.
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
ArielRauch
Advanced member
Posts: 230
Joined: Thu Aug 07, 2014 10:04 am

Transferring Metadata to PrivateData

Post by ArielRauch »

Thank you both, Dwight and Gabriel,

I will try it tomorrow morning
ArielRauch
Advanced member
Posts: 230
Joined: Thu Aug 07, 2014 10:04 am

Transferring Metadata to PrivateData

Post by ArielRauch »

getting crazy:



I put a submit point into a flow and I set "strip unique name" to no.

Afterwards I copied the path of the resulting pdf (I used two fields f1 and f2) into the fixture of incoming files for the following script:





// Is invoked each time a new job arrives in one of the input folders for the flow element.

// The newly arrived job is passed as the second parameter.

function jobArrived( s : Switch, job : Job )

{

var dataset = job.getDataset("Order");

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

var namespaceMap = metadata.createDefaultMap();

var jobID = metadata.evalToString("/Order/field-list/field[1]/tag",namespaceMap);

s.log(1,"aaaa");

job.sendToSingle(job.getPath());

}





I receive the following error message:



Libxml error 4: 'Start tag expected, '<' not found ' in file 'file:///C:/TEMP/1/FixtureTest01/inFolder2/_00001__00158_Epsilon031.pdf' on line 1

Invalid xml document C:/TEMP/1/FixtureTest01/inFolder2/_00001__00158_Epsilon #1.pdf



Only to be clear: The only metadata that is associated with the pdf is the one I entered via the submit point.



Any help is more than welcome!!!



Thanks



Ariel
tz8
Member
Posts: 84
Joined: Mon Aug 13, 2012 12:56 pm

Transferring Metadata to PrivateData

Post by tz8 »

use dataset.getPath() instead of job.getPath() in the new Document() part! ;)



var metadata = new Document(dataset.getPath());
ArielRauch
Advanced member
Posts: 230
Joined: Thu Aug 07, 2014 10:04 am

Transferring Metadata to PrivateData

Post by ArielRauch »

This was my first approach.

This is was I received:

10/7/2014 14:21:50,Assert,Control,,,,,Libxml error 1549: 'failed to load external entity "" ' in file '' on line 0
tz8
Member
Posts: 84
Joined: Mon Aug 13, 2012 12:56 pm

Transferring Metadata to PrivateData

Post by tz8 »

did you add the xml information you want in the fixture set? You need to mark the incoming job, then declare the existing datasets for a job under "Metadata datasets" otherwise you're not going to have any in SwitchScripter
tz8
Member
Posts: 84
Joined: Mon Aug 13, 2012 12:56 pm

Transferring Metadata to PrivateData

Post by tz8 »

do a quick



job.log(1, job.getDatasetTags() );



to see if your job actually has datasets attached?
ArielRauch
Advanced member
Posts: 230
Joined: Thu Aug 07, 2014 10:04 am

Transferring Metadata to PrivateData

Post by ArielRauch »

what do you mean by:

declare the existing datasets for a job under "Metadata datasets"



all the fields which are in the submit points?
ArielRauch
Advanced member
Posts: 230
Joined: Thu Aug 07, 2014 10:04 am

Transferring Metadata to PrivateData

Post by ArielRauch »

you are right.

there are no datasets with this job.

How can I prepare a job with datasets - I thought by switching the option "strip unique name" to no I keep all the metadata together with the pdf
tz8
Member
Posts: 84
Joined: Mon Aug 13, 2012 12:56 pm

Transferring Metadata to PrivateData

Post by tz8 »

ArielRauch wrote:

Afterwards I copied the path of the resulting pdf (I used two fields f1 and f2) into the fixture of incoming files for the following script:


what exactly do you mean by that? _where_ do you do the scripting? In SwitchScripter? And you copy the data over into it?
tz8
Member
Posts: 84
Joined: Mon Aug 13, 2012 12:56 pm

Transferring Metadata to PrivateData

Post by tz8 »

ArielRauch wrote: you are right.

there are no datasets with this job.

How can I prepare a job with datasets - I thought by switching the option "strip unique name" to no I keep all the metadata together with the pdf
no, you can't transport metadata like that, SwitchScripter doesn't work with the job database of Switch!



If you need the resulting XML file from your order entry point do a "export metadata" on "Order" and use this as the metadata backing file in Switch Scripter
ArielRauch
Advanced member
Posts: 230
Joined: Thu Aug 07, 2014 10:04 am

Transferring Metadata to PrivateData

Post by ArielRauch »

I did what you said and received:

10/7/2014 16:05:22,Assert,Control,,,,,Libxml error 1549: 'failed to load external entity "" ' in file '' on line 0



Btw, when I am running the script in a flow I even do not receive the log messages.
Post Reply