예제 #1
0
 /// <summary>
 /// 向XML书写器输出对象数据
 /// </summary>
 /// <remarks>若设置了OwnerDocument.WriteOptions.ScriptWriteCData
 /// 则脚本代码放置在 CDATA 块中</remarks>
 /// <param name="myWriter">XML书写器</param>
 /// <returns>操作是否成功</returns>
 protected override bool InnerWrite(System.Xml.XmlWriter myWriter)
 {
     if (HTMLTextReader.isBlankString(strText))
     {
         myWriter.WriteString(" ");
     }
     else
     {
         if (myOwnerDocument.WriteOptions.ScriptWriteCData)
         {
             string vText = strText.Replace("<![CDATA[", "");
             vText = vText.Replace("]]", "");
             myWriter.WriteString("//");
             myWriter.WriteCData(vText + "//");
         }
         else
         {
             string vText = strText + " ";
             if (vText.IndexOf("--") >= 0)
             {
                 vText = "因保存需要,将所有的\"--\"转换为 \"@@\"符号\r\n" + vText.Replace("--", "@@");
             }
             myWriter.WriteComment(vText);
         }
         //myWriter.WriteString( strText );
     }
     return(true);
 }
예제 #2
0
 /// <summary>
 /// 内部的输出对象数据到XML书写器
 /// </summary>
 /// <param name="myWriter">XML书写器</param>
 /// <returns>操作是否成功</returns>
 protected override bool InnerWrite(System.Xml.XmlWriter myWriter)
 {
     if (myOwnerDocument.WriteOptions.TextAreaOutputXSL)
     {
         myWriter.WriteStartElement(StringConstXSLT.Value_of);
         myWriter.WriteAttributeString(StringConstXSLT.Value_of, this.Name);
         myWriter.WriteEndElement();
     }
     else
     {
         myWriter.WriteString(HTMLTextReader.isBlankString(strText) ? " " : strText);
     }
     return(true);
 }
