There is no way to make your command work because there is currently no
way to copy a plain string to the clipboard.
This is a glaring omission. We'll add this macro-command helper in next
release.
Let's imagine this macro-command helper has already been written and
that it is called "copyToClipboard", your macro "getAtt" is much too
complicated. It could be rewritten as follows:
---
<command name="getAtt">
<macro>
<sequence>
<get context="$selected" expression="@id" />
<command name="copyToClipboard" parameter="%_" />
</sequence>
</macro>
</command>
---
This works because a command-button, by default, will select the element
which is the target of its CSS rule. Therefore, in your case, you can
assume that after clicking on the icon next to a <co> having an "id",
this <co> is explicitly selected.
A possible workaround is:
[1] Copy the id in a variable shared with another macro (that is, do not
use the clipboard).
[2] Write another macro which assigns the value found in the shared
variable to the "arearefs" of the <callout>.
Remember that a shared variable must have a name which has
"http://www.xmlmind.com/xmleditor/namespace/scope/view" as its
namespace. See
http://www.xmlmind.com/xmleditor/_distrib/docs/commands/ch04s01s03.html
versorger at gmx.li wrote:
> Hi there,
>
> maybe someone can point me to the right direction with this. When editing
> DocBook, I want <co> elements to appear styled with an icon. Clicking this
> icon copies the <co>'s id attribute to the clipboard, so that I can paste it
> to a <callout>'s arearefs.
>
> As I could only find commands like putAttribute and addAttribute but nothing
> like getAttribute, I tried to hack something myself. The command in [2]
> seems to succesfully copy the value of id (I checked it with the alert
> command instead of copy).
> The problem with the copy command is that not only the id is copied to the
> clipboard, but also loads of other tags [3].
>
> The question is: Does XXE offer a simple way to get an attribute value? And
> if not, is it possible to make my command work?
>
> Thanks for helping and sorry for the lengthy mail ...
> Patrick
>
>
>
>
> [1] css
>
> co[id]:after {
> content: command-button(icon, icon(right-target),
> command, "getAtt"
> );
> }
>
> [2] command "getAtt"
>
> <command name="getAtt">
> <macro>
> <sequence>
> <command name="selectNode" parameter="self co" />
> <match context="$selected" pattern="co" />
> <set variable="attval" context="$selected" expression="@id" />
> <get expression="$attval" plainString="true" />
> <command name="copy" parameter="%_" />
> </sequence>
> </macro>
> </command>
>
>
> [3] clipboard content
>
> <?xml version="1.0"?>
> <ns:clipboard
> xmlns:ns="http://www.xmlmind.com/xmleditor/namespace/clipboard"
>
>><co
>
> id="abcdef"
>
>></co
>></ns:clipboard
>>