Friday, November 16, 2018

#1 2018-10-31 07:26:30 pm

Budgie
Member
From:: New Zealand
Registered: 2005-02-22
Posts: 657

how to update a value from an imported XML file in Indesign

Hi
I am trying to import a XML file into Indesign CC2018 and then have the information from that update
a property called  "Studio Artist" with a value of "M", the property called  "Studio Artist" already
has a value in it which is this ":", I have managed to bring in the "JobSpecification", but cannot figure
out how to have the value update from  ":" to "M"


This is the XML file:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<JobSpecification>
<JobControl>
        <Set-Property Property="Suppress UI" Value="false"/>
</JobControl>
<Document>
        <Set-Property Property="Studio Artist" Value="M"/>
</Document>
</JobSpecification>




This is the script:

Applescript:

tell application "Adobe InDesign CC 2018"
   set myJobPath to "HD:Users:Budgie:Desktop:mechspec.xml"
   set myDoc to active document
   (import XML myDoc from myJobPath)
   
-- how to have the value update from ":" to "M" ?
   
end tell

any help welcomed please


Cheers
Budgie

"There's no shame in accepting aid from others... but perhaps there is a  responsibility."    - Batman

Offline

 

#2 2018-11-01 05:27:07 pm

Marc Anthony
Member
From:: Dallas, TX
Registered: 2006-04-27
Posts: 841

Re: how to update a value from an imported XML file in Indesign

Hi, Budgie. If you want to do this in InDesign, the method requires you to know the XML item's address, as in my sample code below. You could potentially probe all XML elements until a value is encountered. I wrote a script several years ago that did that, but it appears to be non-functioning at this time; perhaps it was specific to an even older version.

Applescript:

tell application "Adobe InDesign CS3"'s document 1
   set XML element 1's XML element 1's XML element 1's XML attribute "value"'s value to "M"
end tell

Offline

 

#3 2018-11-06 12:40:36 pm

Budgie
Member
From:: New Zealand
Registered: 2005-02-22
Posts: 657

Re: how to update a value from an imported XML file in Indesign

hi Marc

Thanks for the insight, I'm probably trying to implement your suggestion incorrectly, as I cant
seem to get it to work, below is what I thought was right, but nothing happens so I guess it's not.

The XML import definitely adds the property "Studio Artist" and the "Value" of ":"

I get the error:

Adobe InDesign CC 2018 got an error: Can’t set value of XML attribute "Studio Artist" of XML element 1 of XML element 1 of XML element 1 to "M".




Applescript:

tell application "Adobe InDesign CC 2018"
   set myJobPath to "HD:Users:Budgie:Desktop:mechspec.xml"
   set myDoc to active document
   (import XML myDoc from myJobPath)
   
   set XML element 1's XML element 1's XML element 1's XML attribute "Studio Artist"'s value to "M"
   
end tell


Cheers
Budgie

"There's no shame in accepting aid from others... but perhaps there is a  responsibility."    - Batman

Offline

 

#4 2018-11-06 08:09:48 pm

Marc Anthony
Member
From:: Dallas, TX
Registered: 2006-04-27
Posts: 841

Re: how to update a value from an imported XML file in Indesign

Hi. That was really just an example. I stated that you would need to know the address;  i.e. determine it—which requires probing the structure's various branches. In loading your XML, the actual address is a bit further down, and I'm not seeing the conditions described in your question. There  is no ":" value anywhere to be changed. "Property" is an attribute name with "Studio Artist" as its value.

Applescript:

tell application "Adobe InDesign CS3"'s document 1 to set XML element 1's XML element 1's XML element 2's XML element 1's XML attribute "Property"'s value to "Studio Artist or M or whatever"

I'm not sure what you're ultimately doing. If the XML isn't already associated with document elements, I would probably advise against using InDesign to change the structure, because finding these lengthy object references more than a few times is going to be a horror show.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)