private void ValidateElement() { elementName.Init(reader.LocalName, XmlSchemaDatatype.XdrCanonizeUri(reader.NamespaceURI, NameTable, SchemaNames)); ValidateChildElement(); if (SchemaNames.IsXDRRoot(elementName.Name, elementName.Namespace) && reader.Depth > 0) { inlineSchemaParser = new Parser(SchemaType.XDR, NameTable, SchemaNames, EventHandler); inlineSchemaParser.StartParsing(reader, null); inlineSchemaParser.ParseReaderNode(); } else { ProcessElement(); } }
private void ValidateElement() { elementName.Init(reader.LocalName, XmlSchemaDatatype.XdrCanonizeUri(reader.NamespaceURI, NameTable, SchemaNames)); ValidateChildElement(); if (SchemaNames.IsXDRRoot(elementName.Name, elementName.Namespace) && reader.Depth > 0) { _inlineSchemaParser = new Parser(SchemaType.XDR, NameTable, SchemaNames, EventHandler); _inlineSchemaParser.StartParsing(reader, null); _inlineSchemaParser.ParseReaderNode(); } else { ProcessElement(); } }
private void ValidateElement() { elementName.Init(reader.LocalName, reader.NamespaceURI); object particle = ValidateChildElement(); if (IsXSDRoot(elementName.Name, elementName.Namespace) && reader.Depth > 0) { inlineSchemaParser = new Parser(SchemaType.XSD, NameTable, SchemaNames, EventHandler); inlineSchemaParser.StartParsing(reader, null); ProcessInlineSchema(); } else { ProcessElement(particle); } }
private void ProcessElementEvent() { if (this.processInlineSchema && IsXSDRoot(coreReader.LocalName, coreReader.NamespaceURI) && coreReader.Depth > 0) { xmlSchemaInfo.Clear(); attributeCount = coreReaderAttributeCount = coreReader.AttributeCount; if (!coreReader.IsEmptyElement) { //If its not empty schema, then parse else ignore inlineSchemaParser = new Parser(SchemaType.XSD, coreReaderNameTable, validator.SchemaSet.GetSchemaNames(coreReaderNameTable), validationEvent); inlineSchemaParser.StartParsing(coreReader, null); inlineSchemaParser.ParseReaderNode(); validationState = ValidatingReaderState.ParseInlineSchema; } else { validationState = ValidatingReaderState.ClearAttributes; } } else { //Validate element //Clear previous data atomicValue = null; originalAtomicValueString = null; xmlSchemaInfo.Clear(); if (manageNamespaces) { nsManager.PushScope(); } //Find Xsi attributes that need to be processed before validating the element string xsiSchemaLocation = null; string xsiNoNamespaceSL = null; string xsiNil = null; string xsiType = null; if (coreReader.MoveToFirstAttribute()) { do { string objectNs = coreReader.NamespaceURI; string objectName = coreReader.LocalName; if (Ref.Equal(objectNs, NsXsi)) { if (Ref.Equal(objectName, XsiSchemaLocation)) { xsiSchemaLocation = coreReader.Value; } else if (Ref.Equal(objectName, XsiNoNamespaceSchemaLocation)) { xsiNoNamespaceSL = coreReader.Value; } else if (Ref.Equal(objectName, XsiType)) { xsiType = coreReader.Value; } else if (Ref.Equal(objectName, XsiNil)) { xsiNil = coreReader.Value; } } if (manageNamespaces && Ref.Equal(coreReader.NamespaceURI, NsXmlNs)) { nsManager.AddNamespace(coreReader.Prefix.Length == 0 ? string.Empty : coreReader.LocalName, coreReader.Value); } } while (coreReader.MoveToNextAttribute()); coreReader.MoveToElement(); } validator.ValidateElement(coreReader.LocalName, coreReader.NamespaceURI, xmlSchemaInfo, xsiType, xsiNil, xsiSchemaLocation, xsiNoNamespaceSL); ValidateAttributes(); validator.ValidateEndOfAttributes(xmlSchemaInfo); if (coreReader.IsEmptyElement) { ProcessEndElementEvent(); } validationState = ValidatingReaderState.ClearAttributes; } }
internal void Validate() { if (inlineSchemaParser != null) { if (!inlineSchemaParser.ParseReaderNode()) { // Done XmlSchema schema = inlineSchemaParser.FinishParsing(); bool add = true; if (schema != null) { inlineNs = schema.TargetNamespace == null ? string.Empty : schema.TargetNamespace; if (!SchemaInfo.HasSchema(inlineNs) && schema.ErrorCount == 0) { schema.Compile(schemaCollection, nameTable, schemaNames, validationEventHandler, null, inlineSchemaInfo, true); add = schema.ErrorCount == 0; } else { add = false; } } else { inlineNs = inlineSchemaInfo.CurrentSchemaNamespace; add = !SchemaInfo.HasSchema(inlineNs); } if (add) { SchemaInfo.Add(inlineNs, inlineSchemaInfo, validationEventHandler); schemaCollection.Add(inlineNs, inlineSchemaInfo, schema, false); } inlineSchemaParser = null; inlineSchemaInfo = null; inlineNs = null; } } else { this.name = QualifiedName(reader.Prefix, reader.LocalName, reader.NamespaceURI); if (HasSchema) { if (context != null) { while (context != null && reader.Depth <= context.Depth) { EndChildren(); } ValidateElementContent(reader.NodeType); } if (reader.Depth == 0 && reader.NodeType == XmlNodeType.Element && SchemaInfo.SchemaType == SchemaType.DTD) { if (!SchemaInfo.DocTypeName.Equals(this.name)) { SendValidationEvent(Res.Sch_RootMatchDocType); } } } if (reader.NodeType == XmlNodeType.Element) { if (schemaNames.IsSchemaRoot(this.name) && !SkipProcess(this.name == schemaNames.QnXsdSchema ? SchemaType.XSD : SchemaType.XDR) && IsCorrectSchemaType(this.name == schemaNames.QnXsdSchema ? SchemaType.XSD : SchemaType.XDR)) { inlineSchemaInfo = new SchemaInfo(schemaNames); inlineSchemaParser = new Parser(schemaCollection, nameTable, schemaNames, validationEventHandler); inlineSchemaParser.StartParsing(reader, null, inlineSchemaInfo); inlineSchemaParser.ParseReaderNode(); } else { ProcessElement(); } } } }
private void ValidateElement() { elementName.Init(reader.LocalName, reader.NamespaceURI); object particle = ValidateChildElement(); if (IsXSDRoot(elementName.Name, elementName.Namespace) && reader.Depth > 0) { _inlineSchemaParser = new Parser(SchemaType.XSD, NameTable, SchemaNames, EventHandler); _inlineSchemaParser.StartParsing(reader, null); ProcessInlineSchema(); } else { ProcessElement(particle); } }