Re: adding dtd to a file?
"Madlik, Monika (LNG-VIE)" <[email protected]> Wed, 24 Aug 2022 09:31:02 +0000
| Newsgroups | gmane.editors.xxe.general |
|---|---|
| Message-ID | <PH0PR08MB75539299BBA16645F3C5E6D9E4739@PH0PR08MB7553.namprd08.prod.outlook.com> |
Hi Hussein,
many thanks for your advice! This works really good for me.
But now I have another question. I have to combine the new commands (adding the DTD via XSLT and reloading the file via XXE.open [reopen]) with an existing one.
But after doing the XSL-transformation and the reopening of the file, the second command won't be processed.
My source looks like this:
<cfg:command name="release_pre">
<cfg:macro>
<cfg:sequence>
<cfg:command name="save_with_nbsp"/>
<cfg:command name="release"/>
</cfg:sequence>
</cfg:macro>
</cfg:command>
<cfg:command name="save_with_nbsp">
<cfg:macro>
<cfg:sequence>
<cfg:command name="alert" parameter="IN SAVE NBSP"/> <cfg:command name="selectNode" parameter="ancestorOrSelf[implicitElement] artikel"/>
<cfg:command name="XXE.save" parameter="[ifNeeded]"/>
<cfg:set variable="file_origin" expression="'%d'"/>
<cfg:get expression="$file_origin"/>
<cfg:command name="transform_save_with_nbsp" parameter="%_"/> <cfg:command name="XXE.open" parameter="[reopen]"/>
<cfg:command name="alert" parameter="END SAVE NBSP"/>
</cfg:sequence>
</cfg:macro>
</cfg:command>
<cfg:command name="transform_save_with_nbsp">
<cfg:process showProgress="true">
<cfg:copyDocument selection="true" to="in.xml"/>
<cfg:transform stylesheet="xsl/transform_nbsp.xslt" version="2.0" file="in.xml" to="out.xml" cacheStylesheet="true"/>
<cfg:upload base="%0">
<cfg:copyFile file="out.xml" to="%0"/>
</cfg:upload>
</cfg:process>
</cfg:command>
This works fine and does the transformation but after reloading the file neither the alter nor the second command will be processed.
Can I force the second command ("release"), because it's important for me that this runs in one single step so that the user can't forget about adding the dtd before releasing the file.
Thanks a lot,
Monika
-----Ursprüngliche Nachricht-----
Von: Hussein Shafie <[email protected]>
Gesendet: Freitag, 12. August 2022 09:46
An: Madlik, Monika (LNG-VIE) <[email protected]>
Cc: [email protected]
Betreff: Re: [XXE] adding dtd to a file?
On 8/11/22 14:53, Madlik, Monika (LNG-VIE) wrote:
>
> we are using XMLMind Professional Edition 9.5.1 and I have a question regarding files that have no DTD but should have one.
>
> I have to add a DTD to these files. Is it possible to write a command that saves the currently opened file, adds a dtd (maybe via xslt transformation?) and reloads it in XMLMind, so that the user works on the latest version of this file?
>
The answer is almost certainly YES, but it will not be easy because there is an awful lot of XXE techniques to master.
We won't help you writing or debugging such advanced macro-command (probably invoking a process command) as it is completely out of the scope of normal support.
Some pointers though...
1) The following command is found in
XXE_install_dir/config/addon/docbook/docbook.xxe.
It converts the currently DocBook v4.x document to v5.0 or v5.1 by (A) invoking a XSLT stylesheet called "db4-upgrade.xsl" (part of the DocBook XSL stylesheet distribution) and then (B) opening in XXE the resulting DocBook v5 file using command "XXE.open":
---
<command name="docb.toV5">
<macro>
<sequence>
<set variable="converted" expression="uu:setExtension('%d', 'db5.xml')"
xmlns:uu="java:com.xmlmind.util.URIComponent" />
<get expression="$converted" />
<command name="selectFile"
parameter="[DocBook 5 Save File] saveFileURL %_" />
<set variable="converted" expression="%_" plainString="true" />
<choice>
<sequence>
<test expression="$converted = '%d'" />
<command name="alert"
parameter="Please specify a save file other than
%d" />
</sequence>
<sequence>
<command name="pick"
parameter="'Which DocBook version?'
false '"5.0"' '"5.1"'" />
<set variable="params"
expression="concat('"', $converted, '" ', %_)" />
<get expression="$converted" />
<command name="XXE.saveAs" parameter="%_" />
<get expression="$params" />
<command name="{docb}.convertToV5" parameter="%_" />
<command name="XXE.open" parameter="[reopen]" />
</sequence>
</choice>
</sequence>
</macro>
</command>
<command name="{docb}.convertToV5">
<process showProgress="true">
<copyDocument preserveInclusions="true" to="in.xml">
<!-- Do not copy resources. -->
<resources match=".*" />
</copyDocument>
<transform stylesheet="db4-upgrade.xsl" cacheStylesheet="true"
file="in.xml" to="out.xml">
<parameter name="db5.version">%1</parameter>
</transform>
<upload base="%0">
<copyFile file="out.xml" to="%0" />
</upload>
</process>
</command>
---
2) Relevant documentation:
- Macro-commands:
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.xmlmind.com%2Fxmleditor%2F_distrib%2Fdoc%2Fcommands%2Fmacro.html&data=05%7C01%7CMonika.Madlik%40lexisnexis.at%7Ca0f60ba52f87404fbf7808da7c36b02c%7C9274ee3f94254109a27f9fb15c10675d%7C0%7C0%7C637958871716154938%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=1gRwxLZkNAUEHRlOLOtJm650QYXcTZN22rV8rvhCMxs%3D&reserved=0
- Process commands:
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.xmlmind.com%2Fxmleditor%2F_distrib%2Fdoc%2Fcommands%2Fprocess.html&data=05%7C01%7CMonika.Madlik%40lexisnexis.at%7Ca0f60ba52f87404fbf7808da7c36b02c%7C9274ee3f94254109a27f9fb15c10675d%7C0%7C0%7C637958871716154938%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Ki6hqRnG6M%2FI74ia5aD%2BQQnjt0S878hGj8JLP1uBlVQ%3D&reserved=0
- Command "XXE.open":
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.xmlmind.com%2Fxmleditor%2F_distrib%2Fdoc%2Fcommands%2FXXE.open.html&data=05%7C01%7CMonika.Madlik%40lexisnexis.at%7Ca0f60ba52f87404fbf7808da7c36b02c%7C9274ee3f94254109a27f9fb15c10675d%7C0%7C0%7C637958871716154938%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=bRdCWS5sjPRGqLML1o1%2BTSpX28rGBzv5dNQcqzQ7Vqo%3D&reserved=0
- Easy XPath extension functions (e.g "uu:setExtension"):
https://nam11.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.xmlmind.com%2Fxmleditor%2F_distrib%2Fdoc%2Fxpathsupport%2Fxpathextfunc_java.html&data=05%7C01%7CMonika.Madlik%40lexisnexis.at%7Ca0f60ba52f87404fbf7808da7c36b02c%7C9274ee3f94254109a27f9fb15c10675d%7C0%7C0%7C637958871716154938%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=b6z%2FG%2BZFWANXJ8joAmSTfFQfSzJ8cx330ri450GOggg%3D&reserved=0
--
XMLmind XML Editor Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xmleditor-support