예제 #1
0
        public static XElement CreateXmlNode(XNamespace Ns, XMap_Content S)
        {
            XElement el = new XElement(Ns + Constants.XMAP_CONTENT);

            el.Add(new XAttribute(Constants.XMLNS, S.Xmlns));

            el.Add(new XAttribute(Constants.XMLNS_FO, S.Xmlns_Fo));
            el.Add(new XAttribute(Constants.XMLNS_SVG, S.Xmlns_Svg));
            el.Add(new XAttribute(Constants.XMLNS_XHTML, S.Xmlns_Xhtml));
            el.Add(new XAttribute(Constants.XMLNS_XLINK, S.Xmlns_Xlink));

            if (!String.IsNullOrEmpty(S.Modified_By))
            {
                el.Add(new XAttribute(Constants.MODIFIED_BY, S.Modified_By));
            }
            if (S.Timestamp == 0)
            {
                el.Add(new XAttribute(Constants.TIMESTAMP, Util.GetEpoch()));
            }
            else
            {
                el.Add(new XAttribute(Constants.TIMESTAMP, S.Timestamp));
            }

            el.Add(new XAttribute(Constants.VERSION, S.Version));

            foreach (Sheet item in S.SheetList)
            {
                el.Add(Sheet.CreateXmlNode(Ns, item));
            }

            return(el);
        }
예제 #2
0
        public static XMap_Content ParseXmlNode(XElement Node)
        {
            XMap_Content t = new XMap_Content();

            IEnumerable <XAttribute> attrCol = Node.Attributes();

            foreach (XAttribute item in attrCol)
            {
                switch (item.Name.LocalName)
                {
                case Constants.XMLNS:
                    t.Xmlns = item.Value;
                    break;

                case Constants.XMLNS_FO:
                    t.Xmlns_Fo = item.Value;
                    break;

                case Constants.XMLNS_SVG:
                    t.Xmlns_Svg = item.Value;
                    break;

                case Constants.XMLNS_XHTML:
                    t.Xmlns_Xhtml = item.Value;
                    break;

                case Constants.XMLNS_XLINK:
                    t.Xmlns_Xlink = item.Value;
                    break;

                case Constants.MODIFIED_BY:
                    t.Modified_By = item.Value;
                    break;

                case Constants.TIMESTAMP:
                    t.Timestamp = long.Parse(item.Value);
                    break;

                case Constants.VERSION:
                    t.Version = item.Value;
                    break;

                default:
                    break;
                }
            }


            IEnumerable <XElement> nodeliste = Node.Elements();

            foreach (XElement item in nodeliste)
            {
                switch (item.Name.LocalName)
                {
                case Constants.SHEET:
                    t.AddSheet(Sheet.ParseXmlNode(item));
                    break;

                default:
                    break;
                }
            }
            return(t);
        }