示例#1
0
        /// <summary>
        /// Write comment <!-- this is a comment -->
        /// </summary>
        /// <param name="element">Element containing element</param>
        public void WriteComment(XHTMLElement element)
        {
            //Write comment open tag
            XhtmlWriter.BeginRender();
            XhtmlWriter.Write("<!--");

            //Lets parse the text, because the XhtmlWriter handles layout chars incorrectly
            CharIterator charIterator = new CharIterator();
            String       content      = charIterator.ParseText(element.GetContent());

            XhtmlWriter.Write(content);

            //Close comment tag
            XhtmlWriter.Write("-->");
            XhtmlWriter.EndRender();
            XhtmlWriter.Flush();
        }
示例#2
0
        /// <summary>
        /// Visit XHTMLElement and write it to stream
        /// </summary>
        /// <param name="element">Element to visit</param>
        public void Visit(XHTMLElement element)
        {
            if (element.GetTag() == "cdata")
            {   //CData need different handling
                WriteCData(element);
            }
            else if (element.GetTag() == "comment")
            {   //Write comment
                WriteComment(element);
            }
            else
            {   //Normal XHTML tag handling
                XhtmlWriter.BeginRender();

                //Check if element is tag, if not write tag, otherwise handle as XHTML tag
                if (!element.GetTagState())
                {
                    XhtmlWriter.BeginRender();

                    //Get escape chars out of this tag
                    CharIterator charIterator = new CharIterator();
                    String       tag          = charIterator.ParseText(element.GetTag());
                    XhtmlWriter.Write(tag);
                    XhtmlWriter.EndRender();
                    XhtmlWriter.Flush();
                    return;
                }

                XhtmlWriter.WriteBeginTag(element.GetTag());
                foreach (KeyValuePair <String, String> pair in element.GetAttributes())
                {
                    XhtmlWriter.WriteAttribute(pair.Key, pair.Value, false);
                }

                if (IsEmptyElement(element))
                {   //Nothing inside element, so write tag end
                    XhtmlWriter.Write(XhtmlTextWriter.SelfClosingTagEnd);
                }
                else if (IsXHTMLTag(element.GetTag()))
                {
                    //Write tag opening closing
                    XhtmlWriter.Write(XhtmlTextWriter.TagRightChar);

                    //Write content
                    XhtmlWriter.Write(element.GetContent());

                    //Visit children
                    foreach (XHTMLElement child in element.GetChildren())
                    {
                        Visit(child);
                    }

                    //Write closing tag
                    XhtmlWriter.WriteEndTag(element.GetTag());
                    XhtmlWriter.Flush();
                }
                else
                {
                    //Just write it
                    XhtmlWriter.Write(element.GetTag());
                    XhtmlWriter.EndRender();
                    XhtmlWriter.Flush();
                }
            }
        }
示例#3
0
        /// <summary>
        /// Visit XHTMLElement and write it to stream
        /// </summary>
        /// <param name="element">Element to visit</param>
        public void Visit(XHTMLElement element)
        {
            if (element.GetTag() == "cdata")
            {   //CData need different handling
                WriteCData(element);
            }
            else if (element.GetTag() == "comment")
            {   //Write comment
                WriteComment(element);
            }
            else
            {   //Normal XHTML tag handling

                XhtmlWriter.BeginRender();

                //Check if element is tag, if not write tag, otherwise handle as XHTML tag
                if (!element.GetTagState())
                {
                    XhtmlWriter.BeginRender();

                    //Get escape chars out of this tag
                    CharIterator charIterator = new CharIterator();
                    String tag = charIterator.ParseText(element.GetTag());
                    XhtmlWriter.Write(tag);
                    XhtmlWriter.EndRender();
                    XhtmlWriter.Flush();
                    return;
                }

                XhtmlWriter.WriteBeginTag(element.GetTag());
                foreach (KeyValuePair<String, String> pair in element.GetAttributes())
                {
                    XhtmlWriter.WriteAttribute(pair.Key, pair.Value, false);
                }

                if (IsEmptyElement(element))
                {   //Nothing inside element, so write tag end
                    XhtmlWriter.Write(XhtmlTextWriter.SelfClosingTagEnd);
                }
                else if (IsXHTMLTag(element.GetTag()))
                {
                    //Write tag opening closing
                    XhtmlWriter.Write(XhtmlTextWriter.TagRightChar);

                    //Write content
                    XhtmlWriter.Write(element.GetContent());

                    //Visit children
                    foreach (XHTMLElement child in element.GetChildren())
                    {
                        Visit(child);
                    }

                    //Write closing tag
                    XhtmlWriter.WriteEndTag(element.GetTag());
                    XhtmlWriter.Flush();
                }
                else
                {
                    //Just write it
                    XhtmlWriter.Write(element.GetTag());
                    XhtmlWriter.EndRender();
                    XhtmlWriter.Flush();
                }
            }
        }
示例#4
0
        /// <summary>
        /// Write comment <!-- this is a comment -->
        /// </summary>
        /// <param name="element">Element containing element</param>
        public void WriteComment(XHTMLElement element)
        {
            //Write comment open tag
            XhtmlWriter.BeginRender();
            XhtmlWriter.Write("<!--");

            //Lets parse the text, because the XhtmlWriter handles layout chars incorrectly
            CharIterator charIterator = new CharIterator();
            String content = charIterator.ParseText(element.GetContent());
            XhtmlWriter.Write(content);

            //Close comment tag
            XhtmlWriter.Write("-->");
            XhtmlWriter.EndRender();
            XhtmlWriter.Flush();
        }