Hi....How to read the XTags in QuarkXPress using apple scrip

Discuss XML import/export in QuarkXPress 8 & 9 (and before).

If you are interested in newer XML publishing formats that Quark offers, then please contact us about Modifier XML (QuarkXPress Documents as XML) in QuarkXPress Server or about Quark XML Author.
Locked
poovili
Posts: 0
Joined: 26 Feb 2008, 02:09

Hi....How to read the XTags in QuarkXPress using apple scrip

Post by poovili » 27 Mar 2008, 00:38

Hi....I need a apple script that will read the XTags in a Quark document 6.5. All i need is to find some text in Xtag and replace that with some other text....

Please send me the script as soon as possible....

Thanks in advance....

Regards,
Poovili.

Ravi
Posts: 39
Joined: 11 Jan 2006, 12:41

Hi....How to read the XTags in QuarkXPress using apple scrip

Post by Ravi » 12 May 2008, 01:42

Hello Poovili,

You can use simple find and replace function of word or text edit to replace the word correct?

Emma
Posts: 657
Joined: 07 Jul 2004, 08:43

Hi....How to read the XTags in QuarkXPress using apple scrip

Post by Emma » 12 May 2008, 03:28

Ravi is right - but you won't be able to read XPress Tags within a Quark document. You have to save as text with XPress Tags first, then do the search and replace, then put the text back in.

Have a look at this. I've put in a few explanations but ask if you don't understand!

set my_path to (path to desktop folder from user domain) as string
set export_file to my_path & "ExportedText"
set new_file to my_path & "CleanedText"

--this part saves story 1 as an XPress Tags file, named ExportedText
tell document 1 of application "QuarkXPress"
tell story 1
save [b]it in file export_file as "XPress Tags"
[b]end [b]tell
[b]end [b]tell

--now for the search and replace routines, which run on the exported text file
[b]copy (read file export_file) [b]to the_text
[b]set fileref [b]to open for access new_file [b]with write permission

-- Put the search and replace strings in here. Copy the line and put in as many as you like.
[b]set the_text [b]to replace_chars(the_text, "the text to look for", "the text to replace it with")

-- Now the edited file is saved as "CleanedText"
write the_text starting at eof to fileref
close access fileref


-- Write the edited file back into story 1
[b]tell application "QuarkXPress"
[b]set properties [b]to {import styles:true}
[b]tell document 1
[b]set story 1 [b]to file new_file --re-import the text
[b]end [b]tell
[b]end [b]tell

--now delete the text files, otherwise subsequent runs will add to them!
[b]tell application "Finder"
delete file export_file
delete file new_file
[b]end telldisplay dialog "DONE"-- this routine does the search and replace work for youon replace_chars(this_text, search_string, replacement_string)set item_count to 10repeat until item_count = 1set AppleScript's text item delimiters to the search_stringset the item_list to every text item of this_textset item_count to length of item_listset AppleScript's text item delimiters to the replacement_stringset this_text to the item_list as stringset AppleScript's text item delimiters to ""end repeatreturn this_textend replace_chars

Ravi
Posts: 39
Joined: 11 Jan 2006, 12:41

Hi....How to read the XTags in QuarkXPress using apple scrip

Post by Ravi » 12 May 2008, 04:45

Thanks Emma for the detailed AS

Ravi

Locked

Return to “QuarkXPress 8 & 9: XML Import/Export - discontinued”