Dynamic transformation of CustomXML in Word 2003/2007 by inserting new XML nodes.

M

mario.latzig

Hello,

we are using MS Word 2007 Beta2 TR (for testing) and MS Word 2003 and
we want to use Word as a kind of XML editor for our document-based XML
format. The customXML data looks like:

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="1.xsl"?>
<section xmlnumber="11" xmlns="http://www.kgu.com/XSD">
<title>blubb</title>
<component xmlnumber="12">
<title>test1</title>
<para>Dies ist ein Test</para>
</component>
<component xmlnumber="13">
<title>test2</title>
<para>Dies ist der 1. Test</para>
<para>Dies ist der 2. Test</para>
</component>
</section>

I have created a XSLT file by using the WML2XSLT tool and by writing an
own test file. The XSLT is e.g. used for formatting the title tags by
WordML. The CustomXML data is not removed in the tranformed document
word document. It is embedded as CustomXML by the opened word document.
Now we can edit the XML data and save back the XML data by the "data
only" flag in the "Save As" dialog.

But e.g. if we insert new "component" nodes with titles, the new nodes
are not transformed and replaced with formatted styles, because Word
transform only while opening and savin files.

I have found out, that there is an event in VBA
"Document_XMLAfterInsert", where we can use the "TransformDocument"
method on the document instance to re-transform the current XML data.
Then the whole document is replaced by the transformed content. The
disadvantage is also, that the whole Word application is crashed down
by a "Copy & Paste" action (maybe cause of using beta version of Word
2007). The "InsertXML" on the Range object does not work correctly,
too.

Is there a solution to add new XML nodes while editing Word by adding
automatically the formatted styles (of a given XSLT)?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top