Beispiel #1
0
        public void FromFullContent_should_get_node_name_same_as_target()
        {
            string h = "xml version=\"1.0\" encoding=\"UTF-8\"";
            HtmlProcessingInstruction pi = HtmlProcessingInstruction.FromFullContent(new HtmlDocument(), h);

            Assert.Equal("xml", pi.NodeName);
        }
Beispiel #2
0
        public void FromFullContent_split_target_and_data_no_data()
        {
            string h = "xmlversion=\"1.0\"encoding=\"UTF-8\"";
            HtmlProcessingInstruction pi = HtmlProcessingInstruction.FromFullContent(new HtmlDocument(), h);

            Assert.Equal("xmlversion=\"1.0\"encoding=\"UTF-8\"", pi.Target);
            Assert.Equal("", pi.Data);
        }
Beispiel #3
0
        public void Parse_document_into_processing_instruction()
        {
            string html = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
            HtmlProcessingInstruction pi = HtmlDocument.Parse(html).ChildNode(0)
                                           as HtmlProcessingInstruction;

            Assert.NotNull(pi);
            Assert.Equal("xml", pi.Target);
            Assert.Equal("version=\"1.0\" encoding=\"UTF-8\"", pi.Data);
            Assert.Equal("version=\"1.0\" encoding=\"UTF-8\"", pi.TextContent);
        }
Beispiel #4
0
 void Insert(Token.Comment commentToken)
 {
     if (commentToken.IsBogus)
     {
         var comment = HtmlProcessingInstruction.Create(doc, commentToken);
         InsertNode(comment);
     }
     else
     {
         var comment = doc.CreateComment(commentToken.Data);
         InsertNode(comment);
     }
 }
Beispiel #5
0
        protected override void VisitProcessingInstruction(HtmlProcessingInstruction node)
        {
            var macro = Document.CreateProcessingInstruction(node.Target, node.Data);

            // TODO Missing line numbers and positions
            // TODO Enforce directives only at document level
            int line = -1;
            int pos  = -1;

            if (macro != null &&
                (macro.Target == "xml" || (macro is HxlProcessingInstruction)))
            {
                _current.Append(macro);
                AddImplicitType(macro.GetType());
            }
            else
            {
                throw HxlFailure.DirectiveNotDefined(node.Target, line, pos);
            }
        }