Esempio n. 1
0
        /// <summary>
        /// 根据当前模板的特性来设置该节点
        /// </summary>
        protected virtual void MarkXhtmlElement()
        {
            XhtmlPage ownerPage = (XhtmlPage)this._ParentXhtmlElement.OwnerPage;

            //<meta http-equiv="Expires" content="Fri, 26 Mar 1999 23:59:59 GMT">
            //<meta http-equiv="pragma" content="no-cache">
            //<meta name="Author" content="Apple Inc.">
            //<meta name="Keywords" content="Apple">

            //<link rel="home" href="http://www.apple.com/">
            //<link rel="alternate" type="application/rss+xml" title="RSS" href="http://images.apple.com/main/rss/hotnews/hotnews.rss">
            //<link rel="index" href="http://www.apple.com/find/sitemap.html">


            #region Meta: Content-Type

            XhtmlAtts.Http_equiv httpEquiv   = new XhtmlAtts.Http_equiv(Xhtml.Http_equiv.content_type);
            XhtmlAtts.Content    content     = new XhtmlAtts.Content("text/html; charset=utf-8");
            XhtmlTagElement      contentType = ownerPage.CreateXhtmlMeta(httpEquiv, content);
            ownerPage.Head.AppendChild(contentType);

            #endregion

            //<!--#include virtual="http://ssi.jeelu.com/GetHtml.cgi?domain=$SERVER_ADDR&dir=$DOCUMENT_URI&filename=asdfads"-->
            SdCgiObject cgi = new SdCgiObject(CgiPlace.Head);
            ownerPage.Head.AppendChild(ownerPage.CreateXhtmlCommentShtml(cgi));

            #region Meta: Power
#if !DEBUG
            string         version = Application.ProductVersion;
            XhtmlAtts.Name name    = new XhtmlAtts.Name("Generator");
            content = new XhtmlAtts.Content("网站360°: v" + version + ",http://www.SimplusD.com");
            XhtmlTagElement power = ownerPage.CreateXhtmlMeta(name, content);
            ownerPage.Head.AppendChild(power);
#endif
            #endregion

            XhtmlElement mainElement = ownerPage.CreateXhtmlDiv();
            this._XhtmlElement.AppendChild(mainElement);

            #region 辩别生成效果
#if DEBUG
            mainElement.SetAttribute("name", "tmplt");
#endif
            #endregion

            /// this.GetRectsElement().ChildNodes[0]是指的rects节点下的第一个节点,一般是rect
            /// 按照SimplusD的规则,这个节点有仅有一个rect节点
            XmlNode firstNode = null;
            if (this.GetRectsElement().ChildNodes[0] is SnipXmlElement)
            {
                firstNode = this.GetRectsElement();///当一个模板里只有一个页面片时的特殊情况处理
            }
            else
            {
                firstNode = this.GetRectsElement().ChildNodes[0];
            }

            foreach (XmlNode node in firstNode.ChildNodes)///遍历子节点,通过Element的继承关系递归
            {
                if (node.NodeType != XmlNodeType.Element)
                {
                    continue;
                }
                if (node is ToHtmlXmlElement)///当节点是继承自ToHtmlXmlElement,即可以生成页面
                {
                    ToHtmlXmlElement htmlNode = (ToHtmlXmlElement)node;
                    htmlNode.ParentXhtmlElement = mainElement; ///下一级节点的父节点即为本节点
                    htmlNode.ToHtml();                         ///调用下一级节点的ToHtml
                }
            }
            this._isAlreadyToHtml = true;///已经ToHtml的标记
        }