+2006-07-27 Atsushi Enomoto <atsushi@ximian.com>
+
+ * XmlSchema.cs, XmlSchemaSimpleTypeList.cs,
+ XmlSchemaSimpleContentRestriction.cs, XmlSchemaUtil.cs,
+ XmlSchemaSimpleContentExtension.cs, XmlSchemaElement.cs,
+ XmlSchemaComplexType.cs, XmlSchemaSimpleTypeRestriction.cs,
+ XmlSchemaSimpleTypeUnion.cs, XmlSchemaAttribute.cs :
+ Finally fixed bugs around cross-referencing importing schema
+ components (namely, #77489 and #78220) by resolving referenced
+ components via new internal Find[Element|Attribute|AttributeGroup|
+ SchemaType] methods in XmlSchema.
+
2006-07-27 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchema.cs : set ValidationEventHandler to XmlSchemaSet only
#endregion
+ internal XmlSchemaAttribute FindAttribute (XmlQualifiedName name)
+ {
+ XmlSchemaAttribute a;
+ foreach (XmlSchema schema in schemas.Schemas ()) {
+ a = schema.Attributes [name] as XmlSchemaAttribute;
+ if (a != null)
+ return a;
+ }
+ return null;
+ }
+
+ internal XmlSchemaAttributeGroup FindAttributeGroup (XmlQualifiedName name)
+ {
+ XmlSchemaAttributeGroup a;
+ foreach (XmlSchema schema in schemas.Schemas ()) {
+ a = schema.AttributeGroups [name] as XmlSchemaAttributeGroup;
+ if (a != null)
+ return a;
+ }
+ return null;
+ }
+
+ internal XmlSchemaElement FindElement (XmlQualifiedName name)
+ {
+ XmlSchemaElement a;
+ foreach (XmlSchema schema in schemas.Schemas ()) {
+ a = schema.Elements [name] as XmlSchemaElement;
+ if (a != null)
+ return a;
+ }
+ return null;
+ }
+
+ internal XmlSchemaType FindSchemaType (XmlQualifiedName name)
+ {
+ XmlSchemaType a;
+ foreach (XmlSchema schema in schemas.Schemas ()) {
+ a = schema.SchemaTypes [name] as XmlSchemaType;
+ if (a != null)
+ return a;
+ }
+ return null;
+ }
+
internal void Validate (ValidationEventHandler handler)
{
ValidationId = CompilationId;
else if (SchemaTypeName != null && SchemaTypeName != XmlQualifiedName.Empty)\r
{\r
// If type is null, then it is missing sub components .\r
- XmlSchemaType type = schema.SchemaTypes [SchemaTypeName] as XmlSchemaType;\r
+ XmlSchemaType type = schema.FindSchemaType (SchemaTypeName);\r
if (type is XmlSchemaComplexType)\r
error(h,"An attribute can't have complexType Content");\r
else if (type != null) { // simple type\r
// Then, fill type information for the type references for the referencing attributes\r
if (RefName != null && RefName != XmlQualifiedName.Empty)\r
{\r
- referencedAttribute = schema.Attributes [RefName] as XmlSchemaAttribute;\r
+ referencedAttribute = schema.FindAttribute (RefName);\r
// If el is null, then it is missing sub components .\r
if (referencedAttribute != null)\r
errorCount += referencedAttribute.Validate (h, schema);\r
if (contentModel != null) {\r
BaseSchemaTypeName = contentModel.Content != null ? contentModel.Content.GetBaseTypeName () : XmlQualifiedName.Empty;\r
\r
- BaseXmlSchemaTypeInternal = schema.SchemaTypes [BaseSchemaTypeName] as XmlSchemaType;\r
+ BaseXmlSchemaTypeInternal = schema.FindSchemaType(BaseSchemaTypeName);\r
}\r
// Resolve redefine.\r
if (this.isRedefineChild && BaseXmlSchemaType != null && this.QualifiedName == BaseSchemaTypeName) {\r
if (schemaType != null)\r
elementType = schemaType;\r
else if (SchemaTypeName != XmlQualifiedName.Empty) {\r
- XmlSchemaType type = schema.SchemaTypes [SchemaTypeName] as XmlSchemaType;\r
+ XmlSchemaType type = schema.FindSchemaType (SchemaTypeName);\r
if (type != null) {\r
type.Validate (h, schema);\r
elementType = type;\r
if (IsValidated (schema.ValidationId))\r
return errorCount;\r
\r
- XmlSchemaType st = schema.SchemaTypes [baseTypeName] as XmlSchemaType;\r
+ XmlSchemaType st = schema.FindSchemaType (baseTypeName);\r
if (st != null) {\r
XmlSchemaComplexType ct = st as XmlSchemaComplexType;\r
if (ct != null && ct.ContentModel is XmlSchemaComplexContent)\r
actualBaseSchemaType = baseType;\r
}\r
else if (baseTypeName != XmlQualifiedName.Empty) {\r
- XmlSchemaType st = schema.SchemaTypes [baseTypeName] as XmlSchemaType;\r
+ XmlSchemaType st = schema.FindSchemaType (baseTypeName);\r
if (st != null) {\r
st.Validate (h, schema);\r
actualBaseSchemaType = st;\r
// ListItemType\r
XmlSchemaSimpleType type = itemType;\r
if (type == null)\r
- type = schema.SchemaTypes [itemTypeName] as XmlSchemaSimpleType;\r
+ type = schema.FindSchemaType (itemTypeName) as XmlSchemaSimpleType;\r
if (type != null) {\r
errorCount += type.Validate (h, schema);\r
validatedListItemType = type;\r
\r
XmlSchemaSimpleType type = baseType;\r
if (type == null)\r
- type = schema.SchemaTypes [baseTypeName] as XmlSchemaSimpleType;\r
+ type = schema.FindSchemaType (baseTypeName) as XmlSchemaSimpleType;\r
if (type != null) {\r
if (validate)\r
errorCount += type.Validate (h, schema);\r
if (MemberTypes != null) {\r
foreach (XmlQualifiedName memberTypeName in MemberTypes) {\r
object type = null;\r
- XmlSchemaType xstype = schema.SchemaTypes [memberTypeName] as XmlSchemaSimpleType;\r
+ XmlSchemaType xstype = schema.FindSchemaType (memberTypeName) as XmlSchemaSimpleType;\r
if (xstype != null) {\r
errorCount += xstype.Validate (h, schema);\r
type = xstype;\r
if (redefined != null && grpRef.RefName == redefined.QualifiedName)\r
grp = redefined;\r
else\r
- grp = schema.AttributeGroups [grpRef.RefName] as XmlSchemaAttributeGroup;\r
+ grp = schema.FindAttributeGroup (grpRef.RefName);\r
// otherwise, it might be missing sub components.\r
if (grp == null) {\r
if (!schema.missedSubComponents)// && schema.Schemas [grpRef.RefName.Namespace] != null)\r
+2006-07-27 Atsushi Enomoto <atsushi@ximian.com>
+
+ * XmlSchemaSetTest.cs : added bug #77489 case.
+ * XmlSchemaCollectionTests.cs : removed NotWorking from #77820 case.
+
2006-07-27 Atsushi Enomoto <atsushi@ximian.com>
* XmlSchemaSetTests.cs : added AddWrongTargetNamespace().
}
[Test] // bug #78220
- [Category ("NotWorking")]
public void TestCompile ()
{
string schemaFragment1 = string.Format (CultureInfo.InvariantCulture,
ss.RemoveRecursive (s);
Assert.IsTrue (ss.IsCompiled, "#5");
}
+
+ [Test] // bug #77489
+ public void CrossSchemaReferences ()
+ {
+ string schema1 = @"<xsd:schema id=""Base.Schema"" elementFormDefault=""qualified"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
+ <xsd:complexType name=""itemBase"" abstract=""true"">
+ <xsd:attribute name=""id"" type=""xsd:string""
+use=""required""/>
+ <xsd:attribute name=""type"" type=""xsd:string""
+use=""required""/>
+ </xsd:complexType>
+</xsd:schema>";
+
+ string schema2 = @"<xsd:schema id=""Sub.Schema"" elementFormDefault=""qualified"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
+ <xsd:complexType name=""item"">
+ <xsd:complexContent>
+ <xsd:extension base=""itemBase"">
+ <xsd:attribute name=""itemName""
+type=""xsd:string"" use=""required""/>
+ </xsd:extension>
+ </xsd:complexContent>
+ </xsd:complexType>
+</xsd:schema>";
+ XmlSchemaSet schemas = new XmlSchemaSet ();
+ schemas.Add (XmlSchema.Read (new StringReader (schema1), null));
+ schemas.Add (XmlSchema.Read (new StringReader (schema2), null));
+ schemas.Compile ();
+ }
}
}
#endif