예제 #3
0
        /// <summary>
        /// 创建元素对象实例
        /// </summary>
        /// <param name="TagName">HTML标签名称</param>
        /// <param name="vParent">创建的元素的父节点</param>
        /// <returns>创建的HTML元素对象</returns>
        internal HTMLElement InnerCreateElement(string TagName, HTMLContainer vParent)
        {
            if (HTMLTextReader.isBlankString(TagName))
            {
                return(null);
            }
            HTMLElement NewElement = null;

            TagName = TagName.ToLower().Trim();
            switch (TagName)
            {
            case StringConstTagName.HTML:
                if (vParent == null || vParent == this)
                {
                    NewElement = this;
                }
                else
                {
                    NewElement = new HTMLDivElement();
                }
                break;

            case StringConstTagName.Head:
                if (vParent is HTMLDocument)
                {
                    NewElement = this.Head;
                    if (NewElement == null)
                    {
                        NewElement = new HTMLHeadElement();
                    }
                }
                break;

            case StringConstTagName.Body:
                if (vParent is HTMLDocument)
                {
                    NewElement = this.Body;
                    if (NewElement == null)
                    {
                        NewElement = new HTMLBodyElement();
                    }
                }
                else
                {
                    NewElement = new HTMLDivElement();
                }
                break;

            case StringConstTagName.IEDevicerect:
                NewElement = new HTMLIEDeviceRect();
                break;

            case StringConstTagName.IEHeaderFooter:
                NewElement = new HTMLIEHeaderfooter();
                break;

            case StringConstTagName.IELayoutrect:
                NewElement = new HTMLIELayoutrect();
                break;

            case StringConstTagName.IETemplatePrinter:
                NewElement = new HTMLIETemplateprinter();
                break;

            case StringConstTagName.H1:
                NewElement = new HTMLHnElement();
                ((HTMLHnElement)NewElement).Level = 1;
                break;

            case StringConstTagName.H2:
                NewElement = new HTMLHnElement();
                ((HTMLHnElement)NewElement).Level = 2;
                break;

            case StringConstTagName.H3:
                NewElement = new HTMLHnElement();
                ((HTMLHnElement)NewElement).Level = 3;
                break;

            case StringConstTagName.H4:
                NewElement = new HTMLHnElement();
                ((HTMLHnElement)NewElement).Level = 4;
                break;

            case StringConstTagName.H5:
                NewElement = new HTMLHnElement();
                ((HTMLHnElement)NewElement).Level = 5;
                break;

            case StringConstTagName.H6:
                NewElement = new HTMLHnElement();
                ((HTMLHnElement)NewElement).Level = 6;
                break;

            case StringConstTagName.Input:
                NewElement = new HTMLInputElement();
                break;

            case StringConstTagName.TextArea:
                NewElement = new HTMLTextAreaElement();
                break;

            case StringConstTagName.Select:
                NewElement = new HTMLSelectElement();
                break;

            case StringConstTagName.Option:
                NewElement = new HTMLOptionElement();
                break;

            case StringConstTagName.Form:
                NewElement = new HTMLFormElement();
                break;

            case StringConstTagName.A:
                NewElement = new HTMLAElement();
                break;

            case StringConstTagName.B:
                NewElement = new HTMLBElement();
                break;

            case StringConstTagName.Pre:
                NewElement = new HTMLPreElement();
                break;

            case StringConstTagName.Span:
                NewElement = new HTMLSpanElement();
                break;

            case StringConstTagName.Div:
                NewElement = new HTMLDivElement();
                break;

            case StringConstTagName.P:
                NewElement = new HTMLPElement();
                break;

            case StringConstTagName.Br:
                NewElement = new HTMLBRElement();
                break;

            case StringConstTagName.Applet:
                NewElement = new HTMLAppletElement();
                break;

            case StringConstTagName.TextNode:
                NewElement = new HTMLTextNodeElement();
                break;

            case StringConstTagName.Object:
                NewElement = new HTMLObjectElement();
                break;

            case StringConstTagName.Script:
                NewElement = new HTMLScriptElement();
                break;

            case StringConstTagName.Link:
                NewElement = new HTMLLinkElement();
                break;

            case StringConstTagName.Font:
                NewElement = new HTMLFontElement();
                break;

            case StringConstTagName.Meta:
                NewElement = new HTMLMetaElement();
                break;

            case StringConstTagName.BGSound:
                NewElement = new HTMLBGSoundElement();
                break;

            case StringConstTagName.Param:
                NewElement = new HTMLParamElement();
                break;

            case StringConstTagName.Comment:
                NewElement = new HTMLCommentElement();
                break;

            case StringConstTagName.Hr:
                NewElement = new HTMLHRElement();
                break;

            case StringConstTagName.Table:
                NewElement = new HTMLTableElement();
                break;

            case StringConstTagName.TBody:
                NewElement = new HTMLTBodyElement();
                break;

            case StringConstTagName.Tr:
                NewElement = new HTMLTRElement();
                break;

            case StringConstTagName.Td:
                NewElement = new HTMLTDElement();
                break;

            case StringConstTagName.Col:
                NewElement = new HTMLColElement();
                break;

            case StringConstTagName.Style:
                NewElement = new HTMLStyleElement();
                break;

            case StringConstTagName.Img:
                NewElement = new HTMLImgElement();
                break;

            case StringConstTagName.Title:
                NewElement = new HTMLTitleElement();
                break;

            case StringConstTagName.UL:
                NewElement = new HTMLULElement();
                break;

            case StringConstTagName.LI:
                NewElement = new HTMLLIElement();
                break;

            case StringConstTagName.Map:
                NewElement = new HTMLMapElement();
                break;

            case StringConstTagName.Area:
                NewElement = new HTMLAreaElement();
                break;

            case StringConstTagName.HTAApplication:
                NewElement = new HTMLHTAApplicationElement();
                break;

            case StringConstTagName.FrameSet:
                NewElement = new HTMLFrameSetElement();
                break;

            case StringConstTagName.Frame:
                NewElement = new HTMLFrameElement();
                break;

            case StringConstTagName.Label:
                NewElement = new HTMLLabelElement();
                break;

            case StringConstTagName.Marquee:
                NewElement = new HTMLMarqueeElement();
                break;

            case StringConstTagName.IFrame:
                NewElement = new HTMLIFrameElement();
                break;

            case StringConstTagName.XML:
                NewElement = new HTMLXMLElement();
                break;

            case StringConstTagName.Sup:
                NewElement = new HTMLSupElement();
                break;

            case StringConstTagName.Sub:
                NewElement = new HTMLSubElement();
                break;

            case StringConstTagName.Nobr:
                NewElement = new HTMLNobarElement();
                break;

            default:
                NewElement = new HTMLUnknowElement();
                (( HTMLUnknowElement)NewElement).SetTagName(TagName);
                break;
            }
            if (NewElement != null)
            {
                NewElement.OwnerDocument = this;
                NewElement.Parent        = vParent;
            }
            return(NewElement);
        }