public void CheckNoNamespaceSchemaLocationIs_UsedWhenSpecified_NotUsedWhenFlagIsSet(XmlSchemaValidationFlags allFlags) { XmlSchemaValidator val; XmlSchemaSet schemas = new XmlSchemaSet(); XmlSchemaInfo info = new XmlSchemaInfo(); CValidationEventHolder holder = new CValidationEventHolder(); schemas.Add("", XmlReader.Create(new StringReader("<?xml version=\"1.0\" ?>\n" + "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n" + " <xs:element name=\"root\" />\n" + "</xs:schema>"))); val = CreateValidator(schemas, allFlags); val.XmlResolver = new XmlUrlResolver(); val.ValidationEventHandler += new ValidationEventHandler(holder.CallbackA); val.Initialize(); val.ValidateElement("root", "", info, "type1", null, null, Path.Combine(TestData, XSDFILE_NO_TARGET_NAMESPACE)); if ((int)allFlags == (int)AllFlags) { Assert.True(!holder.IsCalledA); Assert.True(info.SchemaType is XmlSchemaComplexType); } else { Assert.True(holder.IsCalledA); _exVerifier.IsExceptionOk(holder.lastException, "Sch_XsiTypeNotFound", new string[] { "type1" }); } return; }
public void CallForElementWithReferenceToGlobalElement() { XmlSchemaValidator val = CreateValidator(XSDFILE_GET_EXPECTED_PARTICLES); XmlSchemaInfo info = new XmlSchemaInfo(); val.Initialize(); val.ValidateElement("ReferenceElement", "", info); val.ValidateEndOfAttributes(null); foreach (string elem in new string[] { "NestedElement", "foo", "bar" }) { CheckExpectedElements(val.GetExpectedParticles(), new XmlQualifiedName[] { new XmlQualifiedName(elem) }); val.ValidateElement(elem, "", info); val.ValidateEndOfAttributes(null); } foreach (string elem in new string[] { "bar", "foo", "NestedElement" }) { val.ValidateEndElement(info); CheckExpectedElements(val.GetExpectedParticles(), new XmlQualifiedName[] { }); } return; }
public void CallForSequence_Before_After_ValidatingWildcard(String callOrder) { XmlSchemaValidator val; XmlSchemaInfo info = new XmlSchemaInfo(); XmlSchemaSet schemas = new XmlSchemaSet(); XmlSchemaParticle[] result; schemas.Add("", TestData + XSDFILE_GET_EXPECTED_PARTICLES); schemas.Add("uri:tempuri", TestData + XSDFILE_TARGET_NAMESPACE); val = CreateValidator(schemas); val.Initialize(); val.ValidateElement("SequenceWildcardElement", "", info); val.ValidateEndOfAttributes(null); if (callOrder == "before") { result = val.GetExpectedParticles(); Assert.Equal(result.Length, 1); Assert.True(result[0] is XmlSchemaAny); Assert.Equal((result[0] as XmlSchemaAny).Namespace, "uri:tempuri"); Assert.Equal((result[0] as XmlSchemaAny).ProcessContents, XmlSchemaContentProcessing.Strict); } else { val.ValidateElement("elem1", "uri:tempuri", info); val.SkipToEndElement(info); CheckExpectedElements(val.GetExpectedParticles(), new XmlQualifiedName[] { new XmlQualifiedName("foo") }); } return; }
public void CheckThatWarningOccursWhenInvalidNoNamespaceSchemaLocationIsProvided() { XmlSchemaValidator val; XmlSchemaSet schemas = new XmlSchemaSet(); XmlSchemaInfo info = new XmlSchemaInfo(); CValidationEventHolder holder = new CValidationEventHolder(); schemas.Add("", XmlReader.Create(new StringReader("<?xml version=\"1.0\" ?>\n" + "<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n" + " <xs:complexType name=\"rootType\">\n" + " <xs:sequence />\n" + " </xs:complexType>\n" + "</xs:schema>"))); val = CreateValidator(schemas); val.XmlResolver = new XmlUrlResolver(); val.ValidationEventHandler += new ValidationEventHandler(holder.CallbackA); val.Initialize(); val.ValidateElement("root", "", info, "rootType", null, null, Path.Combine(TestData, "__NonExistingFile__.xsd")); Assert.True(holder.IsCalledA); Assert.Equal(holder.lastSeverity, XmlSeverityType.Warning); _exVerifier.IsExceptionOk(holder.lastException, "Sch_CannotLoadSchema", new string[] { "", null }); return; }
public void PassNull_LocalName_NamespaceUri_Invalid_First_Second_Overload(string type, string overload) { XmlSchemaValidator val = CreateValidator(CreateSchemaSetFromXml("<root />")); string name = "root"; string ns = ""; XmlSchemaInfo info = new XmlSchemaInfo(); if (type == "name") { name = null; } else { ns = null; } val.Initialize(); try { if (overload == "first") { val.ValidateElement(name, ns, info); } else { val.ValidateElement(name, ns, info, null, null, null, null); } } catch (ArgumentNullException) { return; } Assert.True(false); }
public void CallWith_Null_False_XsiNil(string xsiNil) { XmlSchemaValidator val; XmlSchemaInfo info = new XmlSchemaInfo(); val = CreateValidator(XSDFILE_VALIDATE_END_ELEMENT); val.Initialize(); val.ValidateElement("NillableElement", "", info, null, xsiNil, null, null); val.ValidateEndOfAttributes(null); try { val.ValidateEndElement(info); } catch (XmlSchemaValidationException e) { _exVerifier.IsExceptionOk(e, new object[] { "Sch_IncompleteContentExpecting", new object[] { "Sch_ElementName", "NillableElement" }, new object[] { "Sch_ElementName", "foo" } }); return; } Assert.True(false); }
public void SanityTestsForNestedElements() { XmlSchemaValidator val; XmlSchemaSet schemas = new XmlSchemaSet(); XmlSchemaInfo info = new XmlSchemaInfo(); schemas.Add("", Path.Combine(TestData, XSDFILE_VALIDATE_END_ELEMENT)); schemas.Compile(); val = CreateValidator(schemas); val.Initialize(); val.ValidateElement("NestedElement", "", info); val.ValidateEndOfAttributes(null); Assert.Equal(info.SchemaElement.QualifiedName, new XmlQualifiedName("NestedElement")); Assert.True(info.SchemaType is XmlSchemaComplexType); val.ValidateElement("foo", "", info); val.ValidateEndOfAttributes(null); Assert.Equal(info.SchemaElement.QualifiedName, new XmlQualifiedName("foo")); Assert.True(info.SchemaType is XmlSchemaComplexType); val.ValidateElement("bar", "", info); Assert.Equal(info.SchemaElement.QualifiedName, new XmlQualifiedName("bar")); Assert.True(info.SchemaType is XmlSchemaSimpleType); Assert.Equal(info.SchemaType.TypeCode, XmlTypeCode.String); return; }
public void InitializeWithAttributeValidate_OtherAttribute_Element_Type(string typeToValidate) { XmlSchemaValidator val; XmlSchemaInfo info = new XmlSchemaInfo(); XmlSchemaSet schemas = new XmlSchemaSet(); schemas.Add("", Path.Combine(TestData, XSDFILE_PARTIAL_VALIDATION)); schemas.Compile(); val = CreateValidator(schemas); val.Initialize(schemas.GlobalAttributes[new XmlQualifiedName("PartialAttribute")]); try { switch (typeToValidate) { case "other": val.ValidateAttribute("PartialAttribute2", "", StringGetter("123"), info); break; case "element": val.ValidateElement("PartialElement", "", info); break; case "type": val.ValidateElement("foo", "", info, "PartialType", null, null, null); break; default: Assert.True(false); break; } } catch (XmlSchemaValidationException e) { switch (typeToValidate) { case "other": _exVerifier.IsExceptionOk(e, "Sch_SchemaAttributeNameMismatch", new string[] { "PartialAttribute2", "PartialAttribute" }); break; case "element": _exVerifier.IsExceptionOk(e, "Sch_ValidateElementInvalidCall"); break; case "type": _exVerifier.IsExceptionOk(e, "Sch_ValidateElementInvalidCall"); break; default: Assert.True(false); break; } return; } Assert.True(false); }
private XmlSchemaObject GetTypeFromAncestors(XmlElement elementToValidate, XmlSchemaObject ancestorType, int ancestorsCount) { this.validator = this.CreateTypeFinderValidator(ancestorType); this.schemaInfo = new XmlSchemaInfo(); int num = ancestorsCount - 1; bool flag = this.AncestorTypeHasWildcard(ancestorType); for (int i = num; i >= 0; i--) { XmlNode parentNode = this.nodeSequenceToValidate[i]; XmlElement elementNode = parentNode as XmlElement; this.ValidateSingleElement(elementNode, false, this.schemaInfo); if (!flag) { elementNode.XmlName = this.document.AddXmlName(elementNode.Prefix, elementNode.LocalName, elementNode.NamespaceURI, this.schemaInfo); flag = this.AncestorTypeHasWildcard(this.schemaInfo.SchemaElement); } this.validator.ValidateEndOfAttributes(null); if (i > 0) { this.ValidateChildrenTillNextAncestor(parentNode, this.nodeSequenceToValidate[i - 1]); } else { this.ValidateChildrenTillNextAncestor(parentNode, elementToValidate); } } this.ValidateSingleElement(elementToValidate, false, this.schemaInfo); XmlSchemaObject schemaElement = null; if (this.schemaInfo.SchemaElement != null) { schemaElement = this.schemaInfo.SchemaElement; } else { schemaElement = this.schemaInfo.SchemaType; } if (schemaElement == null) { if (this.validator.CurrentProcessContents == XmlSchemaContentProcessing.Skip) { if (this.isPartialTreeValid) { return(XmlSchemaComplexType.AnyTypeSkip); } return(schemaElement); } if (this.validator.CurrentProcessContents == XmlSchemaContentProcessing.Lax) { return(XmlSchemaComplexType.AnyType); } } return(schemaElement); }
public void PassNullXmlSchemaInfo__Valid() { XmlSchemaValidator val = CreateValidator(XSDFILE_VALIDATE_ATTRIBUTE); XmlSchemaInfo info = new XmlSchemaInfo(); val.Initialize(); val.ValidateElement("OneAttributeElement", "", null); val.ValidateAttribute("attr", "", StringGetter("foo"), null); return; }
public void Default_Null_ArbitraryObject_XmlReader_XmlDocument_XPathNavigator_ProvidedAsValidationEventSender(string param) { XmlSchemaInfo info = new XmlSchemaInfo(); XmlSchemaValidator val = CreateValidator(CreateSchemaSetFromXml("<root>foo</root>")); CValidationEventHolder holder = new CValidationEventHolder(); object sender = null; val.ValidationEventHandler += new ValidationEventHandler(holder.CallbackA); switch (param) { case "default": sender = val; break; case "null": sender = null; break; case "arbitrary": sender = new ArrayList(); break; case "reader": sender = XmlReader.Create(new StringReader("<root/>")); break; case "document": sender = new XmlDocument(); break; case "navigator": XmlDocument d = new XmlDocument(); sender = d.CreateNavigator(); break; default: Assert.True(false); break; } if (param != "default") { val.ValidationEventSender = sender; } val.Initialize(); val.ValidateElement("bar", "", info); Assert.True(holder.IsCalledA); Assert.Equal(sender, holder.lastObjectSent); return; }
public void CallbackNested(object sender, ValidationEventArgs args) { XmlSchemaInfo info = new XmlSchemaInfo(); (sender as XmlSchemaValidator).SkipToEndElement(info); if (NestingDepth < 3) { NestingDepth++; (sender as XmlSchemaValidator).ValidateElement("bar", "", info); } }
public void CallOnElementWithNoAttributesAfterValidateElement() { XmlSchemaValidator val = CreateValidator(XSDFILE_GET_EXPECTED_ATTRIBUTES); XmlSchemaInfo info = new XmlSchemaInfo(); val.Initialize(); val.ValidateElement("NoAttributesElement", "", info); CheckExpectedAttributes(val.GetExpectedAttributes(), new XmlQualifiedName[] { }); return; }
public void CallOnElementWith_Required_Optional_Default_Fixed_FixedRequired_AttributesAfterValidateElement(String attrType) { XmlSchemaValidator val = CreateValidator(XSDFILE_GET_EXPECTED_ATTRIBUTES); XmlSchemaInfo info = new XmlSchemaInfo(); val.Initialize(); val.ValidateElement(attrType + "AttributesElement", "", info); CheckExpectedAttributes(val.GetExpectedAttributes(), new XmlQualifiedName[] { new XmlQualifiedName("a1"), new XmlQualifiedName("a2") }); return; }
public void CallForElementWithZeroMaxOccurs() { XmlSchemaValidator val = CreateValidator(XSDFILE_GET_EXPECTED_PARTICLES); XmlSchemaInfo info = new XmlSchemaInfo(); val.Initialize(); val.ValidateElement("MaxOccurs0Element", "", info); val.ValidateEndOfAttributes(null); CheckExpectedElements(val.GetExpectedParticles(), new XmlQualifiedName[] { new XmlQualifiedName("bar") }); return; }
public void PassNull() { XmlSchemaValidator val = CreateValidator(XSDFILE_VALIDATE_END_ELEMENT); XmlSchemaInfo info = new XmlSchemaInfo(); val.Initialize(); val.ValidateElement("BasicElement", "", info); val.ValidateEndOfAttributes(null); val.SkipToEndElement(null); return; }
void ValidateAttribute(XAttribute a) { IXmlLineInfo original = SaveLineInfo(a); XmlSchemaInfo si = addSchemaInfo ? new XmlSchemaInfo() : null; source = a; validator.ValidateAttribute(a.Name.LocalName, a.Name.NamespaceName, a.Value, si); if (addSchemaInfo) { ReplaceSchemaInfo(a, si); } RestoreLineInfo(original); }
public void Typed_NullXmlSchemaInfo() { XmlSchemaValidator val = CreateValidator(XSDFILE_VALIDATE_END_ELEMENT); XmlSchemaInfo info = new XmlSchemaInfo(); val.Initialize(); val.ValidateElement("NumberElement", "", info); val.ValidateEndOfAttributes(null); val.ValidateEndElement(null, "123"); return; }
public void ValidateAnyAttribute() { XmlSchemaValidator val = CreateValidator(XSDFILE_VALIDATE_ATTRIBUTE); XmlSchemaInfo info = new XmlSchemaInfo(); val.Initialize(); val.ValidateElement("AnyAttributeElement", "", null); val.ValidateAttribute("SomeAttribute", "", StringGetter("foo"), info); Assert.Equal(XmlSchemaValidity.NotKnown, info.Validity); return; }
public void StringPassedToValidateEndElementDoesNotSatisfyIdentityConstraints() { Initialize(); string xsd = "<xs:schema targetNamespace='http://tempuri.org/XMLSchema.xsd' elementFormDefault='qualified' xmlns='http://tempuri.org/XMLSchema.xsd' xmlns:mstns='http://tempuri.org/XMLSchema.xsd' xmlns:xs='http://www.w3.org/2001/XMLSchema'>" + "<xs:element name='root'>" + "<xs:complexType> <xs:sequence> <xs:element name='B' type='mstns:B'/> </xs:sequence> </xs:complexType>" + "<xs:unique name='pNumKey'><xs:selector xpath='mstns:B/mstns:part'/><xs:field xpath='.'/></xs:unique>" + "</xs:element>" + "<xs:complexType name='B'><xs:sequence><xs:element name='part' maxOccurs='unbounded' type='xs:string'></xs:element></xs:sequence></xs:complexType>" + "</xs:schema>"; XmlSchemaSet ss = new XmlSchemaSet(); ss.Add(XmlSchema.Read(new StringReader(xsd), ValidationCallback)); ss.Compile(); string ns = "http://tempuri.org/XMLSchema.xsd"; XmlNamespaceManager nsmgr = new XmlNamespaceManager(ss.NameTable); XmlSchemaValidator val = new XmlSchemaValidator(ss.NameTable, ss, nsmgr, XmlSchemaValidationFlags.ProcessIdentityConstraints); val.ValidationEventHandler += new ValidationEventHandler(ValidationCallback); val.Initialize(); XmlSchemaInfo si = new XmlSchemaInfo(); val.ValidateElement("root", ns, si); val.ValidateEndOfAttributes(si); val.ValidateElement("B", ns, si); val.ValidateEndOfAttributes(si); val.ValidateElement("part", ns, si); val.ValidateEndOfAttributes(si); val.ValidateText("1"); val.ValidateEndElement(si); val.ValidateElement("part", ns, si); val.ValidateEndOfAttributes(si); val.ValidateEndElement(si, "1"); val.ValidateElement("part", ns, si); val.ValidateEndOfAttributes(si); val.ValidateText("1"); val.ValidateEndElement(si); val.ValidateEndElement(si); val.ValidateEndElement(si); Assert.Equal(0, warningCount); Assert.Equal(2, errorCount); return; }
XsElement element; // ... xsinfo.Element? #endregion public XmlSchemaValidatingReader(XmlReader reader, XmlReaderSettings settings) { IXmlNamespaceResolver nsResolver = reader as IXmlNamespaceResolver; if (nsResolver == null) { // throw new ArgumentException ("Argument XmlReader must implement IXmlNamespaceResolver."); nsResolver = new XmlNamespaceManager(reader.NameTable); } XmlSchemaSet schemas = settings.Schemas; if (schemas == null) { schemas = new XmlSchemaSet(); } options = settings.ValidationFlags; this.reader = reader; v = new XmlSchemaValidator( reader.NameTable, schemas, nsResolver, options); readerLineInfo = reader as IXmlLineInfo; startDepth = reader.Depth; getter = delegate() { return(Value); }; xsinfo = new XmlSchemaInfo(); // transition cache v.LineInfoProvider = this; v.ValidationEventSender = reader; this.nsResolver = nsResolver; #if !NON_MONO ValidationEventHandler += delegate(object o, ValidationEventArgs e) { settings.OnValidationError(o, e); }; if (settings != null && settings.Schemas != null) { v.XmlResolver = settings.Schemas.XmlResolver; } else { v.XmlResolver = new XmlUrlResolver(); } #else v.XmlResolver = new XmlUrlResolver(); #endif v.Initialize(); }
public void ValidateContext(XmlCache xcache) { this._cache = xcache; if (string.IsNullOrEmpty(_cache.FileName)) { _baseUri = null; } else { _baseUri = new Uri(new Uri(xcache.FileName), new Uri(".", UriKind.Relative)); } SchemaResolver resolver = xcache.SchemaResolver as SchemaResolver; resolver.Handler = OnValidationEvent; XmlDocument doc = xcache.Document; this._info = new XmlSchemaInfo(); this._nsResolver = new MyXmlNamespaceResolver(doc.NameTable); XmlSchemaSet set = new XmlSchemaSet(); // Make sure the SchemaCache is up to date with document. SchemaCache sc = xcache.SchemaCache; foreach (XmlSchema s in doc.Schemas.Schemas()) { sc.Add(s); } if (LoadSchemas(doc, set, resolver)) { set.ValidationEventHandler += OnValidationEvent; set.Compile(); set.ValidationEventHandler -= OnValidationEvent; } this._validator = new XmlSchemaValidator(doc.NameTable, set, _nsResolver, XmlSchemaValidationFlags.AllowXmlAttributes | XmlSchemaValidationFlags.ProcessIdentityConstraints | XmlSchemaValidationFlags.ProcessInlineSchema); this._validator.ValidationEventHandler += OnValidationEvent; this._validator.XmlResolver = resolver; this._validator.Initialize(); this._nsResolver.Context = doc; ValidateContent(doc); this._nsResolver.Context = doc; this._validator.EndValidation(); }
public void ValidateAttributesAndSkip() { XmlSchemaValidator val = CreateValidator(XSDFILE_VALIDATE_END_ELEMENT); XmlSchemaInfo info = new XmlSchemaInfo(); val.Initialize(); val.ValidateElement("WithAttributesElement", "", info); val.ValidateAttribute("attr1", "", StringGetter("foo"), info); val.SkipToEndElement(info); Assert.Equal(info.Validity, XmlSchemaValidity.NotKnown); return; }
public void Default_Custom_ValueForLineInfoProvider(string param) { string xmlSrc = "<root><foo>FooText</foo><bar>BarText</bar></root>"; XmlSchemaInfo info = new XmlSchemaInfo(); int lineNum = -1; int linePos = -1; XmlSchemaValidator val = CreateValidator(CreateSchemaSetFromXml(xmlSrc)); switch (param) { case "default": lineNum = 0; linePos = 0; break; case "custom": lineNum = 1111; linePos = 2222; val.LineInfoProvider = new CDummyLineInfo(lineNum, linePos); break; default: Assert.True(false); break; } val.Initialize(); val.ValidateElement("root", "", info); val.ValidateEndOfAttributes(null); val.ValidateElement("foo", "", info); Assert.Equal(val.LineInfoProvider.LineNumber, lineNum); Assert.Equal(val.LineInfoProvider.LinePosition, linePos); val.SkipToEndElement(info); try { val.ValidateElement("bar2", "", info); Assert.True(false); } catch (XmlSchemaValidationException e) { Assert.Equal(e.LineNumber, lineNum); Assert.Equal(e.LinePosition, linePos); } return; }
public void XsdAnyToSkipAttributeValidation() { // bug #358408 XmlSchemaSet schemas = new XmlSchemaSet(); schemas.Add(null, TestResourceHelper.GetFullPathOfResource("Test/XmlFiles/xsd/358408.xsd")); XmlSchemaValidator v = new XmlSchemaValidator( new NameTable(), schemas, new XmlNamespaceManager(new NameTable()), XmlSchemaValidationFlags.ProcessIdentityConstraints); v.Initialize(); v.ValidateWhitespace(" "); XmlSchemaInfo info = new XmlSchemaInfo(); ArrayList list = new ArrayList(); v.ValidateElement("configuration", "", info, null, null, null, null); v.GetUnspecifiedDefaultAttributes(list); v.ValidateEndOfAttributes(info); v.ValidateWhitespace(" "); v.ValidateElement("host", "", info, null, null, null, null); v.ValidateAttribute("auto-start", "", "true", info); list.Clear(); v.GetUnspecifiedDefaultAttributes(list); v.ValidateEndOfAttributes(info); v.ValidateEndElement(null); //info); v.ValidateWhitespace(" "); v.ValidateElement("service-managers", "", info, null, null, null, null); list.Clear(); v.GetUnspecifiedDefaultAttributes(list); v.ValidateEndOfAttributes(info); v.ValidateWhitespace(" "); v.ValidateElement("service-manager", "", info, null, null, null, null); list.Clear(); v.GetUnspecifiedDefaultAttributes(list); v.ValidateEndOfAttributes(info); v.ValidateWhitespace(" "); v.ValidateElement("foo", "", info, null, null, null, null); v.ValidateAttribute("bar", "", "", info); }
public XmlSchemaValidatingReader(XmlReader reader, XmlReaderSettings settings) { XmlSchemaValidatingReader <> f__this = this; IXmlNamespaceResolver xmlNamespaceResolver = reader as IXmlNamespaceResolver; if (xmlNamespaceResolver == null) { xmlNamespaceResolver = new XmlNamespaceManager(reader.NameTable); } XmlSchemaSet xmlSchemaSet = settings.Schemas; if (xmlSchemaSet == null) { xmlSchemaSet = new XmlSchemaSet(); } this.options = settings.ValidationFlags; this.reader = reader; this.v = new XmlSchemaValidator(reader.NameTable, xmlSchemaSet, xmlNamespaceResolver, this.options); if (reader.BaseURI != string.Empty) { this.v.SourceUri = new Uri(reader.BaseURI); } this.readerLineInfo = (reader as IXmlLineInfo); this.getter = delegate() { if (< > f__this.v.CurrentAttributeType != null) { return(< > f__this.v.CurrentAttributeType.ParseValue(< > f__this.Value, <> f__this.NameTable, <> f__this)); } return(< > f__this.Value); }; this.xsinfo = new XmlSchemaInfo(); this.v.LineInfoProvider = this; this.v.ValidationEventSender = reader; this.nsResolver = xmlNamespaceResolver; this.ValidationEventHandler += delegate(object o, ValidationEventArgs e) { settings.OnValidationError(o, e); }; if (settings != null && settings.Schemas != null) { this.v.XmlResolver = settings.Schemas.XmlResolver; } else { this.v.XmlResolver = new XmlUrlResolver(); } this.v.Initialize(); }
public void ValidationCallProducesValidationErrorInsideValidationEventHandler__Nesting() { XmlSchemaInfo info = new XmlSchemaInfo(); XmlSchemaValidator val = CreateValidator(CreateSchemaSetFromXml("<root>foo</root>")); CValidationEventHolder holder = new CValidationEventHolder(); val.ValidationEventHandler += new ValidationEventHandler(holder.CallbackNested); val.Initialize(); val.ValidateElement("bar", "", info); Assert.Equal(holder.NestingDepth, 3); return; }
public void Validate_Required_Optional_Default_Fixed_FixedRequired_Attribute(string attrType) { XmlSchemaValidator val = CreateValidator(XSDFILE_VALIDATE_ATTRIBUTE); XmlSchemaInfo info = new XmlSchemaInfo(); val.Initialize(); val.ValidateElement(attrType + "Element", "", null); val.ValidateAttribute(attrType, "", StringGetter("foo"), info); Assert.Equal(info.SchemaAttribute.QualifiedName, new XmlQualifiedName(attrType)); Assert.Equal(XmlSchemaValidity.Valid, info.Validity); Assert.Equal(XmlTypeCode.String, info.SchemaType.TypeCode); return; }
public void ValidateAttributeWithNamespace() { XmlSchemaValidator val = CreateValidator(XSDFILE_VALIDATE_ATTRIBUTE); XmlSchemaInfo info = new XmlSchemaInfo(); val.Initialize(); val.ValidateElement("NamespaceAttributeElement", "", null); val.ValidateAttribute("attr1", "uri:tempuri", StringGetter("123"), info); Assert.Equal(info.SchemaAttribute.QualifiedName, new XmlQualifiedName("attr1", "uri:tempuri")); Assert.Equal(XmlSchemaValidity.Valid, info.Validity); Assert.Equal(XmlTypeCode.Int, info.SchemaType.TypeCode); return; }
public void SanityTestsForValidationEventHandler() { XmlSchemaInfo info = new XmlSchemaInfo(); XmlSchemaValidator val = CreateValidator(CreateSchemaSetFromXml("<root>foo</root>")); CValidationEventHolder holder = new CValidationEventHolder(); val.ValidationEventHandler += new ValidationEventHandler(holder.CallbackA); val.Initialize(); val.ValidateElement("bar", "", info); Assert.True(holder.IsCalledA); return; }
public object ValidateAttribute(string localName, string namespaceUri, XmlValueGetter attributeValue, XmlSchemaInfo schemaInfo) { }
public void SkipToEndElement(XmlSchemaInfo schemaInfo) { }
public void ValidateEndOfAttributes(XmlSchemaInfo schemaInfo) { }
public object ValidateEndElement(XmlSchemaInfo schemaInfo, object typedValue) { }
public object ValidateEndElement(XmlSchemaInfo schemaInfo) { }
public void ValidateElement(string localName, string namespaceUri, XmlSchemaInfo schemaInfo) { }
public void ValidateElement(string localName, string namespaceUri, XmlSchemaInfo schemaInfo, string xsiType, string xsiNil, string xsiSchemaLocation, string xsiNoNamespaceSchemaLocation) { }