Creating a new Xcode text document fails. Is it possible?

My script is as simple as

tell application id "com.apple.dt.Xcode"
			tell (make new text document with properties {path:path to documents folder as string})
				set contents to script_item's script_text
				set visible of the front window to true
			end tell
		end tell

script_text is defined but omitted here for the sake of brevity.

AppleScript returns error

Xcode 4.6.3 got an error: Can’t make or move that element into that container, number -10024

What’s happening here?

According to the Xcode AppleScript dictionary, I should be able to perform such a simple task.

It looks like you’re setting the documents path to its parent folder. What happens if you try including a file name in that path?

Problem solved. Quite predictably, the Xcode DOM won’t allow the creation of new documents. This is a common annoyance with some scriptable apps. TextEdit has it too.

The workaround is standard: make the file outside by telling “System Events” or “Finder”, then open it in the target app and manipulate its contents as its dictionary prescribes.

A mess, frankly.