//internal virtual void MarkXhtmlElement() //{ // this.MarkXhtmlElement(null); //} /// <summary> /// 根据当前节点的特性来设置该节点 /// </summary> internal virtual void MarkXhtmlElement(PageXmlDocument pageDoc) { this.PageXmlDocument = pageDoc; this.TagCreator(); #region if DEBUG, 辩别生成效果 #if DEBUG //为了辩别生成效果,在Debug时节点加入相关的节点名字 //string eleName = this.LocalName; //PropertyInfo pinfo = this.GetType().GetProperty("SnipPartType"); //if (pinfo != null) //{ // eleName = eleName + "_" + pinfo.GetValue(this, null); //} //if (this._XhtmlElement != null && !(this._XhtmlElement is XhtmlText) && !(this._XhtmlElement is XhtmlCData) && !(this._XhtmlElement is XhtmlComment)) //{ // this._XhtmlElement.SetAttribute("name", eleName); //} #endif #endregion foreach (XmlNode node in this.ChildNodes) { if (node.NodeType != XmlNodeType.Element) { continue; } if (node is ToHtmlXmlElement) { if (node is SnipXmlElement) { SnipXmlElement snip = (SnipXmlElement)node; if (!snip.HasSnip)///如果页面片节点里面并不含有页面片的话,节约效率,就不用再往下遍历 { continue; } } ToHtmlXmlElement htmlNode = (ToHtmlXmlElement)node; htmlNode.PageXmlDocument = this.PageXmlDocument; htmlNode.ParentXhtmlElement = this.SetSubNode(); htmlNode.ToHtml(); } } this._isAlreadyToHtml = true; }
/// <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的标记 }