Skip to main content
Participating Frequently
October 8, 2009
Answered

How to edit xml link?

  • October 8, 2009
  • 1 reply
  • 5017 views

First a few words about my context:

I received a layout made on a CS3 version of InDesign. Now I am trying to create a procedure to automate the production of several pdf based on this layout. Manually the process would be to open the layout; edit the xml link with each xml source and create a corresponding pdf...

First issue:

In CS4 when I want to manually edit the xml link, the opened dialog prevent me (xml files are in gray) to select xml files, is it a well-known issue? How can I avoid it?

Second question:

How to edit the xml link from script?

Last question - applescript question - :

How to skip application dialogs? Like "This document miss some links, would you continue?"

If you'd be able to help me, thanks in advance!

This topic has been closed for replies.
Correct answer Loic.Aigon

> I am not skilled at all with applescript. There is a lot of very good applescripters around here. You may refer to ADobe scripts examples, it's quite sure there is a relink example in it.

So I will try your javascript I think it's possible to call javascripts from applescript. I hope actually because there is no relink example with InDesign CS4.

Thanks again


There is a piece of code found on the net :

tell document 1 of application "Adobe InDesign CS3"
relink thisItemLink to someFileReference
update thisItemLink
end

1 reply

Loic.Aigon
Legend
October 8, 2009

Hi,

Depending on your needs, you may choose to

Manually :

1. Label an element of the layout (ex: a graphic frame labeled "Image");

2. Install xmljs library which is very cumfy to deal with XML without loading xml into Indesign.

Via scripting :

3. Process through the xml with the library and get back the datas your need (a picture file path for example)

4. Open the indesign document and proceed like this :

- Duplicates page one

- Proceed to changes on this duplicated page (graphic changes)

- Set the pdfExportPreferences.pageRange to the page name (as String);

- Export the page your document as PDF

- Continue

5. Either save or not the document, close it.

xmljs : http://xmljs.sourceforge.net/

But that's not applescript...

A+ Loic

poxdAuthor
Participating Frequently
October 8, 2009

Hi and thanks for your answer.

My issue is not about xml but moreover InDesign and its integration (or my misuse) with it. The layout I received is intended to be used against several xml files I generate on my side. What I have to do is to take the layout and run the following process for every xml file I generated:

1. Import the xml file into the layout (I'd like to edit xml link indeed instead of an import xml command as the import does'nt give me the same results sometime)

2. Export as pdf

Loic.Aigon
Legend
October 9, 2009

Exactly that's more that! Now the only issue is that when I use the import feature I end sometime with results I don't want... Although when I use the "edit xml link" functionality (possible only in InDesign CS3, see the 1st post) I always get the result I want.

How can I use scripting to do that?

Thanks for your patience


Ok, sorry for digression,

I can't get what you mean by being prevented from manually editing xml links with Indesign. I tried and I can do it whatever I use CS3 or CS4.

But maybe, i didn't seize something, don't hesitate to tell more about your process.

Regarding scripting xml links replacing,

You may use something like :

//my_old_xml will be the name of the link that appears in the links palette

//Replace '/m/scripting/xml/test/my_new.xml' by the path to you rnew xml file;

app.activeDocument.links.item("my_old_xml").relink(File('/m/scripting/xml/test/my_new.xml'));
app.activeDocument.links.item("datas4.xml").update();

you can of course process through a bunch of xml files with Folder.getFiles('*.xml');

After that you have to place the root xmlElement in the main textFrame to get your pages generated.

Then loop for pages length and set pdfExportPreferences to pages and export your file.

Hope it helps.

Loic