Peter.Schulte at gad.de wrote:
>
> Hi,
>
> while migrating our macro commands from XMLmind 3.2.0 to 4.1.0 I have
> some problem with the recent version of the "include"-command.
>
> We use the following command "change-to-reference" for modularizing an
> document being edited:
>
> <command name="change-to-reference">
> <macro>
> <sequence>
> <command name="selectNode"
> parameter="ancestorOrSelf[implicitElement] chapter section appendix" />
> <command name="confirm" parameter="Do you really want to ..." />
> <command name="selectFile" parameter="saveFile
> %p\..\docs-teile\*.xml" />
> <set variable="filename-new" expression="%_" plainString="true" />
> <get expression="$filename-new" />
> <command name="copy-docu" parameter="%_" />
> <set variable="clipboard" expression="%_" plainString="true" />
> <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 = "true"
> preserveXIncludes = "true"
> indent="true"
> encoding="ISO-8859-1">
> <resources match=".*" />
> </copyDocument>
> <read file="%0" encoding="ISO-8859-1" />
> </process>
> </command>
>
> The command copies the selected chapter, section or appendix into a
> separate file and replaces the selection with the reference to the new
> file.
> If the user selects a chapter or section, which does not have an ID,
> everything works fine. But if it has an ID the user gets the error
> message 'Die Knotenpunkte, identifiziert durch "-" konnten nicht in
> Dokument "..filename.." gefunden werden.' (Translation: the nodes,
> identified by "-" could not be found in document "... filename ...").
> This also happens if I change the command
> <command name="include" parameter="replace %_ " />
> into
> <command name="include" parameter="replace %_ ..ID.." />
>
> That means if I specify the ID of the selection as reference_id.
>
> Remark: In XMLmind 3.2 we used <command name="include"
> parameter="replace[useXInclude] %_" />
>
> What is wrong here? Can you help me?
>
As of XXE v4.1, the include command requires to be passed the URL of a
XML file containing the element to be included and the *identifier* of
the element to be included. Your command never passes to command
"include" the identifier of the element to be included.
Here's my interpretation of your "change-to-reference" command (also
attached to this email):
---
<command name="replace-by-reference">
<macro trace="true">
<sequence>
<test context="$selectedElement"
expression="(local-name(.) = 'chapter' or
local-name(.) = 'section' or
local-name(.) = 'appendix') and ./@id"/>
<command name="confirm" parameter="Replace by reference?"/>
<get context="$selectedElement" expression="./@id"/>
<command name="selectFile"
parameter="saveFile %p/../chapters/%_.xml"/>
<set variable="saveFileName" expression="%_" plainString="true"/>
<get expression="$saveFileName"/>
<command name="save-selection" parameter="%_"/>
<get context="$selectedElement"
expression="concat(uri-or-file-name($saveFileName),
' ', ./@id)"/>
<command name="include" parameter="replace %_"/>
</sequence>
</macro>
</command>
<command name="save-selection">
<process>
<copyDocument selection="true" to="%0"
preserveInclusions="true" saveCharsAsEntityRefs="true"
indent="true" encoding="ISO-8859-1">
<resources match=".*"/>
</copyDocument>
</process>
</command>
<binding>
<keyPressed code="F3"/>
<command name="replace-by-reference"/>
</binding>
---
* The element must be explicitly selected and must have an ID.
* This ID is used to suggest a save filename.
* Removed useless:
<set variable="clipboard" expression="%_" plainString="true" />
* Replaced:
<command name="selectFile"
parameter="saveFile %p\..\docs-teile\*.xml" />
by:
<command name="selectFile"
parameter="saveFile %p/../docs-teile\*.xml" />
because selectFile always expects an URL (that is, not '\' but '/').
* It is now:
preserveInclusions="true" saveCharsAsEntityRefs="true"
and no longer:
preserveEntityRefs = "true" preserveXIncludes = "true"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: customize.xxe
Type: text/xml
Size: 1487 bytes
Desc: not available
Url :
http://www.xmlmind.com/pipermail/xmleditor-support/attachments/20081205/bc7c5851/attachment.xml