/// <summary>
        /// Boxes any Object The Implements the IContentObjectInterface into a DE Content Object
        /// </summary>
        /// <param name="imsg">Object That Implements the IContentObject Interface</param>
        /// <returns>Boxed IContentObject Message in a DE Content Object</returns>
        /// <exception cref="ArgumentNullException">ismg is null</exception>
        /// <seealso cref="ContentObject"/>
        public static ContentObject Box(IContentObject imsg)
        {
            if (imsg == (IContentObject)null)
            {
                throw new ArgumentNullException("Input Object Can't Be Null");
            }

            ContentObject contentobj = new ContentObject();
            ValueList     ckw        = new ValueList();

            ckw.ValueListURN = EDXLConstants.ContentKeywordListName;
            contentobj.ContentDescription = imsg.SetContentKeywords(ckw);
            contentobj.ContentKeyword.Add(ckw);
            XMLContentType    xcontent  = new XMLContentType();
            StringBuilder     sb        = new StringBuilder();
            XmlWriterSettings xsettings = new XmlWriterSettings();

            xsettings.CloseOutput        = true;
            xsettings.Encoding           = Encoding.UTF8;
            xsettings.Indent             = true;
            xsettings.OmitXmlDeclaration = true;
            XmlWriter xwriter = XmlWriter.Create(sb, xsettings);

            imsg.WriteXML(xwriter);
            xwriter.Flush();
            xwriter.Close();
            string s = sb.ToString();

            sb = null;

            // imsg.ValidateToSchema(s);
            XElement xe = XElement.Parse(s);

            xcontent.EmbeddedXMLContent.Add(xe);
            contentobj.XMLContent = xcontent;
            ckw      = null;
            xcontent = null;
            xwriter  = null;

            return(contentobj);
        }
        /// <summary>
        /// Reads This ContentObject From An Existing XML Document
        /// Fails if XML Document is not a valid Content Object
        /// </summary>
        /// <remarks>
        /// A Content Object is considered invalid if does not contain exactly one of the two content formats:
        /// <list type="number">
        ///     <item>
        ///         <term>xmlContent</term> <description>Valid namespace XML content.</description>
        ///     </item>
        ///     <item>
        ///         <term>nonXMLContent</term>
        ///         <description>Contains one or both of the elements uri, for reference to the content’s location,
        ///         and contentData, for data encapsulated in the message.</description>
        ///     </item>
        /// </list>
        /// </remarks>
        /// <param name="rootnode">Node That Points to the Element</param>
        /// <exception cref="ArgumentNullException">Content Object has no content or is missing required element</exception>
        /// <exception cref="ArgumentException">Content Object has both xmlContent AND nonxmlContent or there are nodes with invalid values</exception>
        /// <exception cref="FormatException">An invalid node was found</exception>
        public void ReadXML(XmlNode rootnode)
        {
            this.contentKeyword.ReadXML(rootnode);
            this.consumerRole.ReadXML(rootnode);
            this.originatorRole.ReadXML(rootnode);

            foreach (XmlNode node in rootnode.ChildNodes)
            {
                ////This check is for xml objects that have attribs only (no innertext) like CoT
                if (node.LocalName == "xmlContent" && string.IsNullOrEmpty(node.InnerXml))
                {
                    continue;
                }
                else if (node.LocalName != "xmlContent" && string.IsNullOrEmpty(node.InnerText))
                {
                    continue;
                }

                switch (node.LocalName)
                {
                case "contentDescription":
                    this.contentDescription = node.InnerText;
                    break;

                case "contentKeyword":
                    break;

                case "incidentID":
                    this.incidentID = node.InnerText;
                    break;

                case "incidentDescription":
                    this.incidentDescription = node.InnerText;
                    break;

                case "originatorRole":
                    break;

                case "consumerRole":
                    break;

                case "confidentiality":
                    this.confidentiality = node.InnerText;
                    break;

                case "nonXMLContent":
                    this.nonXMLContent = new NonXMLContentType();
                    this.nonXMLContent.ReadXML(node);
                    break;

                case "xmlContent":
                    this.xmlContent = new XMLContentType();
                    this.xmlContent.ReadXML(node);
                    break;

                case "#comment":
                    break;

                default:
                    XElement xe = XElement.Load(new XmlNodeReader(node));
                    this.other.Add(xe);
                    break;
                }
            }

            this.Validate();
        }