none
Empty numbering.xml FileTrips Up Word

    Question

  • Hello,

    I am working on a SharePoint solution which will convert submitted InfoPath forms to Word documents by way of an event receiver. I have started by building a simpler solution without the SharePoint overhead. The form has a button with a clicked event that invokes my Open XML SDK 2.0/C# code.

    A docx file is generated, which when opened with Word, produces this warning:

    If I click OK, a second dialogue pops up, with the message:

    • Word found unreadable content in generated.docx. Do you want to recover the contents of this document? If you trust the source of this document, click Yes.

    If I click Yes here, the document opens, and looks fine. Poking into the docx file, I find that numbering.xml is empty, which explains why Word thinks it is not well-formed. Looking at other files I am working with, I find that many do not have a numbering.xml file, at all.

    I would appreciate any thoughts on how to approach this.


    Echo Train Nashville TN



    • Edited by Echo Train Thursday, January 31, 2013 10:41 PM
    Thursday, January 31, 2013 10:19 PM

Answers

  • Hi Echo Train

    OK, I'm not at all familiar with the Library you're using (InfoPathToWordLib.InfoPathToWord)... But I'll try my best to at least get things going in the right direction.

    As far as Word is concerned, bullets and numbering are the same. It's just when paragraphs are numbered they start with numbers that increment and when they're bulleted they start with the bullet symbol. That's the only difference.

    So Bullet definitions are also saved in numbering.xml. If you need bullets, you need numering.xml.

    Beyond that, there's not a lot I can do to help you because I don't work with the library you're using. And I've never worked on reading or defining the content of numbering.xml before. This, for example, is meaningless to me:
     Paragraph par = InfoPathToWord.CreateListParagraph(
                             listItems
    .Current.Value, InfoPathToWord.ListStyle.Bullets);

    I can guess what that's supposed to do, and it makes the impression that it should be taking care of making the bullets for you. So if it's not doing that, then you perhaps need to ask in a forum that supports this library.

    If it turns out you have to do it yourself then your next step should be to create a Word document with the basic formatting you want to have (type in a couple of lines, format them with bullets, save the document, close it, then look at how numbering.xml is constructed).

    You'll find this article useful : http://msdn.microsoft.com/en-us/library/ee922775(office.14).aspx and possibly this discussion: http://openxmldeveloper.org/discussions/development_tools/f/35/t/5169.aspx


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by Echo Train Friday, February 01, 2013 9:04 PM
    Friday, February 01, 2013 5:31 PM
    Moderator
  • Thanks very much for taking the time to help me with this. Your reply got me thinking from a fresh perspective, and the first link was very helpful in understanding what was supposed to happen. There is quite a bit of information in that section of the MSDN that helped me get a broader perspective on what I was trying to do.

    As I said, this is my first experience with the Open XML SDK. I had picked up a project that had been started by someone else, and I soon realized I was in the deep end.

    For anyone who winds up here searching on the same problem, it turned out that I had a stubbed method specific to bulleted and numbered lists which required some document specific code generated by reflecting the Word template with the SDK Productivity Tool. If there was ever any code there, it was gone before I got involved. Hence, the present, but empty numbering.xml file. 


    Echo Train Nashville TN



    • Marked as answer by Echo Train Friday, February 01, 2013 9:06 PM
    • Edited by Echo Train Friday, February 01, 2013 9:08 PM
    Friday, February 01, 2013 9:03 PM

