66. paste

Parameter syntax:

'into'|'toOrInto'|'add'|'toOrAdd' | ('to'|'before'|'after' [ implicit_selection ]?) 
([ S string ]? | [ '[systemSelection]' ]?)
into

Pastes the content of system clipboard into the element containing the caret, at caret position.

to

Pastes the content of system clipboard replacing text selection or selected nodes.

Options to, toOrInto, toOrAdd allow to replace the explicitly selected root element of a document by another element having the same name.

toOrInto

Pastes the content of system clipboard replacing text selection or selected nodes.

OR if there is no explicit selection, pastes the content of system clipboard into the element containing the caret, at caret position.

before, after

Pastes the content of system clipboard before of after selected nodes.

add

Pastes the content of system clipboard at any valid position in the document following the caret position.

toOrAdd

Pastes the content of system clipboard replacing text selection or selected nodes.

OR if there is no explicit selection, pastes the content of system clipboard at any valid position in the document following the caret position.

The system clipboard may contain XML or plain text.

If the [systemSelection] option is used, the content of system selection (always plain text) is used instead of the content of system clipboard.

If string is specified in the command parameter, this string is used instead of the content of system clipboard. Note that string is parsed as XML if it begins with "<?xml", otherwise it is considered to be plain text.

If several nodes are to be pasted, they must be wrapped in a {http://www.xmlmind.com/xmleditor/namespace/clipboard}clipboard element. See last example below.

Examples:

paste toOrInto
paste toOrInto[systemSelection]
paste before[implicitElement]
paste before[implicitElement][systemSelection]

paste after <?xml version='1.0'?><p>A paragraph.</p>
paste toOrAdd <?xml version='1.0'?><p>A paragraph.</p>

paste into <?xml version="1.0"?>
  <ns:clipboard xmlns:ns="http://www.xmlmind.com/xmleditor/namespace/clipboard">
  A text line containing <b>bold</b> and <i>italic</i> text.
  </ns:clipboard>
[Important]

In the above example, for a better readability, the XML strings to be pasted are represented as is —unescaped— and sometimes indented. In practice, this would prevent the paste command from working!

An XML string to be pasted:

  • must have all its markup delimiters ("<", "&", etc) properly escaped ("&lt;", "&amp;", etc);

  • must not contain any non-significant whitespace (i.e. indentation).