internal XmlParserContext(XmlNameTable nt, XmlNamespaceManager nsMgr, DTDObjectModel dtd, string baseURI, string xmlLang, XmlSpace xmlSpace, Encoding enc) { this.namespaceManager = nsMgr; this.nameTable = nt != null ? nt : nsMgr != null ? nsMgr.NameTable : null; if (dtd != null) { this.DocTypeName = dtd.Name; this.PublicId = dtd.PublicId; this.SystemId = dtd.SystemId; this.InternalSubset = dtd.InternalSubset; this.dtd = dtd; } this.encoding = enc; this.BaseURI = baseURI; this.XmlLang = xmlLang; this.xmlSpace = xmlSpace; contextItems = new ArrayList(); }
// .ctor() public DTDReader (DTDObjectModel dtd, int startLineNumber, int startLinePosition) { this.DTD = dtd; currentLinkedNodeLineNumber = startLineNumber; currentLinkedNodeLinePosition = startLinePosition; Init (); }
/// <summary>Initializes a new instance of the <see cref="T:System.Xml.XmlDocumentType" /> class.</summary> /// <param name="name">The qualified name; see the <see cref="P:System.Xml.XmlDocumentType.Name" /> property.</param> /// <param name="publicId">The public identifier; see the <see cref="P:System.Xml.XmlDocumentType.PublicId" /> property.</param> /// <param name="systemId">The system identifier; see the <see cref="P:System.Xml.XmlDocumentType.SystemId" /> property.</param> /// <param name="internalSubset">The DTD internal subset; see the <see cref="P:System.Xml.XmlDocumentType.InternalSubset" /> property.</param> /// <param name="doc">The parent document.</param> protected internal XmlDocumentType(string name, string publicId, string systemId, string internalSubset, XmlDocument doc) : base(doc) { XmlTextReader xmlTextReader = new XmlTextReader(this.BaseURI, new StringReader(string.Empty), doc.NameTable); xmlTextReader.XmlResolver = doc.Resolver; xmlTextReader.GenerateDTDObjectModel(name, publicId, systemId, internalSubset); this.dtd = xmlTextReader.DTD; this.ImportFromDTD(); }
// Constructor protected internal XmlDocumentType (string name, string publicId, string systemId, string internalSubset, XmlDocument doc) : base (doc) { XmlTextReaderImpl xtr = new XmlTextReaderImpl (BaseURI, new StringReader (""), doc.NameTable); xtr.XmlResolver = doc.Resolver; xtr.GenerateDTDObjectModel (name, publicId, systemId, internalSubset); this.dtd = xtr.DTD; ImportFromDTD (); }
XmlParserContext(XmlNameTable nt, XmlNamespaceManager nsMgr, #if NOT_PFX DTDObjectModel dtd, #else string docTypeName, string pubId, string sysId, string internalSubset, #endif string baseURI, string xmlLang, XmlSpace xmlSpace, Encoding enc) { if (nt == null) { this.nameTable = nsMgr == null ? new NameTable() : nsMgr.NameTable; } else { this.nameTable = nt; } this.namespaceManager = nsMgr != null ? nsMgr : new XmlNamespaceManager(nameTable); #if NOT_PFX if (dtd != null) { this.DocTypeName = dtd.Name; this.PublicId = dtd.PublicId; this.SystemId = dtd.SystemId; this.InternalSubset = dtd.InternalSubset; this.dtd = dtd; } #else this.DocTypeName = docTypeName; this.PublicId = pubId; this.SystemId = sysId; this.InternalSubset = internalSubset; #endif this.encoding = enc; this.BaseURI = baseURI; this.XmlLang = xmlLang; this.xmlSpace = xmlSpace; contextItems = new ArrayList(); }
private XmlDocumentType CreateDocumentType(DTDObjectModel dtd) { return(new XmlDocumentType(dtd, this)); }
XmlNode ReadNodeCore(XmlReader reader) { switch (reader.ReadState) { case ReadState.Interactive: break; case ReadState.Initial: #if NET_2_0 if (reader.SchemaInfo != null) { this.SchemaInfo = new XmlSchemaInfo(reader.SchemaInfo); } #endif reader.Read(); break; default: return(null); } XmlNode n; switch (reader.NodeType) { case XmlNodeType.Attribute: string localName = reader.LocalName; string ns = reader.NamespaceURI; n = ReadAttributeNode(reader); // Keep the current reader position on attribute. reader.MoveToAttribute(localName, ns); return(n); case XmlNodeType.CDATA: n = CreateCDataSection(reader.Value); break; case XmlNodeType.Comment: n = CreateComment(reader.Value); break; case XmlNodeType.Element: XmlElement element = CreateElement(reader.Prefix, reader.LocalName, reader.NamespaceURI, reader.NameTable == this.NameTable); #if NET_2_0 if (reader.SchemaInfo != null) { SchemaInfo = new XmlSchemaInfo(reader.SchemaInfo); } #endif element.IsEmpty = reader.IsEmptyElement; // set the element's attributes. for (int i = 0; i < reader.AttributeCount; i++) { reader.MoveToAttribute(i); element.SetAttributeNode( ReadAttributeNode(reader)); reader.MoveToElement(); } // FIXME: the code below should be fine and // in some XmlReaders it is much faster, but // caused some breakage in sys.data test. /* * if (reader.MoveToFirstAttribute ()) { * do { * element.SetAttributeNode (ReadAttributeNode (reader)); * } while (reader.MoveToNextAttribute ()); * reader.MoveToElement (); * } */ reader.MoveToElement(); int depth = reader.Depth; if (reader.IsEmptyElement) { n = element; break; } reader.Read(); while (reader.Depth > depth) { n = ReadNodeCore(reader); if (preserveWhitespace || n.NodeType != XmlNodeType.Whitespace) { element.AppendChild(n, false); } } n = element; break; case XmlNodeType.ProcessingInstruction: n = CreateProcessingInstruction(reader.Name, reader.Value); break; case XmlNodeType.Text: n = CreateTextNode(reader.Value); break; case XmlNodeType.XmlDeclaration: n = CreateXmlDeclaration("1.0", String.Empty, String.Empty); n.Value = reader.Value; break; case XmlNodeType.DocumentType: DTDObjectModel dtd = null; IHasXmlParserContext ctxReader = reader as IHasXmlParserContext; if (ctxReader != null) { dtd = ctxReader.ParserContext.Dtd; } if (dtd != null) { n = CreateDocumentType(dtd); } else { n = CreateDocumentType(reader.Name, reader ["PUBLIC"], reader ["SYSTEM"], reader.Value); } break; case XmlNodeType.EntityReference: if (this.loadMode && this.DocumentType != null && DocumentType.Entities.GetNamedItem(reader.Name) == null) { throw new XmlException("Reference to undeclared entity was found."); } n = CreateEntityReference(reader.Name); // IF argument XmlReader can resolve entity, // ReadNode() also fills children _from it_. // In this case, it is not from doctype node. // (it is kind of sucky design, but it happens // anyways when we modify doctype node). // // It does not happen when !CanResolveEntity. // (In such case AppendChild() will resolve // entity content, as XmlEntityReference does.) if (reader.CanResolveEntity) { reader.ResolveEntity(); reader.Read(); for (XmlNode child; reader.NodeType != XmlNodeType.EndEntity && (child = ReadNode(reader)) != null;) { n.InsertBefore(child, null, false, false); } } break; case XmlNodeType.SignificantWhitespace: n = CreateSignificantWhitespace(reader.Value); break; case XmlNodeType.Whitespace: n = CreateWhitespace(reader.Value); break; case XmlNodeType.None: return(null); default: // No idea why MS does throw NullReferenceException ;-P throw new NullReferenceException("Unexpected node type " + reader.NodeType + "."); } reader.Read(); return(n); }
internal XmlDocumentType(DTDObjectModel dtd, XmlDocument doc) : base(doc) { this.dtd = dtd; ImportFromDTD(); }
public DTDInvalidAutomata (DTDObjectModel root) : base (root) { }
public DTDAnyAutomata (DTDObjectModel root) : base (root) { }
public DTDOneOrMoreAutomata (DTDObjectModel root, DTDAutomata children) : base (root) { this.children = children; }
public DTDSequenceAutomata (DTDObjectModel root, DTDAutomata left, DTDAutomata right) : base (root) { this.left = left; this.right = right; }
public DTDElementAutomata (DTDObjectModel root, string name) : base (root) { this.name = name; }
internal XmlParserContext (XmlNameTable nt, XmlNamespaceManager nsMgr, DTDObjectModel dtd, string baseURI, string xmlLang, XmlSpace xmlSpace, Encoding enc) { this.namespaceManager = nsMgr; this.nameTable = nt != null ? nt : nsMgr != null ? nsMgr.NameTable : null; if (dtd != null) { this.DocTypeName = dtd.Name; this.PublicId = dtd.PublicId; this.SystemId = dtd.SystemId; this.InternalSubset = dtd.InternalSubset; this.dtd = dtd; } this.encoding = enc; this.BaseURI = baseURI; this.XmlLang = xmlLang; this.xmlSpace = xmlSpace; contextItems = new ArrayList (); }
internal XmlDocumentType (DTDObjectModel dtd, XmlDocument doc) : base (doc) { this.dtd = dtd; ImportFromDTD (); }
private XmlDocumentType CreateDocumentType (DTDObjectModel dtd) { return new XmlDocumentType (dtd, this); }
void ReadDoctype () { FillAttributes (); IHasXmlParserContext ctx = reader as IHasXmlParserContext; if (ctx != null) dtd = ctx.ParserContext.Dtd; if (dtd == null) { XmlTextReaderImpl xmlTextReader = new XmlTextReaderImpl ("", XmlNodeType.Document, null); xmlTextReader.XmlResolver = resolver; xmlTextReader.GenerateDTDObjectModel (reader.Name, reader ["PUBLIC"], reader ["SYSTEM"], reader.Value); dtd = xmlTextReader.DTD; } currentAutomata = dtd.RootAutomata; // Validity Constraint Check. for (int i = 0; i < DTD.Errors.Length; i++) HandleError (DTD.Errors [i].Message, XmlSeverityType.Error); // NData target exists. foreach (DTDEntityDeclaration ent in dtd.EntityDecls.Values) if (ent.NotationName != null && dtd.NotationDecls [ent.NotationName] == null) this.HandleError ("Target notation was not found for NData in entity declaration " + ent.Name + ".", XmlSeverityType.Error); // NOTATION exists for attribute default values foreach (DTDAttListDeclaration attListIter in dtd.AttListDecls.Values) { foreach (DTDAttributeDefinition def in attListIter.Definitions) { if (def.Datatype.TokenizedType != XmlTokenizedType.NOTATION) continue; foreach (string notation in def.EnumeratedNotations) if (dtd.NotationDecls [notation] == null) this.HandleError ("Target notation was not found for NOTATION typed attribute default " + def.Name + ".", XmlSeverityType.Error); } } }
public DTDAutomata (DTDObjectModel root) { this.root = root; }