Esempio n. 1
0
        /// <summary>Creates a new document and sets it to the given namespace.</summary>
        public Document createDocument(string namespaceUri, string qualifiedName, DocumentType doctype)
        {
            MLNamespace ns = null;

            // Get the namespace if there is one:
            if (!string.IsNullOrEmpty(namespaceUri))
            {
                ns = MLNamespaces.Get(namespaceUri);
            }

            // Create the document:
            Document document = (ns == null)? new Document() : ns.CreateDocument();

            // Add the doctype:
            if (doctype != null)
            {
                document.appendChild(doctype);
            }

            if (!string.IsNullOrEmpty(qualifiedName))
            {
                // Create the element:
                Element element = document.createElement(qualifiedName);

                if (element != null)
                {
                    document.appendChild(element);
                }
            }

            // Apply the base URI:
            document.basepath = _owner.basepath;

            return(document);
        }
Esempio n. 2
0
        /// <summary>Parses a complete document from the given string.</summary>
        public Dom.Document parseFromString(string text, string type)
        {
            // Try making the document by the given mime type:
            MLNamespace ns = MLNamespaces.GetByMime(type);

            // Create the document:
            Document document = (ns == null)? new Document() : ns.CreateDocument();

            // Parse the contents:
            if (text != null)
            {
                document.innerML = text;
            }

            return(document);
        }