Article View: adobe.scripting.indesign
Article #18573Finally! Mapping a Character Style to an XML Tag
From: adamcoop
Date: Wed, 12 Mar 2003 04:32
Date: Wed, 12 Mar 2003 04:32
28 lines
1828 bytes
1828 bytes
I did it. (I couldn't get the other examples to work for me) This Applescript applies a character style to the contents of an XML element and displays a statistics window on completion: tell application "InDesign 2.0.2" set theDocument to active document tell theDocument set theTag to "Body_Text_Bold" --Sets the tag containing text to be formatted set theStyle to character style "Body_Text_Bold" -- Character style to apply set parentTag to "Body_Text" -- The tag in question is 2 levels deep - this is it's parent set numberDone to 0 tell XML Element parentTag repeat with myCounter from 1 to (count XML Elements) set myXMLElement to XML Element myCounter if name of markup tag of myXMLElement is theTag then set applied character style of contents of XML Element myCounter to theStyle set numberDone to numberDone + 1 end if end repeat display dialog "Number of XML elements in " & parentTag & ": " & (count XML Elements) & return & "Number of elements styled: " & numberDone end tell end tell end tell
Technical Details
Message-ID:
<1de840e9.-1@WebX.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!easynet-quince!easynet.net!oleane.net!oleane!bnewspeer01.bru.ops.eu.uu.net!emea.uu.net!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebXShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,33e3064188bb8807,start X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-03-11 20:37:47 PST From: adamcoop <adam.c@ncprint.com.au> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!easynet-quince!easynet.net!oleane.net!oleane!bnewspeer01.bru.ops.eu.uu.net!emea.uu.net!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Finally! Mapping a Character Style to an XML Tag Message-ID: <1de840e9.-1@WebX.la2eafNXanI> Date: Tue, 11 Mar 2003 20:32:51 -0800 Lines: 34 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit