Hi,

thanks a lot for the tip. 

Now for everybody who is interested in this is the command which changes a 
chapter or a section in a reference which is automatically created: 

  <command name="change-to-reference">
    <macro trace="true">
      <sequence>
        <command name="selectNode" 
parameter="ancestorOrSelf[implicitElement] chapter section" />
        <command name="confirm" parameter="Do you really want ...?" />
        <command name="selectFile" parameter="saveFile 
%p\..\docs-parts\*.xml" /> 
        <set variable="filename-new" expression="%_" plainString="true" />
        <get expression="$filename-new" />
        <command name="copy-docu" parameter="%_" />
        <command name="copyToClipboard" parameter="[clipboard] %_" /> 
        <get expression="$filename-new" />
        <get expression="relativize-uri('file:///%_')" /> 
        <set variable="filename-new" expression="%_" plainString="true" />
        <get expression="$filename-new" />
          <command name="include" parameter="replace %_" /> 
      </sequence>
    </macro>
  </command>

  <command name="copy-docu">
    <process>
      <copyDocument to="%0" 
          selection = "true" 
          preserveEntityRefs = "false"
          preserveXIncludes = "true"
          indent="true" 
          encoding="ISO-8859-1" />
      <read file="%0" encoding="ISO-8859-1" />
    </process>
  </command>

  <binding>
    <keyPressed code="R" modifiers="alt" />
    <command name="change-to-reference" />
  </binding> 

PS: maybe that anybody can write it even shorter or simpler.

Best Regards
Peter Schulte



Hussein Shafie <hussein at xmlmind.com> 
Gesendet von: xmleditor-support-bounces at xmlmind.com
18.11.2005 14:04
Bitte antworten an
xmleditor-support at xmlmind.com


An
Peter.Schulte at gad.de
Kopie
xmleditor-support at xmlmind.com
Thema
[XXE] Re: command with node selection on 2nd Edit






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>
> 
> 
 
--
XMLmind XML Editor Support List
xmleditor-support at xmlmind.com
http://www.xmlmind.com/mailman/listinfo/xmleditor-support

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://www.xmlmind.com/pipermail/xmleditor-support/attachments/20051123/36fe9b72/attachment.htm
 

Reply via email to