I'm almost sure that what you want to do is feasible with XXE but, in my
opinion, you don't use the right tools:

[1] create a new document which contains the selected chapter or section

--> Your macro should invoke a process command which will save the
selection to a file. You did that. Great, you are using the right tool
for this step!

[2] copy the entire content of the new document as an inclusion to the
clipboard
[3] replace the selected chapter or section in the origin document with
an entity reference from the clipboard to the new document

--> Use command "include" with parameter "replace [...]", and not
"copyAsInclusion"/"pasteInclusionEnabled". See
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/include.html

---
PS: This kind of question should be sent to xmleditor-support at xmlmind.com



Peter Schulte wrote:
> I'm trying to write a command which should do the following:
> 
> - create a new document which contains the selected chapter or section
> - copy the entire content of the new document as an inclusion to the
> clipboard
> - replace the selected chapter or section in the origin document with an
> entity reference
>   from the clipboard to the new document
>  
> Unfortunately my command does not work because the node selection in the
> marked command
> line does not operate on the new document but on the origin document.
> Obviously the document context for the macro command lines is not
> changed when starting
> XXE.edit for the new document.
> Is there any possibility to switch the context to the new document?
> 
> Thanks for any suggestions,
> 
> 
>   <command name="change-to-reference">
>     <macro>
>       <sequence>
>         <command name="selectNode"
> parameter="ancestorOrSelf[implicitElement] chapter section" />
>           <set variable="anchor" expression="$selected" />
>           <set variable="filename-orig" expression="%D"
> plainString="true" />
>         <command name="selectFile" parameter="saveFile file:///c:\*.xml" />
>         <set variable="filename-new" expression="%_" plainString="true" />
>         <get expression="$filename-new" />
>         <command name="copy-docu" parameter="%_" />  
>         <get expression="$filename-new" />
>           <command name="XXE.edit" parameter="%_" />
>           <set variable="selected" expression="/*" />   <<<<<<<<<<<<<<<<<<<
>         <command name="copyAsInclusion"  />  
>         <get expression="$filename-orig" />
>         <command name="XXE.edit" parameter="%_"/>
>           <set variable="selected" expression="$anchor" />
>           <command name="pasteInclusionEnabled" parameter="toOrInto" />
>       </sequence>
>     </macro>
>   </command>
> 
>   <command name="copy-docu">
>     <process>
>         <copyDocument to="%0"
>           selection = "true"
>           preserveEntityRefs = "false"
>           preserveXIncludes = "true"
>           indent="true"
>           encoding="ISO-8859-1" />
>     </process>
>   </command>
> 
>   <binding>
>     <keyPressed code="R" modifiers="alt" />
>     <command name="change-to-reference" />
>   </binding>
> 
> 

Reply via email to