It is easier for me to write a macro which does what you want rather
than answering your questions.
I don't have your environment therefore I have written an equivalent
macro which works on my Linux box:
[1] It uses DocBook <phrase> + attribute "id" instead of <ProjektID> +
attribute "ProjektIDRef".
[2] It simulates "/usr/local/bin/IF2mapleSocket
get_projektlist_xxe_pick_arg()" with an awk script acting on file
fruits.txt.
[3] It simulates "usr/local/bin/IF2mapleSocket prjid2prjname(%_)" with
another awk script acting on file fruits.txt.
The macro:
---
<cfg:command name="getprjrefid">
<cfg:macro>
<cfg:sequence>
<cfg:command name="selectNode" parameter="self[implicitElement]
phrase"/> ***1***
<cfg:command name="run"
parameter="awk -F ',' -- '{ print $1 }'
/home/hussein/tmp/fruits.txt"/>
<cfg:command name="pick" parameter="'Choose a fruit' false %_"/>
<cfg:command name="putAttribute" parameter="id %_"/>
<cfg:command name="get" parameter="./@id"/>
<cfg:command name="run"
parameter="awk -F ',' -- '/%_/ { print $2 }'
/home/hussein/tmp/fruits.txt"/>
<cfg:command name="getprjrefid2" parameter='"%_"'/>***2***
</cfg:sequence>
</cfg:macro>
</cfg:command>
<cfg:command name="getprjrefid2">
<cfg:macro>
<cfg:sequence>
<cfg:command name="selectNode" parameter="firstChild"/>***3***
<cfg:command name="insertString" parameter="ANYTHING"/>***4***
<cfg:command name="selectText" />***5***
<cfg:command name="paste" parameter="to %0"/>***6***
</cfg:sequence>
</cfg:macro>
</cfg:command>
---
***1*** This ensures that the macro only works if a <phrase> is
implicitely or explicitely selected.
***2*** Splitting the macro in 2 parts allows to reference what has been
returned by second awk script in getprjrefid2 as %0. This is a
workaround for the fact that XXE macros have no variables (this will
change real soon now).
***3*** This selects the text node contained in the <phrase>.
***4*** This ensures that this text node is not empty.
***5*** This selects all the text contained in the <phrase>.
***6*** This replaces all the text contained in the <phrase> by what has
be returned by the second awk script.
Et voil?!
Attached files are:
* docbook.xxe (DocBook customization file containing the macro) which
must be copied to ~/.xxe2/config
* fruits.txt which must be copied *somewhere* and after this, replace
/home/hussein/tmp/fruits.txt by *somewhere*/fruits.txt in the macro.
To test this macro in DocBook, open a DocBook document, insert a
<phrase> and press F2. And you can do that several times for the same
<phrase>.
thye wrote:
>
> I have a text mode <ProjektID ProjektIDRef="xxx">TEXT</ProjektID>
>
> in css I bound a command button on this node to execute the following
> command:
>
>
> <!-- show a generated Project-menulist via pick
> ask maple-server and insert the id in attribute
> ask maple-server for a the associated name of the id
> and insert the name in the text-field -->
>
> <cfg:command name="getprjrefid">
> <cfg:macro>
> <cfg:sequence>
> <cfg:command name="selectNode" parameter="self"/>
> <cfg:command name="run" parameter='/usr/local/bin/IF2mapleSocket
> "with(PJVerw)"'/>
> <cfg:command name="run" parameter='/usr/local/bin/IF2mapleSocket
> "get_projektlist_xxe_pick_arg()"'/>
> <cfg:command name="pick" parameter='%_'/>
> <cfg:command name="putAttribute" parameter="ProjektIDRef %_"/>
>
> <cfg:choice>
> <cfg:sequence>
> <cfg:command name="selectText"/>
> <cfg:command name="delete" parameter="[implicitElement]"/>
> </cfg:sequence>
> </cfg:choice>
>
> <cfg:command name="get" parameter="[implicitElement] ./@ProjektIDRef"/>
> <cfg:command name="run" parameter='/usr/local/bin/IF2mapleSocket
> "prjid2prjname(%_)"'/>
> <cfg:command name="insertString" parameter="%_"/>
> </cfg:sequence>
> </cfg:macro>
> </cfg:command>
>
>
> IF2mapleserver is a shell-tool to make a conection to a socket.
>
> There 3 steps in the macro:
> 1. get a list (via server)
> pick an item from the list and insert the ID in the
> attribute from the node
> 2. CLEAN the text-field
> 3. connect again to the server and get the name of the
> priviusly selected ID
> insert this name in the text-field:
>
>
> This macro does not work very well, somtimes (dependig on the
> previusly selected nodes otherwise it works not, somtimes it works?
>
> My questions are:
> 1.) is there a simpler way to delete the text-node before inserting new text
> 2.) why this macor works only sometimes?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: docbook.xxe
Type: text/xml
Size: 525 bytes
Desc: not available
Url :
http://www.xmlmind.com/pipermail/xmleditor-support/attachments/20040402/65db62b5/attachment.xml
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: fruits.txt
Url:
http://www.xmlmind.com/pipermail/xmleditor-support/attachments/20040402/65db62b5/attachment.txt