The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniFocus Extras (http://forums.omnigroup.com/forumdisplay.php?f=44)
-   -   Importing OPML (Outline Processor Markup Language) files (http://forums.omnigroup.com/showthread.php?t=10432)

David Murby 2008-11-04 04:40 AM

Importing OPML (Outline Processor Markup Language) files
 
I'm trying to figure out if I can import an OPML file directly into OminFocus - at the moment I'm failing miserably.
I have a project management application (Merlin) that exports in OPML format (amongst others) and specifically mentions OmniOutliner as a target application for this file format. Since OmniOutliner is supposed to export to OmniFocus I was hoping that there's some way of getting an OMPL file directly into OmniFocus. I would not want to buy OmniOutliner just to use it as an intermediate step between the two applications.
When I try to import into OmniFocus the import dialogu doesn't even recognise the OMPL file as a valid import option. Anyone out there manged to complete this or something similar?
David.

whpalmer4 2008-11-04 06:39 AM

You don't need to buy OmniOutliner to use it in read-only mode, and I think that's all you should need. Omni's policy is that you can use their document applications as readers for their files without charge -- helps promote their use if you can create a document with one and send it to someone who doesn't own the app!

Download OmniOutliner from the product page, fire it up and open the .OPML file you've got. Then select all the rows, copy and try to paste into OmniFocus. You'll get a dialog box that allows you to specify how OO columns map into OF data. There are some bugs right now (in OF 1.5, at least) which I've been writing up so it isn't quite trouble-free, but you should be able to get the actions/projects without too much trouble. The bugs I know about at the moment are that dates don't seem to transfer, and the cancel button on the dialog to map columns doesn't actually cancel.

David Murby 2008-11-04 09:26 AM

Works a treat! Can't see any major problems that a small amount of editing won't solve and this'll save me an awful lot of retyping on something I'll only need to do occasionally.
Thanks.

miguelmarcos 2010-04-28 01:26 AM

I just came here to find out how I can transfer OPML to OmniFocus. I have OPML that comes out of CarbonFin Outliner on my iPod Touch (a nice, basic outliner). It's awesome that Omni has allowed read-only capability in their apps. This worked well.

I'll be glad to go to OmniOutliner on iPhoneOS if it ever comes out but for now CarbonFin is very useful.

RobTrew 2010-04-30 03:22 AM

[QUOTE=whpalmer4;50110]Download OmniOutliner from the product page, fire it up and open the .OPML file you've got. Then select all the rows, copy and try to paste into OmniFocus. You'll get a dialog box that allows you to specify how OO columns map into OF data[/QUOTE]

Simply dragging one or more OPML files onto a droplet app on your desktop would avoid the need for OmniOutliner and might give an easier workflow (and more control) if it needs to be done at all regularly.

I have placed a simplified version of the droplet which I use at:

[URL="http://www.complexpoint.macmate.me/Site/Import_OPML_into_OF.html"]http://www.complexpoint.macmate.me/Site/Import_OPML_into_OF.html[/URL]

It creates a date-stamped OF folder of the imported projects for each OPML file that has been dragged onto the droplet.

(This version just imports the text of each opml node, and any Omni-style _note attribute, but the applescript can easily be adapted to import any other columns/attributes which your opml may have.)

The draft code (to be saved in .app format) looks like this:

[CODE]-- DROPLET TO IMPORT OPML FILES INTO OMNIFOCUS

-- Ver 0.4 Now gives warning message if XML Tools osax
-- from http://www.latenightsw.com/freeware/XMLTools2/index.html
-- has not been copied to ~/Library/ScriptingAdditions


property pstrDialogTitle : "OPML to OmniFocus Ver 0.4"
property pstrImportFolder : "Imported from OPML"
property pEmpty : ""

-- TRY TO READ THE DROPPED FILE(S) AS OPML
-- AND TRANSLATE CONTENTS OF EACH FILE
-- TO A NEW DATE-STAMPED FOLDER OF OF PROJECTS
on open lstfDropped
set {lstFolders, lngProjects, lngFiles} to {{}, 0, 0}
repeat with fDropped in lstfDropped
if IsOPML(fDropped) then
set strFile to ReadTextFile(fDropped)
try
set xmlDoc to parse XML strFile
set xmlContent to (a reference to XML contents of (last item of XML contents of xmlDoc))
set lstActivities to XML2List(xmlContent)
set {lngActs, oFolder} to PlaceInOF(lstActivities)
set end of lstFolders to oFolder
set lngProjects to lngProjects + lngActs
set lngFiles to lngFiles + 1
on error
set the clipboard to "http://www.latenightsw.com/freeware/XMLTools2/index.html"
set strError to "
This script requires installation of Late Night Software's free XML Tools osax

From:

http://www.latenightsw.com/freeware/XMLTools2/index.html

(This URL is now in your clipboard, and can be pasted to a browser)

The version of the XML Tools.osax which matches your operating system should be copied to a folder with the path:

~/Library/ScriptingAdditions
"
display dialog strError buttons {"OK"} with title pstrDialogTitle
tell application id "com.apple.finder"
set strAddns to "ScriptingAdditions"
set fldrLibrary to folder ((path to home folder as string) & "Library") as alias
if not (exists folder strAddns of fldrLibrary) then
set fldrAddns to (make new folder at fldrLibrary with properties {name:strAddns})
else
set fldrAddns to folder strAddns of fldrLibrary
end if
open fldrAddns
activate front window
end tell
return
end try
else
display dialog "Expected file with extension .opml" with title pstrDialogTitle
end if
end repeat
ShowResult(lngProjects, lstFolders, lngFiles)
end open

-- Give feedback to user
on ShowResult(lngProjects, lstFolders, lngFiles)
if lngProjects > 0 then
set strMsg to ((lngProjects as text) & " projects placed in OmniFocus" & return & return &
"(" & lngFiles as text) & " opml file"
if lngFiles > 1 then
set strMsg to strMsg & "s imported)"
else
set strMsg to strMsg & " imported)"
end if
display dialog strMsg with title pstrDialogTitle
tell application id "com.omnigroup.OmniFocus"
tell front document
set recProps to {selected view mode identifier:"project", focus:lstFolders}
set oWin to make new document window with properties recProps at front of document windows
end tell
activate
end tell
else
display dialog "No projects found in " & strFile with title pstrDialogTitle
end if
end ShowResult


-- CREATE A FOLDER OF PROJECTS IMPORTED FROM OPML
on PlaceInOF(lstActivities)
set lngActivities to length of lstActivities
if lngActivities > 0 then
tell application id "com.omnigroup.OmniFocus"
tell front document
set strName to pstrImportFolder & " " & (current date)
set oFolder to make new folder with properties {name:strName}
my FillOFFolder(oFolder, lstActivities)
end tell
end tell
{lngActivities, oFolder}
else
{0, missing value}
end if

end PlaceInOF

-- Transfer activities to the specified project (or parent task)
on FillOFFolder(oFolder, lstActivities)
using terms from application "OmniFocus"
tell oFolder
repeat with oAct in lstActivities
set {strName, lstChiln, strNote} to oAct
if strNote is missing value then
set oProj to make new project with properties {name:strName}
else
set oProj to make new project with properties {name:strName, note:strNote}
end if
if length of lstChiln > 0 then my FillOFProj(oProj, lstChiln)
end repeat
end tell
end using terms from
end FillOFFolder

-- Transfer activities to the specified project (or parent task)
on FillOFProj(oProj, lstActivities)
using terms from application "OmniFocus"
tell oProj
repeat with oAct in lstActivities
set {strName, lstChiln, strNote} to oAct
if strNote is missing value then
set oTask to make new task with properties {name:strName}
else
set oTask to make new task with properties {name:strName, note:strNote}
end if
if length of lstChiln > 0 then
my FillOFProj(oTask, lstChiln)
end if
end repeat
end tell
end using terms from
end FillOFProj

-- READ FROM PARSED XML TO SIMPLE APPLESCRIPT LIST WITH TITLE SUB_LIST AND NOTE
on XML2List(lstContent)
set lstText to {}
repeat with xmlNode in lstContent
try
-- GET TEXT OF NODE
set recAttribs to (a reference to XML attributes of xmlNode)
set lngAttribs to length of recAttribs
if lngAttribs > 0 then
set end of lstText to {|text| of recAttribs}
else
set end of lstText to {pEmpty}
end if

-- GET ANY CHILDREN OF NODE
set refNewNode to (a reference to the last item of lstText)
set lstChildren to (a reference to XML contents of xmlNode)
if length of lstChildren > 0 then
set end of refNewNode to XML2List(lstChildren)
else
set end of refNewNode to {}
end if

-- GET ANY OMNI-STYLE _note OF NODE
if lngAttribs > 1 then
set strNote to pEmpty
set strNote to _note of recAttribs
if length of strNote > 0 then
set end of refNewNode to strNote
else
set end of refNewNode to pEmpty
end if
else
set end of refNewNode to pEmpty
end if
end try
end repeat
lstText
end XML2List


on ReadTextFile(fFile)
open for access fFile
try
set strContents to (read fFile)
on error
set strContents to ""
end try
close access fFile
return strContents
end ReadTextFile

-- Check that the file has an .opml extension
on IsOPML(fDropped)
set strFileName to fDropped as string
set {strDelim, text item delimiters} to {text item delimiters, "."}

set lstParts to text items of strFileName
set lngParts to length of lstParts
if lngParts < 2 then
set blnIsOPML to false
else
set strSuffix to (item lngParts of lstParts)
ignoring case
set blnIsOPML to (strSuffix is "opml")
end ignoring
end if
set text item delimiters to strDelim
blnIsOPML
end IsOPML

[/CODE]

RobTrew 2011-01-18 10:37 AM

I have updated the OPML2OF.app file at [URL="http://bit.ly/djsGUF"]http://www.complexpoint.macmate.me/Site/Import_OPML_into_OF.html[/URL] so that it now warns the user if the free [URL="http://www.latenightsw.com/freeware/XMLTools2/index.html"]XML Tools osax[/URL] from Late Night Software (which this script requires) has not yet been copied to ~/Library/ScriptingAdditions.

Rob.

[COLOR="White"]--[/COLOR]

Ilajn 2011-02-19 12:18 PM

Hi,
I've installed the XML Tools.osax and I downloaded the OPML2OF.app. But when I dorp an OPML file on the App I always get the error message that I have to install the XML Tools. Any solutions?

I'm on 10.6.6

RobTrew 2011-02-19 12:35 PM

[QUOTE=Ilajn;93688]I've installed the XML Tools.osax[/QUOTE]

What happens if you run this script:

[CODE]on run
display dialog XML comment as string
end run[/CODE]

or run the following line in a Terminal.app window:

[CODE]ls ~/Library/ScriptingAdditions[/CODE]

?

Coolcat21 2011-02-19 12:46 PM

With the goal of getting my brainstormed nodes out of MindNode Pro into OmniFocus, I happened on your post about your applet, installed it along with XML Tools component and HOCUS POCUS, the OPML file exported from MindNode Pro was imported flawlessly into OmniFocus. Thanks for your work! It's very much appreciated!

Ilajn 2011-02-20 11:01 AM

[QUOTE=RobTrew;93689]What happens if you run this script:

[CODE]on run
display dialog XML comment as string
end run[/CODE][/QUOTE]

A window pops up saying "XML comment".

[QUOTE]

or run the following line in a Terminal.app window:

[CODE]ls ~/Library/ScriptingAdditions[/CODE]

?[/QUOTE]

The Terminal.app puts out:
"XML Tools.osax"


All times are GMT -8. The time now is 12:50 PM.

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