public void StartParsing(XmlReader reader, string targetNamespace) { _reader = reader; _positionInfo = PositionInfo.GetPositionInfo(reader); _namespaceManager = reader.NamespaceManager; if (_namespaceManager == null) { _namespaceManager = new XmlNamespaceManager(_nameTable); _isProcessNamespaces = true; } else { _isProcessNamespaces = false; } while (reader.NodeType != XmlNodeType.Element && reader.Read()) { } _markupDepth = int.MaxValue; _schemaXmlDepth = reader.Depth; SchemaType rootType = _schemaNames.SchemaTypeFromRoot(reader.LocalName, reader.NamespaceURI); string code; if (!CheckSchemaRoot(rootType, out code)) { throw new XmlSchemaException(code, reader.BaseURI, _positionInfo.LineNumber, _positionInfo.LinePosition); } if (_schemaType == SchemaType.XSD) { _schema = new XmlSchema(); _schema.BaseUri = new Uri(reader.BaseURI, UriKind.RelativeOrAbsolute); _builder = new XsdBuilder(reader, _namespaceManager, _schema, _nameTable, _schemaNames, _eventHandler); } else { Debug.Assert(_schemaType == SchemaType.XDR); _xdrSchema = new SchemaInfo(); _xdrSchema.SchemaType = SchemaType.XDR; _builder = new XdrBuilder(reader, _namespaceManager, _xdrSchema, targetNamespace, _nameTable, _schemaNames, _eventHandler); ((XdrBuilder)_builder).XmlResolver = _xmlResolver; } }
private ValidationType DetectValidationType() { //Type not yet detected : Check in Schema Collection if (reader.Schemas != null && reader.Schemas.Count > 0) { XmlSchemaCollectionEnumerator enumerator = reader.Schemas.GetEnumerator(); while (enumerator.MoveNext()) { XmlSchemaCollectionNode node = enumerator.CurrentNode; SchemaInfo schemaInfo = node.SchemaInfo; if (schemaInfo.SchemaType == SchemaType.XSD) { return(ValidationType.Schema); } else if (schemaInfo.SchemaType == SchemaType.XDR) { return(ValidationType.XDR); } } } if (reader.NodeType == XmlNodeType.Element) { SchemaType schemaType = SchemaNames.SchemaTypeFromRoot(reader.LocalName, reader.NamespaceURI); if (schemaType == SchemaType.XSD) { return(ValidationType.Schema); } else if (schemaType == SchemaType.XDR) { return(ValidationType.XDR); } else { int count = reader.AttributeCount; for (int i = 0; i < count; i++) { reader.MoveToAttribute(i); string objectNs = reader.NamespaceURI; string objectName = reader.LocalName; if (Ref.Equal(objectNs, SchemaNames.NsXmlNs)) { if (XdrBuilder.IsXdrSchema(reader.Value)) { reader.MoveToElement(); return(ValidationType.XDR); } } else if (Ref.Equal(objectNs, SchemaNames.NsXsi)) { reader.MoveToElement(); return(ValidationType.Schema); } else if (Ref.Equal(objectNs, SchemaNames.QnDtDt.Namespace) && Ref.Equal(objectName, SchemaNames.QnDtDt.Name)) { reader.SchemaTypeObject = XmlSchemaDatatype.FromXdrName(reader.Value); reader.MoveToElement(); return(ValidationType.XDR); } } //end of for if (count > 0) { reader.MoveToElement(); } } } return(ValidationType.Auto); }