private static void TestPartForUnsupportedContent(OpenXmlPart part, int sourceNumber)
 {
     XNamespace[] obsoleteNamespaces = new[]
         {
             XNamespace.Get("http://schemas.microsoft.com/office/word/2007/5/30/wordml"),
             XNamespace.Get("http://schemas.microsoft.com/office/word/2008/9/16/wordprocessingDrawing"),
             XNamespace.Get("http://schemas.microsoft.com/office/word/2009/2/wordml"),
         };
     XDocument xDoc = part.GetXDocumentWithTracking();
     XElement invalidElement = xDoc.Descendants()
         .FirstOrDefault(d =>
             {
                 bool b = d.Name == W.subDoc ||
                     d.Name == W.control ||
                     d.Name == W.altChunk ||
                     d.Name.LocalName == "contentPart" ||
                     obsoleteNamespaces.Contains(d.Name.Namespace);
                 bool b2 = b ||
                     d.Attributes().Any(a => obsoleteNamespaces.Contains(a.Name.Namespace));
                 return b2;
             });
     if (invalidElement != null)
     {
         if (invalidElement.Name == W.subDoc)
             throw new DocumentBuilderException(String.Format("Source {0} is unsupported document - contains sub document",
                 sourceNumber));
         if (invalidElement.Name == W.control)
             throw new DocumentBuilderException(String.Format("Source {0} is unsupported document - contains ActiveX controls",
                 sourceNumber));
         if (invalidElement.Name == W.altChunk)
             throw new DocumentBuilderException(String.Format("Source {0} is unsupported document - contains altChunk",
                 sourceNumber));
         if (invalidElement.Name.LocalName == "contentPart")
             throw new DocumentBuilderException(String.Format("Source {0} is unsupported document - contains contentPart content",
                 sourceNumber));
         if (obsoleteNamespaces.Contains(invalidElement.Name.Namespace) ||
             invalidElement.Attributes().Any(a => obsoleteNamespaces.Contains(a.Name.Namespace)))
             throw new DocumentBuilderException(String.Format("Source {0} is unsupported document - contains obsolete namespace",
                 sourceNumber));
     }
 }