コード例 #1
0
ファイル: DocumentBuilder.cs プロジェクト: rrsc/AngleSharp
        /// <summary>
        /// Creates a new builder with the specified source.
        /// </summary>
        /// <param name="source">The code manager.</param>
        /// <param name="document">The document to fill.</param>
        /// <param name="options">Options to use for the document generation.</param>
        DocumentBuilder(SourceManager source, XMLDocument document, DocumentOptions options)
        {
            document.Options = options;
            parser = new XmlParser(document, source);
			parser.ErrorOccurred += ParseErrorOccurred;

			if (options.OnError != null)
				parser.ErrorOccurred += options.OnError;
        }
コード例 #2
0
ファイル: XmlValidator.cs プロジェクト: rrsc/AngleSharp
        /// <summary>
        /// Runs the Validation with the given document.
        /// </summary>
        /// <param name="doc">The document to inspect.</param>
        /// <returns>True if the validation has been successful, otherwise false.</returns>
        public static Boolean Run(XMLDocument doc)
        {
            if (doc.Doctype == null || doc.Doctype.TypeDefinitions == null)
                return false;

            var validator = new XmlValidator();
            validator.Definition = doc.Doctype.TypeDefinitions;

            if (!validator.Definition.IsInvalid && doc.DocumentElement.NodeName == doc.Doctype.Name)
                return validator.Inspect(doc.DocumentElement);

            return false;
        }
コード例 #3
0
ファイル: XmlParser.cs プロジェクト: Rajbandi/AngleSharp
        /// <summary>
        /// Creates a new instance of the XML parser with the specified document
        /// based on the given source manager.
        /// </summary>
        /// <param name="document">The document instance to be constructed.</param>
        /// <param name="source">The source to use.</param>
        internal XmlParser(XMLDocument document, SourceManager source)
        {
            tokenizer = new XmlTokenizer(source);

            tokenizer.ErrorOccurred += (s, ev) =>
            {
                if (ErrorOccurred != null)
                    ErrorOccurred(this, ev);
            };

            started = false;
            doc = document;
            standalone = false;
            open = new List<Element>();
            insert = XmlTreeMode.Initial;
        }
コード例 #4
0
ファイル: DOMImplementation.cs プロジェクト: rrsc/AngleSharp
        public Document CreateDocument(String namespaceURI = null, String qualifiedName = null, DocumentType doctype = null)
        {
            Document doc = null;

            if (Namespaces.Html == namespaceURI)
                doc = new HTMLDocument();
            else if (Namespaces.Xml == namespaceURI)
                doc = new XMLDocument();
            else
                doc = new Document();

            if(doctype != null)
                doc.AppendChild(doctype);

            doc.NodeName = qualifiedName ?? doc.NodeName;
            return doc;
        }
コード例 #5
0
 /// <summary>
 /// Creates a new instance of the XML parser with the specified document
 /// based on the given stream.
 /// </summary>
 /// <param name="document">The document instance to be constructed.</param>
 /// <param name="stream">The stream to use as source.</param>
 public XmlParser(XMLDocument document, Stream stream)
     : this(document, new SourceManager(stream))
 {
 }
コード例 #6
0
 /// <summary>
 /// Creates a new instance of the XML parser with the specified document
 /// based on the given source.
 /// </summary>
 /// <param name="document">The document instance to be constructed.</param>
 /// <param name="source">The source code as a string.</param>
 public XmlParser(XMLDocument document, String source)
     : this(document, new SourceManager(source))
 {
 }
コード例 #7
0
 /// <summary>
 /// Creates a new builder with the specified source.
 /// </summary>
 /// <param name="source">The code manager.</param>
 /// <param name="document">The document to fill.</param>
 DocumentBuilder(SourceManager source, XMLDocument document)
 {
     parser = new XmlParser(document, source);
     parser.ErrorOccurred += ParseErrorOccurred;
 }