Hi All,
I'm struggling with a problem for awhile. It's clear how to fetch specific data from an external dataset in PowerSwitch, but what if the data is a 'moving target'? Example:
var theDataset = job.getDataset("pi4"); // external dataset added by Callas pdfToolbox
var theOutputIntent = theDataset.evalToString( "/*/*[1]/*[4]/*[4]/*/*[4]" );
That's working fine, until the needed data is at the very same place. But in certain files the XPath should be something else, like "/*/*[1]/*[4]/*[5]/*/*[4]".
How can I query the needed info using the node names of the XML? Of course I know the node names, which are:
/report
/document
/resources
/output_intents
/output_profilename
Thanks in advance, kind regards,
Peter
Querying data from XML using node names
-
- Newbie
- Posts: 16
- Joined: Mon Apr 04, 2011 3:56 pm
Querying data from XML using node names
Hi Peter,
simply by using the node (and maybe also attribute) names within your XPath expressions
I don't have the structure of a callas pdfToolbox XML preflight report in front of me but relying on the information you wrote the correct XPath would be
/report/document/resources/output_intents/output_intent/output_profilename
As there might be more than one output intent in a PDF file you might access a specific one by using an index:
/report/document/resources/output_intents/output_intent[1]/output_profilename
or one or more pieces of additional information which uniquely identifies the node(s) within the XML like e.g. the PDF/X compliant output intent:
/report/document/resources/output_intents/output_intent[@subtype=GTS_PDFX]/output_profilename
Unfortunately this will not work because callas defines a default name space within their report XML files and therefore you will have to define a generic name space prefix within your XPath expressions:
/default_switch_ns:report/default_switch_ns:document/default_switch_ns:resources/default_switch_ns:output_intents/default_switch_ns:output_intent[@subtype='GTS_PDFX']/default_switch_ns:output_profilename
Regards
Robert
simply by using the node (and maybe also attribute) names within your XPath expressions

I don't have the structure of a callas pdfToolbox XML preflight report in front of me but relying on the information you wrote the correct XPath would be
/report/document/resources/output_intents/output_intent/output_profilename
As there might be more than one output intent in a PDF file you might access a specific one by using an index:
/report/document/resources/output_intents/output_intent[1]/output_profilename
or one or more pieces of additional information which uniquely identifies the node(s) within the XML like e.g. the PDF/X compliant output intent:
/report/document/resources/output_intents/output_intent[@subtype=GTS_PDFX]/output_profilename
Unfortunately this will not work because callas defines a default name space within their report XML files and therefore you will have to define a generic name space prefix within your XPath expressions:
/default_switch_ns:report/default_switch_ns:document/default_switch_ns:resources/default_switch_ns:output_intents/default_switch_ns:output_intent[@subtype='GTS_PDFX']/default_switch_ns:output_profilename
Regards
Robert
-
- Newbie
- Posts: 16
- Joined: Mon Apr 04, 2011 3:56 pm
Querying data from XML using node names
Hi Robert,
thanks for the quick help, it's working fine. I've never ever figured it out alone.
Kind regards,
Peter
thanks for the quick help, it's working fine. I've never ever figured it out alone.
Kind regards,
Peter