On 11/21/2014 05:13 PM, Jeff Hooker wrote:

Is there a method of available for simply writing the output of a macro
to the clipboard?

Sure. What follows copies the last result of the macro, no matter what it could be, to the clipboard.

plainString="true" simply ensures that the last result of the macro is not evaluated as an XPath expression.

<macro>
  ...SOME CODE WHICH IMPLICITLY SETS %_ HERE...

  <set variable="clipboard" expression="%_" plainString="true"/>
</macro>

See the "clipboard" XPath variable in http://www.xmlmind.com/xmleditor/_distrib/doc/commands/xpath_vars.html



Remember that if you want the contents of the clipboard to be usable as XML (as opposed to plain text), this contents must be well-formed XML starting with "<?xml ".

Moreover if you want to copy several nodes to the clipboard, these nodes must be wrapped in a {http://www.xmlmind.com/xmleditor/namespace/clipboard}clipboard element. Example:

  <?xml version="1.0"?>
  <ns:clipboard
    xmlns:ns="http://www.xmlmind.com/xmleditor/namespace/clipboard";
    xmlns="http://www.w3.org/1999/xhtml";>
    A text line containing <b>bold</b> and <i>italic</i> text.
  </ns:clipboard>

See command "paste" in http://www.xmlmind.com/xmleditor/_distrib/doc/commands/paste.html.




Many of the ditamaps I work with are immense, and I don’t want to load
the whole document set view just to create a single xref to a resource
within a DITA topic, so I would like to write a command that will take
whatever element is currently selected, assuming it has an ID, and write
either a completed xref element or at least the href value for it to the
clipboard so that I can paste it in at my preferred location.

OK.




Should this be possible?

Sure. See above.




I can find no reference to “copying to the
clipboard” in the commands.pdf document, and simply stopping an existing
command that copies, processes, and pastes content before the “paste”
command is run does not seem to leave what would have been pasted
sitting on the clipboard.


That's right. By doing this, you modify a copy of the contents of the clipboard.




--
XMLmind XML Editor Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xmleditor-support

Reply via email to