Hi,
I am asking this here in addition to the vstools.office group because i
think the issue could possibly be schema or serilazation related...
i have a word document which has a custom schema attached whose target
namespace is "com.test.mynamespace". I am trying to insert some xml
into the word document using Range.InsertXML. I get the xml to insert
by serializing an object. the xml after serialization of my object
looks like this:
<data xmlns:ts="com.test.mynamespace">
<people>
<person id="1234">
<ts:name>Test User</ts:name>
<ts:email>emailaddr1</ts:email>
</person>
<person id="5678">
<ts:name>Test User1</ts:name>
<ts:email>emailaddr2</ts:email>
</person>
</people>
<places>
<place id="1234">
<ts:name>Somewhere 1</ts:name>
</place>
<place id="5678">
<ts:name>Somewhere2</ts:name>
</place>
</places>
So the first question is why after serializing my object, does certain
elements have a prefix, and others don't?
The second issue is, after inserting the above XML into my Word
document, i look at the underlying WordML and the xml i inserted looks
like this (note, i am not showing the superfluous WordML that surrounds
the nodes for clarity
sake):
<data>
<person >
<person id="1234">
<ns2:name>Test User</ns2:name>
<ns2:email>emailaddr1</ns2:email>
</person>
<person id="1234">
<ns2:name>Test User</ns2:name>
<ns2:email>emailaddr2</ns2:email>
</person>
</people>
<places>
<place id="1234">
<ns2:name>Somewhere 1</ns2:name>
</place>
<place id="1234">
<ns2:name>Somewhere2</ns2:name>
</place>
</places>
All elements are valid and in my schema.
Notice that the namespace is gone from the top level element, but that
an "ns2" alias is added to some elements. "ns2" is an alias for my
name space in the Word document. But i don't understand why only some
elements are marked as "ns2" (equivalent to the "ts" alias)...My
question is, why is the top level namespace being thrown out? This is
creating difficulties in transforming this xml, as my stylesheet is
unable to find the "data" element.
Any help would be appreciated and i can provide more details as
necessary (i realize it is a long post already, so i have left out the
code and shema definition for now)