public Document CreateDocument(String namespaceURI, String qualifiedName, DocumentType doctype) { Document doc = null; if (Namespaces.Html == namespaceURI) doc = new HTMLDocument(); else doc = new Document(); doc.AppendChild(doctype); doc.NodeName = qualifiedName ?? doc.NodeName; return doc; }
void BeforeDoctype(XmlToken token) { if (token.Type == XmlTokenType.DOCTYPE) { var tok = (XmlDoctypeToken)token; var doctype = new DocumentType(); doctype.SystemId = tok.SystemIdentifier; doctype.PublicId = tok.PublicIdentifier; doctype.Name = tok.Name; doc.AppendChild(doctype); insert = XmlTreeMode.Body; } else if (token.Type == XmlTokenType.ProcessingInstruction) { var tok = (XmlPIToken)token; var pi = doc.CreateProcessingInstruction(tok.Target, tok.Content); doc.AppendChild(pi); } else if (token.Type == XmlTokenType.Comment) { var tok = (XmlCommentToken)token; var com = doc.CreateComment(tok.Data); doc.AppendChild(com); } else if (!token.IsIgnorable) { insert = XmlTreeMode.Body; InBody(token); } }
public override Node CloneNode(Boolean deep = true) { var node = new DocumentType(); CopyProperties(this, node, deep); node.Name = this.Name; node.PublicId = this.PublicId; node.SystemId = this.SystemId; node.InternalSubset = this.InternalSubset; return node; }
/// <summary> /// Before any doctype - still in the prolog. No declaration /// allowed. /// </summary> /// <param name="token">The consumed token.</param> void BeforeDoctype(XmlToken token) { switch (token.Type) { case XmlTokenType.DOCTYPE: { var tok = (XmlDoctypeToken)token; var doctype = new DocumentType(); doctype.SystemId = tok.SystemIdentifier; doctype.PublicId = tok.PublicIdentifier; doctype.TypeDefinitions = tokenizer.DTD; doctype.Name = tok.Name; doc.AppendChild(doctype); insert = XmlTreeMode.Misc; if (!tok.IsSystemIdentifierMissing && !standalone) ScanExternalSubset(doctype.SystemId, doctype.TypeDefinitions); break; } default: { InMisc(token); break; } } }
/// <summary> /// Appends the doctype token to the document. /// </summary> /// <param name="doctypeToken">The doctypen token.</param> void AddDoctype(HtmlDoctypeToken doctypeToken) { var node = new DocumentType(); node.SystemId = doctypeToken.SystemIdentifier; node.PublicId = doctypeToken.PublicIdentifier; node.Name = doctypeToken.Name; doc.AppendChild(node); }