Mark Fletcher wrote:
> Hmm. Well, here's what I'm trying to do. Maybe you can suggest another
> way.
>
> I'm working on a CSS for ditamap. Topicref hrefs are displayed onscreen.
> If an href is unassigned, I display it as "[unassigned]" and want to put
> a command button behind the text that will allow the user to create a
> new concept/task/reference dita file and update the href attribute
> automatically. I haven't seen a programmatic way to show the user the
> File,New dialog. Is there one?
Here's a command which does what you want (I think):
---
<binding>
<keyPressed code="F3" />
<command name="initTopicRef" />
</binding>
<command name="initTopicRef">
<macro>
<sequence>
<pass><command name="putAttribute" parameter="href" /></pass>
<command name="pick"
parameter="'Please choose the type of topic you want to create:'
true
Topic template%Stopic.dita
Concept template%Sconcept.dita
Reference template%Sreference.dita
Task template%Stask.dita " />
<set variable="templateFilename" expression="%_"
plainString="true" />
<command name="selectConvertedFile"
parameter="saveFileWithExtension=dita" />
<set variable="newFileName" expression="%_"
plainString="true" />
<get expression="concat('"',
$templateFilename,
'" "',
$newFileName, '"')" />
<command name="copyTopicTemplate" parameter="%_" />
<get context="$selectedElement"
expression="relativize-uri(uri-or-file-name($newFileName))"
/>
<command name="putAttribute" parameter="href '%_'" />
<get expression="$newFileName" />
<command name="XXE.open" parameter="%_" />
</sequence>
</macro>
</command>
<command name="copyTopicTemplate">
<process showProgress="false">
<copy files="%C%S%0" to="%1" />
</process>
</command>
---
Just one problem with XXE V3.1. uri-or-file-name() is a new XPath
extension function which has been added in V3.2.
Replace:
expression="relativize-uri(uri-or-file-name($newFileName))"
by just:
expression="$newFileName"
if you want to play with this macro.
> Also, is there a way to change the "context" from the map file to the
> new Untitled file?
The above macro does this because it *ends* with an XXE.open.
> What if I write a command that only exists in a
> config file for dita topics and not dita maps, and call that command
> when I want to save the file?
Commands are global to XXE: e.g. a command defined the DocBook
configuration file could invoke a command defined in the XHTML
configuration file.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: initTopicRef.xxe
Url:
http://www.xmlmind.com/pipermail/xmleditor-support/attachments/20060329/9c4d550a/attachment.bat