🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #16429

Mapping a Character Style to XML Tag

#16429
From: Kari Puikkonen
Date: Fri, 12 Sep 2003 22:24
36 lines
1987 bytes
Helps!

I found this script - from this forum - that maps character styles to XML Tag:



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



�but it only works if the tag to which I would like to apply the charcter style is 2 levels deep.

How do I change the script to affect also tags that are in three levels, four leves etc� deep?

Kari
Technical Details
Message-ID: <2ccd6a5b.-1@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!62.132.236.44.MISMATCH!ecngs!feeder.ecngs.de!npeer.de.kpn-eurorings.net!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f939a,10a8a5cbe2e389a5,start
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-09-12 15:37:52 PST
From: "Kari Puikkonen" <kari.puikkonen@welho.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-09!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!62.132.236.44.MISMATCH!ecngs!feeder.ecngs.de!npeer.de.kpn-eurorings.net!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.scripting.indesign
Subject: Mapping a Character Style to XML Tag
Message-ID: <2ccd6a5b.-1@webx.la2eafNXanI>
Date: Fri, 12 Sep 2003 15:24:40 -0700
Lines: 40
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit