예제 #1
0
        public static XElement CreateXmlNode(XNamespace Ns, Topic T)
        {
            XElement el = new XElement(Ns + Constants.TOPIC);

            if (!String.IsNullOrEmpty(T.ID))
            {
                el.Add(new XAttribute(Constants.ID, T.ID));
            }
            else
            {
                el.Add(new XAttribute(Constants.ID, Util.Generate_ID()));
            }

            if (!String.IsNullOrEmpty(T.Branch))
            {
                el.Add(new XAttribute(Constants.BRANCH, T.Branch)); //TODO Style ID
            }
            if (!String.IsNullOrEmpty(T.Style))
            {
                el.Add(new XAttribute(Constants.STYLE_ID, T.Style)); //TODO Style ID
            }
            if (!String.IsNullOrEmpty(T.Structure_Class))
            {
                el.Add(new XAttribute(Constants.STRUCTURE_CLASS, T.Structure_Class));
            }

            if (T.Timestamp == 0)
            {
                el.Add(new XAttribute(Constants.TIMESTAMP, Util.GetEpoch()));
            }
            else
            {
                el.Add(new XAttribute(Constants.TIMESTAMP, T.Timestamp));
            }

            if (!String.IsNullOrEmpty(T.XLink))
            {
                el.Add(new XAttribute(Constants.XLINK, T.XLink));
            }

            if (T.Title != null)
            {
                XElement title = Title.CreateXmlNode(Ns, T.Title);
                if (title != null)
                {
                    el.Add(title);
                }
            }

            if (T.Children != null)
            {
                XElement children = Children.CreateXmlNode(Ns, T.Children);
                if (children != null)
                {
                    el.Add(children);
                }
            }

            if (T.MarkerRefs != null)
            {
                XElement markerref = MarkerRefs.CreateXmlNode(Ns, T.MarkerRefs);
                if (markerref != null)
                {
                    el.Add(markerref);
                }
            }

            if (T.Relationships != null)
            {
                XElement relationships = Relationships.CreateXmlNode(Ns, T.Relationships);
                if (relationships != null)
                {
                    el.Add(relationships);
                }
            }

            if (T.Boundaries != null)
            {
                XElement boundaries = Boundaries.CreateXmlNode(Ns, T.Boundaries);
                if (boundaries != null)
                {
                    el.Add(boundaries);
                }
            }
            return(el);
        }