All replies

  • Hi Echo Train

    It is possible to generate a basic Word document without including a numbering.xml file in the "package". As long as the document doesn't apply any automatic numbering, it is not required. See also for the minimum requirement for a Word document:
      http://msdn.microsoft.com/en-us/library/ff478190.aspx


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, February 01, 2013 7:31 AM
    Moderator
  • Thank you for your reply. My form has a bulleted list, which is rendering as a numbered list in the Word document. Here is that part of the embedded code:

                        sdtList = InfoPathToWordLib.InfoPathToWord.GetContentControl(
                          mainPart.Document, "bulletedlist");
                        InfoPathToWordLib.InfoPathToWord.AddBulletedList("rId200", iter2, ref sdtList,
                          ref mainPart);

    Here is the method it calls:

            public static void AddBulletedList(string id, XPathNodeIterator listItems,
              ref List<OpenXmlElement> sdtList, ref MainDocumentPart mainPart)
            {
                NumberingDefinitionsPart numDefPart =
                InfoPathToWord.AddNumberingDefinitionsPart(id, ref mainPart);
                if (sdtList.Count != 0)
                {
                    foreach (OpenXmlElement sdt in sdtList)
                    {
                        OpenXmlElement parent = sdt.Parent;
                        while (listItems.MoveNext())
                        {
                            Paragraph par = InfoPathToWord.CreateListParagraph(
                              listItems.Current.Value, InfoPathToWord.ListStyle.Bullets);
                            parent.InsertBefore(par, sdt);
                        }
                        sdt.Remove();
                    }
                }
            }
    This is my first foray into the Open XML SDK, and I am trying to find my way. Clearly, I have something wrong, but I haven't been able to put my finger on it. If I need the numbering.xml file, why is it empty? If not, why is it showing up at all?

    Echo Train Nashville TN


    • Edited by Echo Train Friday, February 01, 2013 2:24 PM
    Friday, February 01, 2013 2:23 PM
  • Hi Echo Train

    OK, I'm not at all familiar with the Library you're using (InfoPathToWordLib.InfoPathToWord)... But I'll try my best to at least get things going in the right direction.

    As far as Word is concerned, bullets and numbering are the same. It's just when paragraphs are numbered they start with numbers that increment and when they're bulleted they start with the bullet symbol. That's the only difference.

    So Bullet definitions are also saved in numbering.xml. If you need bullets, you need numering.xml.

    Beyond that, there's not a lot I can do to help you because I don't work with the library you're using. And I've never worked on reading or defining the content of numbering.xml before. This, for example, is meaningless to me:
     Paragraph par = InfoPathToWord.CreateListParagraph(
                             listItems
    .Current.Value, InfoPathToWord.ListStyle.Bullets);

    I can guess what that's supposed to do, and it makes the impression that it should be taking care of making the bullets for you. So if it's not doing that, then you perhaps need to ask in a forum that supports this library.

    If it turns out you have to do it yourself then your next step should be to create a Word document with the basic formatting you want to have (type in a couple of lines, format them with bullets, save the document, close it, then look at how numbering.xml is constructed).

    You'll find this article useful : http://msdn.microsoft.com/en-us/library/ee922775(office.14).aspx and possibly this discussion: http://openxmldeveloper.org/discussions/development_tools/f/35/t/5169.aspx


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by Echo Train Friday, February 01, 2013 9:04 PM
    Friday, February 01, 2013 5:31 PM
    Moderator
  • Thanks very much for taking the time to help me with this. Your reply got me thinking from a fresh perspective, and the first link was very helpful in understanding what was supposed to happen. There is quite a bit of information in that section of the MSDN that helped me get a broader perspective on what I was trying to do.

    As I said, this is my first experience with the Open XML SDK. I had picked up a project that had been started by someone else, and I soon realized I was in the deep end.

    For anyone who winds up here searching on the same problem, it turned out that I had a stubbed method specific to bulleted and numbered lists which required some document specific code generated by reflecting the Word template with the SDK Productivity Tool. If there was ever any code there, it was gone before I got involved. Hence, the present, but empty numbering.xml file. 


    Echo Train Nashville TN



    • Marked as answer by Echo Train Friday, February 01, 2013 9:06 PM
    • Edited by Echo Train Friday, February 01, 2013 9:08 PM
    Friday, February 01, 2013 9:03 PM
  • Glad you were able to track down the source of the problem and solve it :-) For someone who's never worked with the Open XML sDK before I'd say you're doing quite well!

    Cindy Meister, VSTO/Word MVP, my blog

    Saturday, February 02, 2013 8:13 AM
    Moderator
  • I recognize both the code and the library that it came from. This was originally sourced from S.Y.M. Wong-A-Ton's InfoPath 2010 Cookbook 3.

    Since you're now maintaining it, that may provide a useful reference/resource for you to work on it and any other projects you have now inherited. Good luck!

    Tuesday, February 12, 2013 4:25 PM