Page 1 of 1

Searching for link in XML/JDF file [SOLVED]

Posted: Thu Feb 16, 2023 5:33 pm
by wkopp
I've got an xml with multiple entries for file links. The list could include one entry or up to ten, and the target won't be always in the same position. I need to use the link that's name ends in "-all.pdf" to download my file. I am trying to store the url as a Private Data Key. All the values are either the same (<type>, <units>) or unique to the order (<name>,<url>, <checksum>, etc.).

I know how to filter when searching for a specific value (/MxJdf4/job/article/additional-files/additionalFiles[sizeInBytes=3385008]/url).
Is there a way in the Metadata > Build Location Path to search for a partial file name (/url=%-all.pdf)?

Here is a sample list of URL's. In this example I'm trying to get "<url>https://url1.com/job966098-3-all.pdf</url>":

<additional-files>
<additionalFiles>
<type>0</type>
<name>job966098-3.pdf</name>
<url>https://url1.com/job966098-3.pdf</url>
<checksum>eaca23fdfa58ba359dfd0d59c1bdbc13</checksum>
<sizeInBytes>6104367</sizeInBytes>
<trimBox>
<longEdge>228.60000610351562</longEdge>
<shortEdge>152.39999389648438</shortEdge>
<units>1</units>
</trimBox>
</additionalFiles>
<additionalFiles>
<type>0</type>
<name>job966098-3-cover.pdf</name>
<url>https://url1.com/job966098-3-cover.pdf</url>
<checksum>fe56552eb9243cb32001c89c4db7f785</checksum>
<sizeInBytes>236682</sizeInBytes>
<trimBox>
<longEdge>304.79998779296875</longEdge>
<shortEdge>228.60000610351562</shortEdge>
<units>1</units>
</trimBox>
</additionalFiles>
<additionalFiles>
<type>0</type>
<name>job966098-3-all.pdf</name>
<url>https://url1.com/job966098-3-all.pdf</url>
<checksum>593bf192b7fd985b69d116768e588f10</checksum>
<sizeInBytes>5714732</sizeInBytes>
<trimBox>
<longEdge>304.79998779296875</longEdge>
<shortEdge>228.60000610351562</shortEdge>
<units>1</units>
</trimBox>
</additionalFiles>
</additional-files>

Re: Searching for link in XML/JDF file

Posted: Fri Feb 17, 2023 9:17 am
by loicaigon
Try this:

Code: Select all

/additional-files/additionalFiles/url[contains(text(), '-all.pdf')]
Loic

Re: Searching for link in XML/JDF file

Posted: Fri Feb 17, 2023 5:11 pm
by wkopp
loicaigon wrote: Fri Feb 17, 2023 9:17 am Try this:

Code: Select all

/additional-files/additionalFiles/url[contains(text(), '-all.pdf')]
Loic
Excellent! That did it. Thank you so much!
Very helpful piece of code. Is there a reference somewhere for this kind of thing?

Re: Searching for link in XML/JDF file [SOLVED]

Posted: Fri Feb 17, 2023 5:45 pm
by loicaigon
Glad it helped, the command is part of XPATH API which includes the contains method I have used.
https://www.w3schools.com/xml/xsl_functions.asp
Long history of fail and learn with XSLT talking here ;)