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?

Also, is there a way to change the "context" from the map file to the
new Untitled file? 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?



-----Original Message-----
From: Hussein Shafie [mailto:[email protected]] 
Sent: Monday, March 27, 2006 1:17 AM
To: Mark Fletcher
Cc: xmleditor-support at xmlmind.com
Subject: Re: [XXE] Problem with XXE.saveAs

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.htm
l)
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" />
---




Reply via email to