Mark Fletcher wrote: > I'm trying to use XXE.saveAs in a command macro and it's failing for > some reason. Can anyone see what I'm doing wrong here? > > > <command name="createNewFile"> > > <macro> > > <sequence> > > <command name="pick" parameter="'Choose the type of DITA file to create' > true 'Concept' 'dita_concept_template.xml' 'Reference' > 'dita_reference_template.xml' 'Task' 'dita_task_template.xml' 'Wrapper > (multi-topic) ' 'ditabase_template.xml'"/> > > <set variable="templateName" expression="%_" plainString="true"/> > > <get expression="$templateName"/> > > <command name="alert" parameter="%_"/> > > <get expression="$templateName"/> > > <command name="XXE.openCopy" parameter="file:///c:/program > files/xmlmind_xml_editor/addon/config/dita/template/%_"/> > > <command name="alert" parameter="pre-save"/> > > <command name="XXE.saveAs"/> > > <command name="alert" parameter="post-save"/> > > </sequence> > > </macro> > > </command> > > > When I run this, it only gets to the "pre-save" alert. The "Save File" > dialog never appears and processing stops. The file that is opened > during XXE.openCopy is valid, so no problems there. >
The reasons are quite obscure: * XXE.openCopy (http://www.xmlmind.com/xmleditor/_distrib/doc/commands/XXE.openCopy.html) opens a copy of specified document in XXE and immediately makes it the ``active document'' (AKA current document, document being edited, etc). Let's say this command opens "/tmp/Untitled2.dita". * Command XXE.saveAs (http://www.xmlmind.com/xmleditor/_distrib/doc/commands/XXE.saveAs.html), like all commands, is executed in the context of a document view. Let's say the user has invoked your macro from within a view of "/home/mark/MyTopic.dita". Well, XXE.saveAs refuses to be executed because the active document: "/tmp/Untitled2.dita" is different from its context: "/home/mark/MyTopic.dita". There is certainly a reason for that, but I don't remember which one :-( --- PS: Why do you need to do this? Simply define multiple document templates in the configuration and let the user choose one using File|New. Here are the document templates found in the future DITA configuration: --- <template name="Topic" location="template/topic.dita" /> <template name="Concept" location="template/concept.dita" /> <template name="Task" location="template/task.dita" /> <template name="Reference" location="template/reference.dita" /> <template name="Multiple Topics" location="template/dita.dita" /> ---

