The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniGraffle > OmniGraffle General
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Automatically Diagram XML data? Thread Tools Search this Thread Display Modes
Hmm, I commented out the line and Omnigraffle Professional (5.2.1) Put the initial homepage node in, but that was it. Another vote for major celebration if anyone can get this working. Or is it possible to grab an old copy of Omnigraffle from anywhere?
Having no luck using this with OmniGraffle Pro version 5.2.1

Anybody figure out what the tweaks are ?
got it to compile with this

set children to back to front ordering
--set children to back to front ordering

unfortunately, no sitemap generated rom the resulting XML :-(

Last edited by deny; 2010-01-11 at 08:50 AM..
For those of you who are having troubles, I just want to talk through the process again:

First, copy the script from jeremybrown's post into Script Editor:

Try to compile the script. You may be asked to show where the application Omnigraffle is. If it doesn't compile, the issue is typically the back to front ordering line, which you can comment out by placing a double hypen at the beginning of the line (--):
-- set children to bottom to top ordering

Then Save As an 'application' and place where you like.

When you want to create a new sitemap, just drag your xml file onto the AppleScript Application and it will load OmniGraffle and start creating the document in the frontmost canvas.

It can take a little while if there's a lot of pages so give it a few minutes.

Hope that helps someone!

Hi everybody-

I've been following this thread for awhile and re-wrote some of the code here to create my own version of this script. You run the script, find your sitemap.xml file, and it does the rest, I believe. Let me know if it works for you as well as it does for me.

Here's a link to the blog post. It contains instructions and the download.

Here's the code so you can see how I did it:

-- v0. works but includes http:// as a base node *duh*
-- v1. removes http:// baseline, improves performance
-- v2. is a minor re-write
-- v3. removes notion of folder vs. uri shapes
-- prompt user to select sitemap.xml file

-- function that draws each type of box
on makeShape(aTitle, aURL)
	tell application "OmniGraffle Professional 5"
		tell canvas of front window
			return make new shape with properties {text:aTitle, url:aURL, vertical padding:5, autosizing:full, side padding:10, magnets:{{1, 0}, {-1, 0}, {-1, 1}, {-1, -1}}, origin:{(x of canvasSize) / 2.0, (y of canvasSize) / 2.0}}
		end tell
	end tell
end makeShape

on findShape(shapeText)
	tell application "OmniGraffle Professional 5"
		set matchingShapes to shapes of canvas of front window whose url is shapeText
		if (count of matchingShapes) is greater than 0 then
			return item 1 of matchingShapes
		end if
	end tell
end findShape

on drawConnectingLine(aSource, aDestination)
	tell application "OmniGraffle Professional 5"
		tell aSource
			set aLine to connect to aDestination with properties {line type:straight}
		end tell
		set tail magnet of aLine to 1
	end tell
end drawConnectingLine

on makeNewSitemap()
	tell application "OmniGraffle Professional 5"
		make new document
		tell layout info of canvas of front window
			set type to left to right
			-- set children to back to front ordering
		end tell
	end tell
end makeNewSitemap

on cleanupSitemap()
	tell application "OmniGraffle Professional 5"
		tell canvas of front window
			page adjust
		end tell
	end tell
end cleanupSitemap

set sitemapFile to choose file with prompt "Please select a sitemap.xml file." of type {"XML"}
set sitemapXML to open for access sitemapFile

set uriList to {}

set isDone to false

-- got to be a better way here.
repeat until isDone -- end of sitemapXML
		-- read up to a tag, and see what the tag is
		read sitemapXML before "<"
		set theTag to read sitemapXML before ">"
		-- if it is a <loc> tag, then read the contents
		if theTag is "loc" then
			-- jumps to next < start of tag
			set uriText to read sitemapXML before "<"
			-- strip the "http://" is 7 characters 
			set uriText to text 8 thru (length of uriText) of uriText
			copy uriText to the end of uriList
		end if
	on error errStr number errorNumber
		-- you'll want the next line if you want to see error messages
		-- display dialog errorNumber
		set isDone to true
	end try
end repeat
close access sitemapXML


set savedDelimiters to AppleScript's text item delimiters
set text item delimiters to "/"

set nodeList to {}

repeat with currentURI in uriList
	if last character of currentURI is "/" then
		set currentURI to text 1 thru ((length of currentURI) - 1) of currentURI
	end if
	set currentItems to text items of currentURI
	repeat with i from 1 to count of items in currentItems
		-- cItem in currentItems
		set cItem to item i of currentItems
		if contents of cItem is in nodeList then
			-- find the matching shape within the list, and make it the node parent node 
			-- do nothing
			-- log " cItem in nodeList "
			-- add this item to the list of nodes
			copy contents of cItem to the end of nodeList
			-- create this shape
			set childNode to makeShape(cItem, cItem)
			if i is greater than 1 then
				-- this must be a child node, so we must find the previous node's shape
				set parentText to contents of item (i - 1) of currentItems
				set parentNode to findShape(parentText)
				drawConnectingLine(parentNode, childNode)
			end if
		end if
		--		makeShape(cItem, cItem)
	end repeat
end repeat

set text item delimiters to savedDelimiters

I recently came on this thread, and Jason's work is phenomenal. I found a number of opportunities for improvement and put those into a fork of his original project. (Thanks for making it open source, Jason!) This one does a lot, including applying a template to your file (so it's pretty), and adding the full page text so you can search the diagram for page text.

You can download the binary on my site:

Or get the source on GitHub:

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I break process diagram into separate pages and display diagram name on every page Chien OmniGraffle General 0 2012-04-25 06:38 AM
Creating graphs automatically from imported data Angostura OmniGraffle General 2 2008-04-30 12:29 PM
automatically formatted imported data MAatHome OmniOutliner 3 for Mac 3 2007-12-04 06:32 PM

All times are GMT -8. The time now is 05:25 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.