Highlighted

Build XML structure by scripting

Explorer ,
Mar 07, 2017

Copy link to clipboard

Copied

Hi everybody,

I'm writting here regarding a project using XML and ExtendScript.

I have a big XML file to import in InDesign.

The InDesign layout is pretty simple (title, content).

I'm looking for a way to write a script with the following steps:

By hands

- import the XML file into a 1 page document

- make the correct structure > link the text frame with the content of the first node of the XML file

By Scripting

- duplicate the page 1 of the document. (each page correspond to a new XML node)

- one the page 2 to n, link the text frame with the content of the current node (content 1, content2, content3)

- I will use the function placeXML(textframe) to build the correct stucture

Does anyone know if this is a good start?

I'm confortable with ExtendScript but I'm not sure if there is a better way to build the XML structure?

Is it possible to get the element like a textframe by name to avoid errors?

Thank you in advance for your help.

Well, I've finally found the book and the samples.

Here are a couple of screenshots illustrating the approach:

Before — a template containing only one page with one xml-element placed.

08-03-2017 15-36-47.png

After — after importing an xml-file which has identical structure, more pages are inserted (235 in total) and variable data are added to each page. Note: each page has a different dog picture, breed. etc. InDesign does all this automatically: no script was used.

08-03-2017 15-38-33.png

Are you interested in this or still stick to the idea of doing this by script?

— Kas

Topics

Scripting

Views

1.5K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Build XML structure by scripting

Explorer ,
Mar 07, 2017

Copy link to clipboard

Copied

Hi everybody,

I'm writting here regarding a project using XML and ExtendScript.

I have a big XML file to import in InDesign.

The InDesign layout is pretty simple (title, content).

I'm looking for a way to write a script with the following steps:

By hands

- import the XML file into a 1 page document

- make the correct structure > link the text frame with the content of the first node of the XML file

By Scripting

- duplicate the page 1 of the document. (each page correspond to a new XML node)

- one the page 2 to n, link the text frame with the content of the current node (content 1, content2, content3)

- I will use the function placeXML(textframe) to build the correct stucture

Does anyone know if this is a good start?

I'm confortable with ExtendScript but I'm not sure if there is a better way to build the XML structure?

Is it possible to get the element like a textframe by name to avoid errors?

Thank you in advance for your help.

Well, I've finally found the book and the samples.

Here are a couple of screenshots illustrating the approach:

Before — a template containing only one page with one xml-element placed.

08-03-2017 15-36-47.png

After — after importing an xml-file which has identical structure, more pages are inserted (235 in total) and variable data are added to each page. Note: each page has a different dog picture, breed. etc. InDesign does all this automatically: no script was used.

08-03-2017 15-38-33.png

Are you interested in this or still stick to the idea of doing this by script?

— Kas

Topics

Scripting

Views

1.5K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Guru ,
Mar 07, 2017

Copy link to clipboard

Copied

You don't need a script for this: use the 'clone repeating text elements' option in the import xml options dialog box.

Check out the 'work with repeating data' section in indesign help.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Mar 07, 2017

Copy link to clipboard

Copied

Hi,

Thank you for your message… I'm not sure I'm doing this correctly…
I tried to import this XML with clone repeating text elements.

It works well but only for the first page. In this project, I will have 300 pages.
Those pages only contains 1 title and an adresse.

So during the import InDesign must duplicate the current page with the the layout and merge XML tag with the second row of the database.

So I still need a script to duplicate the master page xxx times. Link all xml fields with the correct text frame?

See my capture below.

Capture d’écran 2017-03-08 à 08.17.21.png

Thank you very much for your advices

P.-S. I found a video here that explain how to do this (IDUG Berlin#31 – InDesign & XML - YouTube ) see at the 43 minutes.
I guess it is a good way for simple layout. How to do if I need more blocs? If I have multiples stories?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Contributor ,
Mar 08, 2017

Copy link to clipboard

Copied

Hi Bastien,

this is a feasible way you are going, except I would:

1. Add a scripting label to each textframe on the first page, then

2. Import the XML, then

3. Duplicate the first page according the the number of nodes in the XML, then

4. Link each XML node the the corresponding textframe on the page (finding it with the scripting label)

Thanks  stefan

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Guru ,
Mar 08, 2017

Copy link to clipboard

Copied

Hi,

I don't understand German so can't figure out what's going on there.

I read how to do this in Designer's Guide to Adobe InDesign and XML by James Maivald. But it was a few years ago and I don't remember how I did it since I don't use it in my everyday practice. And I can't find the book and my exercise files on my new computer: I must left them on my old one. But I remember he explained with an example how to clone repeating elements and used no scripts in his book,

— Kas

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Guru ,
Mar 08, 2017

Copy link to clipboard

Copied

Well, I've finally found the book and the samples.

Here are a couple of screenshots illustrating the approach:

Before — a template containing only one page with one xml-element placed.

08-03-2017 15-36-47.png

After — after importing an xml-file which has identical structure, more pages are inserted (235 in total) and variable data are added to each page. Note: each page has a different dog picture, breed. etc. InDesign does all this automatically: no script was used.

08-03-2017 15-38-33.png

Are you interested in this or still stick to the idea of doing this by script?

— Kas

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Explorer ,
Mar 08, 2017

Copy link to clipboard

Copied

Hi,

Thank you very much for your help…

I still interested, I personally prefer your approach…

Is it possible to have your sources files (XML and InDesign)?
I the video posted before the process is probably the same but your document seems to be closed from mine.In the example that I have, the author only has one text frame…

Thank you for your comments again.
Best,
Bastien

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Community Beginner ,
Mar 30, 2020

Copy link to clipboard

Copied

Hej there!

Thanks for the workflow. I can't seem to get it to work yet, though.

Simplified, my structure is:

 

<content>

<event1>
<a>ASDF1</a>
<b>QWER1</b>
</event1>

<event2>
<a>ASDF2</a>
<b>QWER2</b>
</event2>

<event3>
<a>ASDF3</a>
<b>QWER3</b>
</event3>

</content>

 

I created a page 1, linked all the XML containers to tags and to text frames and imported it using the »clone« option.

Page 1 still loads up all the updated information perfectly and the XML structure panel shows all the other <eventN> containers including their content. But InDesign doesn't automatically create any further pages.

 

I tried to have <event> containers without the digit, I tried adding empty pages beforehand and I tried out the different import-options – no luck 😕

Do I have to do anything via the master page?

My approach was to try and script it, too, but that would be a looong way to go for me. So a simpler method, which seems to be possible, would be so much nicer.

 

I realise this is a rather old thread, but I guess the topic didn't age. So... any thoughts? 🙂

 

Thanks in advance & best wishes

Mattis

 

edit: I opened a new topic for the issue, find it here:

https://community.adobe.com/t5/indesign/multipage-xml-automatisation/td-p/11015857?page=1

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...