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. - dam > David Mundie wrote: > > XMLEditor's run + insertString is a powerful technique, but what > if what > > you want to compute XML markup to be parsed and added to the > document? > > insertString seems to implicitly quote markup. > > > > To take the example from the documentation: > > > > <command name="insertCommandOutput"> > > <macro> > > <sequence> > > <command name="run" /> > > <command name="insertString" parameter="%_" /> > > </sequence> > > </macro> > > </command> > > > > If I use this to run a shell script that simply returns an > element, e.g. > > > > #!/bin/sh > > echo "<i>This is a test</i>" > > > > what gets inserted into the document is not an "i" node, but > rather the > > string "<i>Thisis a test</i>", which is not what I > want. How > > can I get XMLEditor to parse the result of the command? Sorry if > this > > has been asked before; I have searched the mail archive and the > > documentation and didn't see anything. > > You need to use "paste" instead of "insertString" and the string to be > inserted must start with "<?xml ". See > http://www.xmlmind.com/xmleditor/_distrib/docs/commands/ch06s34.html > > Example: > > --- > #!/bin/sh > echo "<?xml version="1.0"?><i>This is a test</i>" > --- > > --- > <command name="insertCommandOutput"> > <macro> > <sequence> > <command name="run" /> > <command name="paste" parameter="into %_" /> > </sequence> > </macro> > </command> > ---

