David Mundie wrote:
> Over a year ago I asked how to use an external command to insert nodes,
> as opposed to strings, into a document. Yesterday I got around to
> trying the proposed solution. I encountered two problems:
>
> The first, and lesser, problem is that there's no convenient way to get
> the output from my shell command into the clipboard. I could redirect
> the output to a file, and write an Applescript that opens the file and
> copies it to the clipboard, but somehow I don't think that's what
> Hussein had in mind.
>
> The second problem, for which I have no workaround, is that for me
> using paste has the same result as using insertString - I end up with
> quoted markup, not an italic node. Maybe this has changed in the year
> since this first came up? I'm assuming the current URL for the
> reference is http://www.xmlmind.com/xmleditor/_distrib/doc/commands/
> paste.html.
>
I'm sorry but what follows works as expected: "Esc ! /tmp/test.sh ENTER"
do insert an i element containing "This is a test" at caret position.
/tmp/test.sh
---
#!/bin/sh
echo '<?xml version="1.0"?><i>This is a test</i>'
---
---
<command name="insertCommandOutput2">
<macro>
<sequence>
<command name="run" />
<command name="paste" parameter="into %_" />
</sequence>
</macro>
</command>
<binding>
<keyPressed code="ESCAPE" />
<charTyped char="!" />
<command name="insertCommandOutput2" />
</binding>
---
[[[Notice that (nested double quotes!):
---
echo "<?xml version="1.0"?><i>This is a test</i>"
--
outputs (no quotes around 1.0!):
---
<?xml version=1.0?><i>This is a test</i>
---
which cannot be parsed as XML and is therefore pasted as a string.]]]
Now this being said, please explain exactely what you want and I'll try
to implement it for you using a macro.
Fo example, copying the content of an XML file in the clipboard can be
implemented by using:
[1] the "read" element of a process command. See
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/read.html
[2] the "clipboard" variable of a macro command. See
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/xpath_vars.html