Searching for link in XML/JDF file [SOLVED]

Post Reply
wkopp
Newbie
Posts: 13
Joined: Mon Sep 16, 2019 8:20 pm

Searching for link in XML/JDF file [SOLVED]

Post 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>
Last edited by wkopp on Fri Feb 17, 2023 5:14 pm, edited 1 time in total.
loicaigon
Advanced member
Posts: 379
Joined: Wed Jul 10, 2013 10:22 am

Re: Searching for link in XML/JDF file

Post by loicaigon »

Try this:

Code: Select all

/additional-files/additionalFiles/url[contains(text(), '-all.pdf')]
Loic
wkopp
Newbie
Posts: 13
Joined: Mon Sep 16, 2019 8:20 pm

Re: Searching for link in XML/JDF file

Post 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?
loicaigon
Advanced member
Posts: 379
Joined: Wed Jul 10, 2013 10:22 am

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

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