John L. Clark wrote:
> I am trying to add a menu item for an additional transform for DocBook.
> I am almost fully successful; the only problem I am having is in opening
> the resulting output file. To do this, I have defined two commands: one
> is the actual process which performs the translations, and the other
> asks the user for the output filename, calls the translation, and
> (should) display the result. My motivation for this approach has been a
> combination of both examples at the end of the "command" section of the
> power user documentation.
>
> In particular, I had thought that the "read" process element would set
> "%_" (because it seems that that is what the "toSimpara" command does in
> example 1), and I had thought that XXE.edit opens a new file view on its
> parameter (if not already open). When I run/select my command, though,
> the most recent line of the command history indicates that the "read"
> took place, but says nothing about the edit.
>
> It's not entirely clear to me what exactly "read" should do given the
> documentation ("Loads the contents of specified text file"). Loads it
> to where? Does it or does it not set %_? If so, to what?
"read" loads the *content* of specified text file and returns it as its
result.
"%_" is the result of last executed command in a macro-command. This
means that each command executed inside a macro-command sets "%_". This
also means that commands which does not return a result (most commands
do not return a result) clears "%_" (that is, it sets it to void).
> I've included my configuration file so that you can see the details.
> Alternate approaches to the same end would be welcome.
> <?xml version="1.0" encoding="UTF-8"?>
> <cfg:configuration name="DocBook"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns:cfg="http://www.xmlmind.com/xmleditor/schema/configuration">
> <cfg:include location="docbook/docbook.xxe" system="true" />
> <cfg:command name="docbook.translateChanges">
> <cfg:process>
> <cfg:copyDocument to="in.xml"></cfg:copyDocument>
> <cfg:transform file="in.xml" stylesheet="xsl/change.xsl"
> to="out.xml"></cfg:transform>
> <cfg:upload base="file:///">
> <cfg:copyFile file="out.xml" to="%0" />
> </cfg:upload>
> <cfg:read file="%0" />
> </cfg:process>
> </cfg:command>
> <cfg:command name="docbook.integrateVersioning">
> <cfg:macro>
> <cfg:sequence>
> <cfg:command name="selectFile" parameter="saveFile" />
> <cfg:command name="docbook.translateChanges" parameter=""%_""
> />
> <cfg:command name="XXE.edit" parameter=""%_"" />
> </cfg:sequence>
> </cfg:macro>
> </cfg:command>
> <cfg:menu label="DocBook" mnemonic="D">
> <cfg:insert />
> <cfg:item command="docbook.integrateVersioning"
> label="Merge Internal Changes" mnemonic="M"></cfg:item>
> </cfg:menu>
> </cfg:configuration>
The trick is to split your docbook.integrateVersioning macro in 2
pieces: docbook.integrateVersioning and docbook.doIntegrateVersioning
Also note that I have removed useless "<cfg:read file="%0" />" at the
end of docbook.translateChanges.
---
<?xml version="1.0" encoding="UTF-8"?>
<cfg:configuration name="DocBook"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:cfg="http://www.xmlmind.com/xmleditor/schema/configuration">
<cfg:include location="docbook/docbook.xxe" system="true" />
<cfg:command name="docbook.translateChanges">
<cfg:process>
<cfg:copyDocument to="in.xml"></cfg:copyDocument>
<cfg:transform file="in.xml" stylesheet="xsl/change.xsl"
to="out.xml"></cfg:transform>
<cfg:upload base="file:///">
<cfg:copyFile file="out.xml" to="%0" />
</cfg:upload>
</cfg:process>
</cfg:command>
<cfg:command name="docbook.doIntegrateVersioning">
<cfg:macro>
<cfg:sequence>
<cfg:command name="docbook.translateChanges" parameter="'%0'" />
<cfg:command name="XXE.edit" parameter="'%0'" />
</cfg:sequence>
</cfg:macro>
</cfg:command>
<cfg:command name="docbook.integrateVersioning">
<cfg:macro>
<cfg:sequence>
<cfg:command name="selectFile" parameter="saveFile" />
<cfg:command name="docbook.doIntegrateVersioning"
parameter="'%_'" />
</cfg:sequence>
</cfg:macro>
</cfg:command>
<cfg:menu label="DocBook" mnemonic="D">
<cfg:insert />
<cfg:item command="docbook.integrateVersioning"
label="Merge Internal Changes" mnemonic="M"></cfg:item>
</cfg:menu>
</cfg:configuration>
---