Howdy–
I have a script created that does the following
- Creates a document
- Creates styles that match a DTD
- Import the DTD
- Map the tags to styles
- Import an XML document
- create a text frame
but what i absolutly cannot figure out is how to get the XML content into the text frame. I need to do it two ways because of two different template types I’m creating.
- Set up tagged frames and have the XML content fill those frames accordingly
- Set up a general text frame and just have all the XML content flow in.
I think I’ve been to every page on the Adobe website and read every example, but these are the two things that I’m not able to find anywhere. It’s mind-boggling. I’ve included a shortened version of the script below my sig. i can do all of this by hand, but i cannot find any of the Applescript commands to do it all automatically.
Any help anyone can give would be greaty appreciated. Thanks!
Philip
lists (insert “at” symbol here) oatmeal and coffee dot com
tell application "Adobe InDesign CS2"
--preset check
set presetCheck to (get name of every document preset)
if "MKTG_AUTO_Generic" is not in presetCheck then
set GenericDocPreset to make new document preset with properties {bottom:36, document bleed bottom offset:0, document bleed outside or right offset:0, document bleed inside or left offset:0, document bleed top offset:0, facing pages:false, left:36, name:"MKTG_AUTO_Generic", page height:792, page orientation:portrait, page width:612, right:36, top:36}
end if
set GenericDoc to make new document with properties {document preset:"MKTG_AUTO_Generic"}
tell GenericDoc
--creates all the character and paragraph styles
make new paragraph style with properties {name:"story", applied font:"Times", font style:"Roman", point size:18, space after:6} --1
make new paragraph style with properties {name:"book", applied font:"Times", font style:"Roman", point size:18, space after:6} --11
make new paragraph style with properties {name:"book_title", applied font:"Times", font style:"Roman", point size:18, space after:6} --14
make new character style with properties {applied font:"Times", name:"book_title_article", font style:"Roman", size:12.0} --15
make new character style with properties {applied font:"Times", name:"book_title_title", font style:"Roman", size:12.0} --16
make new character style with properties {applied font:"Times", name:"book_title_subtitle", font style:"Roman", size:12.0} --17
make new character style with properties {applied font:"Times", name:"book_title_edition", font style:"Roman", size:12.0} --18
make new character style with properties {applied font:"Times", name:"book_title_version", font style:"Roman", size:12.0} --19
make new paragraph style with properties {name:"book_biblio", applied font:"Times", font style:"Roman", point size:18, space after:6} --35
make new character style with properties {applied font:"Times", name:"book_isbn_code", font style:"Roman", size:12.0} --39
make new character style with properties {applied font:"Times", name:"book_isbn_10", font style:"Roman", size:12.0} --40
make new character style with properties {applied font:"Times", name:"book_isbn_13", font style:"Roman", size:12.0} --41
--technical prep
set ruler origin of view preferences of GenericDoc to page origin --very important for ease of placing elements according to Adobe
--sets color variables
set noColor to swatch "None" of GenericDoc --document 1
set blackColor to swatch "Black" of GenericDoc --document 1
set blueColor to swatch "C=100 M=0 Y=0 K=0" of GenericDoc --document 1
set whiteColor to swatch "Paper" of GenericDoc --document 1
--import the DTD and map accordingly
set theDTDDoc to "Macintosh HD:Users:Shared:AutoMarketing_0_1:System:XML:MKTG_DTD_Parsing_1_4_b_SLSA_0_4.dtd"
import dtd from theDTDDoc
set PStyleCount to (get count of paragraph styles)
repeat with p from 1 to PStyleCount
set thisPStyle to paragraph style p
set thisPStyleObj to object reference of thisPStyle
set thisPStyleName to name of thisPStyleObj as string
if thisPStyleName is not "[Basic Paragraph]" and thisPStyleName is not "[No Paragraph Style]" then --Avoids this error: The tag you are trying to create has an invalid name.
set XMLImportMap to make XML import map with properties {mapped style:thisPStyle, markup tag:thisPStyleName}
end if
end repeat
set CStyleCount to (get count of character styles)
repeat with p from 1 to CStyleCount
set thisCStyle to character style p
set thisCStyleObj to object reference of thisCStyle
set thisCStyleName to name of thisCStyleObj as string
if thisCStyleName is not "[None]" and thisCStyleName is not "[No Character Style]" then --Avoids this error: The tag you are trying to create has an invalid name.
set XMLImportMap to make XML import map with properties {mapped style:thisCStyle, markup tag:thisCStyleName}
end if
end repeat
--import the XML
set theXMLDoc to "Macintosh HD:Users:Shared:AutoMarketing_0_1:System:XMLQueue:MKTG_DTD_Parsing_1_4_b_SLSA_0_4.xml"
import XML from theXMLDoc
--create the page elements
set TitleFrame to make new text frame with properties {geometric bounds:{54, 54, 154, 558}}
--flow in the XML into the appropriate text elements
set contents of TitleFrame to contents of XML element "book_title"
(* THIS IS WHERE I'M STUMPED *)
--STOP ERROR: Invalid value for set property 'contents'. Expected string, placeholder text or auto page number/...
end tell --document
end tell --application