示例#1
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>
        /// <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
        /// <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
        /// <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
        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;
        }
 /// <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))
 {
 }
 /// <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))
 {
 }
 /// <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;
 }