McGuire, Mike wrote:
operation. Thanks.
>
> In regards to the more automated solution, I cobbled together the
> following:
>
> <binding>
> <keyPressed code="F5" />
> <command name="pickId" />
> </binding>
>
>
> <command name="pickId">
> <macro>
> <sequence>
> <command name="selectFile" parameter="openFileURL
> %d"/>
> <set variable="url" expression="%_" plainString="true"
> />
> <get expression="$url" />
> <get expression="join(document('%_')//@id,' ')" />
> <command name="pick" parameter="'Choose ID' false %_"
> />
> <set variable="myId" expression="$%_"
> plainString="true" />
> <get expression="concat($url, '#', $myId)" />
>
> <command name="putAttribute" parameter="href '%_'" />
> </sequence>
> </macro>
> </command>
>
> This does roughly what I wanted (in a prototype form) but I would still
> like to get the path to be made relative and to list the information in
> the picker using the descriptive title of the element that's connected
> to the ID, but paste in the ID itself. From my rough reading of the
> docs, it seems that both possibilities should be achievable. The more I
> read the docs, the more I see how expandable the program has been made.
>
What follows is your macro-command with 3 little enhancments:
---
<binding>
<keyPressed code="F5" />
<command name="pickId" />
</binding>
<command name="pickId">
<macro trace="true">
<sequence>
<pass><command name="putAttribute"
parameter="href anything" /></pass>
<command name="selectFile" parameter="openFileURL %d"/>
<set variable="url" expression="%_" plainString="true"/>
<get expression="$url" />
<get expression="join(document('%_')//@id, ' ')" />
<command name="pick" parameter="'Choose ID' false %_"/>
<set variable="myId" expression="%_" plainString="true" />
<get expression="concat(relativize-uri($url, '%d'),'#',$myId)" />
<command name="putAttribute" parameter="href '%_'" />
</sequence>
</macro>
</command>
---
[1] <pass>...</pass> is used to test whether it is possible to add an
href attribute to explicitly selected element.
This makes the macro safer to use.
[2] I've replaced
<set variable="myId" expression="$%_" plainString="true" />
by
<set variable="myId" expression="%_" plainString="true" />
I assumed that the leading "$" was a typo.
[3] I've replaced
<get expression="concat($url,'#',$myId)" />
by
<get expression="concat(relativize-uri($url, '%d'),'#',$myId)" />
relativize-uri is an XPath extension function documented here:
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/xpathextfunc.html
With more efforts, it probably possible to display in the "Choose ID"
picker something more elaborate than a bare list of IDs.