/// <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); }
/// <summary>Loads up the foreigners set.</summary> private void LoadForeigners() { Foreigners = new Dictionary <string, MLNamespace>(); if (ForeignNames == null) { return; } string[] tags = ForeignNames.Split(','); for (int i = 0; i < tags.Length; i++) { // FQ with it's xmlns, e.g. 'svg:svg' or 'mml:math' string fullyQualifiedTag = tags[i]; string[] tagParts = fullyQualifiedTag.Split(':'); // Get the namespace from a (global only) prefix: MLNamespace ns = MLNamespaces.GetPrefix(tagParts[0]); // Add to set: Foreigners[tagParts[1]] = ns; } }
public AttributeNode(Node owner, string name, string val, string ns) { UnprefixedName = name; Namespace = MLNamespaces.GetPrefix(ns); ownerElement = owner as Element; specified = (val != null); value = val; }
public XmlNamespace(string name, string prefix, string mime, Type docType) { Namespace = MLNamespaces.Get(name, prefix, mime); if (docType != null) { Namespace.DocumentType = docType; } }
/// <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); }
public XmlNamespace(string name, string prefix, string mime, Type docType, string foreign) { Namespace = MLNamespaces.Get(name, prefix, mime); if (docType != null) { Namespace.DocumentType = docType; } if (foreign != null) { // Foreign elements (such as mathml's 'math' in html) are available. // Set: Namespace.ForeignNames = foreign; } }
/// <summary>Creates a new element in this document with the given namespace. /// You'll need to parent it to something.</summary> public Element createElementNS(string namespaceName, string tag) { // Get the namespace by its URL: MLNamespace ns = MLNamespaces.Get(namespaceName); if (ns == null) { ns = Namespace; } // Create the element and call its startup methods: Element result = TagHandlers.Create(ns, tag) as Element; result.document_ = this; result.OnTagLoaded(); result.OnChildrenLoaded(); return(result); }