none
Word 2007: w:customXML and w:altChunk: can they co-exist? RRS feed

  • Question

  • Hi,
    We generate Word 2007 document from the system by pulling content from several word 2007 documents. We achieve this by using w:altChunk. This works fine. We also want to wrap the w:altChunk entries with custom tags(w:customXml) which enables our processing when the word document is passed back to us.  But it seems like the combination of w:customXml and w:altChunk is not handled by Word 2007 properly.

    Details:
    If we have the following:
         <w:customXml w:element="SectionsAndClauses">
          <w:customXml w:element="SectionTitleTagStart">
           <w:customXmlPr>
            <w:attr w:name="Id" w:val="100000011325001"/>
            <w:attr w:name="Title" w:val="ASec"/>
            <w:attr w:name="ScnId" w:val=""/>
           </w:customXmlPr>
           <w:p>
            <w:pPr>
             <w:pStyle w:val="Heading2"/>
            </w:pPr>
            <w:r>
             <w:t>ASec</w:t>
            </w:r>
           </w:p>
          </w:customXml>
          <w:customXml w:element="ClauseStart">
           <w:customXmlPr>
            <w:attr w:name="Id" w:val="100000017951004"/>
            <w:attr w:name="Title" w:val="clause 1 display name"/>
            <w:attr w:name="ScnId" w:val="100000011325001"/>
           </w:customXmlPr>
           <w:customXml w:element="ClauseTitleTagStart">
            <w:customXmlPr>
             <w:attr w:name="Id" w:val="100000017951004"/>
             <w:attr w:name="Title" w:val="clause 1 display name"/>
             <w:attr w:name="ScnId" w:val="100000011325001"/>
            </w:customXmlPr>
            <w:p>
             <w:pPr>
              <w:pStyle w:val="ClauseTitle3"/>
             </w:pPr>
             <w:r>
              <w:t>clause 1 display name</w:t>
             </w:r>
            </w:p>
           </w:customXml>
           <w:customXml w:element="ClauseTextTagStart">
            <w:customXmlPr>
             <w:attr w:name="Id" w:val="100000017951004"/>
             <w:attr w:name="Title" w:val="clause 1 display name"/>
             <w:attr w:name="ScnId" w:val="100000011325001"/>
            </w:customXmlPr>
            <w:altChunk r:id="ARTICLE100000017951004"/>
           </w:customXml>
          </w:customXml>
    </w:customXml> 

    In Short we have the customXml tags and altChunk in this hierarchy :
       <SectionsAndClauses>
          <SectionTitleTagStart/>
          <ClauseStart>
             <ClauseTitleTagStart/>
             <ClauseTextTagStart>
                <w:altChunk/>
             </ClauseTextTagStart>
          </ClauseStart>
        </SectionsAndClauses>

    When we open the Word document and enable to see the XML tags using Ctrl+Shift+X, Word shows the xml tags in the "wrong" location. This seems to be because of wrapping w:altChunk within one of the w:customXml; If we don't have w:altChunk, the issue doesn't arise.

    So, to clarify, when we open the document and enable the Xml tags, we see the xml tags in this fashion which is incorrect:
      <ClauseStart>
          <SectionTitleTagStart/>
          <ClauseTitleTagStart>
             <ClauseTitleTagStart/>
             <SectionsAndClauses>
                Content from w:altChunk
             </SectionsAndClauses>
           </ClauseTitleTagStart>
       </ClauseStart>

    instead of:
       <SectionsAndClauses>
          <SectionTitleTagStart/>
          <ClauseStart>
             <ClauseTitleTagStart/>
             <ClauseTextTagStart>
                <w:altChunk/>
             </ClauseTextTagStart>
          </ClauseStart>
        </SectionsAndClauses>

    Basically, the tags get messed up in display. If the user saves the document at that time, the "tags" get saved in the wrong location. If the user closes the document (not word itself) without any changes and reopens the document, then word "figures it out" and shows the tags correctly for that session of Word.

    Is this a known issue? Are there any workarounds/fixes for this..
    Appreciate your help.

    Thursday, May 14, 2009 7:40 PM

All replies

  • Sounds like a bug on Word's end. One potential workaround is to use Content Controls instead of custom xml.

    Zeyad Rajabi
    Zeyad Rajabi (MS)
    Thursday, May 14, 2009 8:53 PM
  • Thanks for taking time to respond. Appreciate it.

    Content Control is not an option for our solution as the user is free to type any text in between. There is no structure to the data that the user can bring in. Also, the user can add new text outside of our tags.

    Would you happen to know if this issue has been reported/logged. Anything else you could suggest...

    Thursday, May 14, 2009 9:03 PM
  • The issue has been reported and we are looking into addressing the issue in Office 14. Have you looked into using bookmarks as well?

    Zeyad Rajabi (MS)
    Thursday, May 14, 2009 10:34 PM
  • Thanks for the update. We will check and see if we could use bookmarks as a workaround for now.
    Friday, May 15, 2009 10:12 AM