Thread View: adobe.scripting.indesign
4 messages
4 total messages
Started by sudar1983
Sat, 21 Mar 2009 07:36
Array sort with XML Attributes
Author: sudar1983
Date: Sat, 21 Mar 2009 07:36
Date: Sat, 21 Mar 2009 07:36
10 lines
949 bytes
949 bytes
Hi All, Windows / CS3 / JavaScript 1. I have XML Elements in Array, each Element have attribute called pg='34' like this, I want to sort this array using 'pg' attribute. 2. I am Reading all stories from indesign file, it is not coming with perfect alignment order (ie) First story coming from last page and second story coming from first page. I want to align the stories with layout order. Regards, Sudar
Re: Array sort with XML Attributes
Author: Dave_Saunders
Date: Sat, 21 Mar 2009 13:09
Date: Sat, 21 Mar 2009 13:09
7 lines
915 bytes
915 bytes
Use a callback function with the standard JavaScript sort call. The function would be responsible for comparing the values of the pg attributes and returning -1, 0 or 1 to the sort function. The general idea is described here (first hit on a Google search): <http://solutoire.com/2007/05/02/sorting-javascript-arrays/> Dave
Re: Array sort with XML Attributes
Author: sudar1983
Date: Mon, 23 Mar 2009 04:40
Date: Mon, 23 Mar 2009 04:40
6 lines
708 bytes
708 bytes
Thanks Dave, I have sorted using attribute, but in the second question Is it possible or not? Regards, Sudar
Re: Array sort with XML Attributes
Author: Dave_Saunders
Date: Mon, 23 Mar 2009 11:54
Date: Mon, 23 Mar 2009 11:54
9 lines
811 bytes
811 bytes
You'll need to get the stories references into an array: myStories = myDocument.stories.everyItem().getElements(); and the sort them based on the page numbers of the first text container. So, yes it is possible. Dave
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads