Example #1
0
        internal virtual void Insert(Token.Comment commentToken)
        {
            Comment comment = new Comment(commentToken.GetData(), baseUri);

            iText.StyledXmlParser.Jsoup.Nodes.Node insert = comment;
            if (commentToken.bogus)
            {
                // xml declarations are emitted as bogus comments (which is right for html, but not xml)
                // so we do a bit of a hack and parse the data as an element to pull the attributes out
                String data = comment.GetData();
                if (data.Length > 1 && (data.StartsWith("!") || data.StartsWith("?")))
                {
                    Document doc = iText.StyledXmlParser.Jsoup.Jsoup.Parse("<" + data.JSubstring(1, data.Length - 1) + ">", baseUri
                                                                           , iText.StyledXmlParser.Jsoup.Parser.Parser.XmlParser());
                    iText.StyledXmlParser.Jsoup.Nodes.Element el = doc.Child(0);
                    insert = new XmlDeclaration(el.TagName(), comment.BaseUri(), data.StartsWith("!"));
                    insert.Attributes().AddAll(el.Attributes());
                }
            }
            InsertNode(insert);
        }
Example #2
0
        internal virtual void Insert(Token.Comment commentToken)
        {
            Comment comment = new Comment(commentToken.GetData(), baseUri);

            InsertNode(comment);
        }