On 11/28/2011 12:35 PM, Yves Forkl wrote:
>
> With the following command definition, XXE only returns the result as "output 
> of command", but does not substitute the original document version:
>
> <command name="mytransform">
>    <process showProgress="false">
>      <copyDocument to="TMP_in.xml" />
>      <transform stylesheet="mytransform.xsl"
>        version="2.0"
>        file="TMP_in.xml" to="TMP_out.xml" />
>      <read file="TMP_out.xml" encoding="UTF-8" />
>    </process>
> </command>

Please note that recent versions of XXE allow to embed an XSLT 
stylesheet in a <macro>, which is often simpler and more efficient than 
<process showProgress="false">.

See 
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/macro_reference.html



>
> I have observed that if in-place transformation is restricted to a selected 
> node (of course with<copyDocument selection="true" to="TMP_in.xml" />), 
> substitution works fine.
>
> Remembering that the root element can't be replaced in XXE through the Edit 
> menu, I wonder if this restriction also applies if the name and attributes of 
> the root element remain unchanged in the results of command transform.
>

Yes, that right. This restriction applies always.



> (At least, this limitation of command transform is not mentioned in the docs:
> http://www.xmlmind.com/xmleditor/_distrib/doc/commands/transform.html )
>
> How could I manage to transform my document in-place (or make it seem as if 
> it happened that way)?
>

You could do something like this (not tested, not 100% sure):

1) Your XSLT stylesheet must generate multiple nodes using XXE's 
clipboard format.

XXE's clipboard format is not documented, so you'll have to guess how it 
works. Fortunately, this is very easy (unless you generate inclusions).

Example: A sequence of 3 DocBook 5 para elements:
---
<?xml version="1.0" encoding="UTF-8"?>
<ns:clipboard
   xmlns:ns="http://www.xmlmind.com/xmleditor/namespace/clipboard";
   xmlns:db="http://docbook.org/ns/docbook";>

   <db:para>Paragraph #1.</db:para>

   <db:para>Paragraph #2.</db:para>

   <db:para>Paragraph #3.</db:para>

</ns:clipboard>
---

2) After loading what's generated by your XSLT stylesheet using <read>, 
copy the loaded string to a variable.

---
<set variable="rootContents"
      expression="%_" plainString="true"/>.
---

3) Then select all the child nodes of the root element.

4) Finally paste the contents of variable rootContents in order to 
replace all the the child nodes of the root element.

----
<get expression="$rootContents" />
<command name="paste"
          parameter="to %_" />
----

See 
http://www.xmlmind.com/xmleditor/_distrib/doc/commands/macro_reference.html

See http://www.xmlmind.com/xmleditor/_distrib/doc/commands/paste.html


 
--
XMLmind XML Editor Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xmleditor-support

Reply via email to