public void ImportAnotherSchemaThat_Is_IsNot_InSchemaSet(bool importTwice)
{
XmlSchemaValidator val;
XmlSchemaInfo info = new XmlSchemaInfo();
Uri u = new Uri(Uri.UriSchemeFile + Uri.SchemeDelimiter + Path.Combine(Path.GetFullPath(TestData), XSDFILE_TARGET_NAMESPACE));
XmlSchema s1;
XmlSchemaSet schemas = new XmlSchemaSet();
schemas.XmlResolver = new XmlUrlResolver();
val = CreateValidator(new XmlSchemaSet());
s1 = XmlSchema.Read(new StringReader("<?xml version=\"1.0\"?>\n" +
"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"\n" +
" xmlns:temp=\"uri:tempuri\">\n" +
" <xs:import namespace=\"uri:tempuri\"\n" +
" schemaLocation=\"" + u.AbsoluteUri + "\" />\n" +
" <xs:element name=\"root\">\n" +
" <xs:complexType>\n" +
" <xs:sequence>\n" +
" <xs:element ref=\"temp:elem1\" />\n" +
" </xs:sequence>\n" +
" </xs:complexType>\n" +
" </xs:element>\n" +
"</xs:schema>"), null);
schemas.Add(s1);
if (importTwice)
{
foreach (XmlSchema s in schemas.Schemas("uri:tempuri"))
val.AddSchema(s);
}
val.AddSchema(s1);
val.Initialize();
val.ValidateElement("root", "", info);
val.ValidateEndOfAttributes(null);
val.ValidateElement("elem1", "uri:tempuri", info);
val.ValidateEndOfAttributes(null);
val.ValidateEndElement(info);
val.ValidateEndElement(info);
val.EndValidation();
return;
}