internal static XmlSchemaSimpleType StartBuiltinType(XmlQualifiedName qname, XmlSchemaDatatype dataType) { XmlSchemaSimpleType type = new XmlSchemaSimpleType(); type.SetQualifiedName(qname); type.SetDatatype(dataType); type.ElementDecl = new SchemaElementDecl(dataType); type.ElementDecl.SchemaType = type; return(type); }
internal static XmlSchemaSimpleType GetNormalizedStringTypeV1Compat() { if (normalizedStringTypeV1Compat == null) { normalizedStringTypeV1Compat = GetSimpleTypeFromTypeCode(XmlTypeCode.NormalizedString).Clone() as XmlSchemaSimpleType; normalizedStringTypeV1Compat.SetDatatype(c_normalizedStringV1Compat); normalizedStringTypeV1Compat.ElementDecl = new SchemaElementDecl(c_normalizedStringV1Compat); normalizedStringTypeV1Compat.ElementDecl.SchemaType = normalizedStringTypeV1Compat; } return(normalizedStringTypeV1Compat); }
internal static XmlSchemaSimpleType GetTokenTypeV1Compat() { if (tokenTypeV1Compat == null) { tokenTypeV1Compat = GetSimpleTypeFromTypeCode(XmlTypeCode.Token).Clone() as XmlSchemaSimpleType; tokenTypeV1Compat.SetDatatype(c_tokenV1Compat); tokenTypeV1Compat.ElementDecl = new SchemaElementDecl(c_tokenV1Compat); tokenTypeV1Compat.ElementDecl.SchemaType = tokenTypeV1Compat; } return(tokenTypeV1Compat); }
private void CompileSimpleType(XmlSchemaSimpleType simpleType) { if (simpleType.IsProcessing) { throw new XmlSchemaException("Sch_TypeCircularRef", simpleType); } if (simpleType.ElementDecl == null) { simpleType.IsProcessing = true; try { if (simpleType.Content is XmlSchemaSimpleTypeList) { XmlSchemaDatatype datatype; XmlSchemaSimpleTypeList content = (XmlSchemaSimpleTypeList) simpleType.Content; simpleType.SetBaseSchemaType(DatatypeImplementation.AnySimpleType); if (content.ItemTypeName.IsEmpty) { this.CompileSimpleType(content.ItemType); content.BaseItemType = content.ItemType; datatype = content.ItemType.Datatype; } else { XmlSchemaSimpleType type = this.GetSimpleType(content.ItemTypeName); if (type == null) { throw new XmlSchemaException("Sch_UndeclaredSimpleType", content.ItemTypeName.ToString(), simpleType); } if ((type.FinalResolved & XmlSchemaDerivationMethod.List) != XmlSchemaDerivationMethod.Empty) { base.SendValidationEvent("Sch_BaseFinalList", simpleType); } content.BaseItemType = type; datatype = type.Datatype; } simpleType.SetDatatype(datatype.DeriveByList(simpleType)); simpleType.SetDerivedBy(XmlSchemaDerivationMethod.List); } else if (simpleType.Content is XmlSchemaSimpleTypeRestriction) { XmlSchemaDatatype datatype2; XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction) simpleType.Content; if (restriction.BaseTypeName.IsEmpty) { this.CompileSimpleType(restriction.BaseType); simpleType.SetBaseSchemaType(restriction.BaseType); datatype2 = restriction.BaseType.Datatype; } else if ((simpleType.Redefined != null) && (restriction.BaseTypeName == simpleType.Redefined.QualifiedName)) { this.CompileSimpleType((XmlSchemaSimpleType) simpleType.Redefined); simpleType.SetBaseSchemaType(simpleType.Redefined.BaseXmlSchemaType); datatype2 = simpleType.Redefined.Datatype; } else { if (restriction.BaseTypeName.Equals(DatatypeImplementation.QnAnySimpleType)) { throw new XmlSchemaException("Sch_InvalidSimpleTypeRestriction", restriction.BaseTypeName.ToString(), simpleType); } XmlSchemaSimpleType type2 = this.GetSimpleType(restriction.BaseTypeName); if (type2 == null) { throw new XmlSchemaException("Sch_UndeclaredSimpleType", restriction.BaseTypeName.ToString(), simpleType); } if ((type2.FinalResolved & XmlSchemaDerivationMethod.Restriction) != XmlSchemaDerivationMethod.Empty) { base.SendValidationEvent("Sch_BaseFinalRestriction", simpleType); } simpleType.SetBaseSchemaType(type2); datatype2 = type2.Datatype; } simpleType.SetDatatype(datatype2.DeriveByRestriction(restriction.Facets, base.NameTable, simpleType)); simpleType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction); } else { XmlSchemaSimpleType[] types = this.CompileBaseMemberTypes(simpleType); simpleType.SetBaseSchemaType(DatatypeImplementation.AnySimpleType); simpleType.SetDatatype(XmlSchemaDatatype.DeriveByUnion(types, simpleType)); simpleType.SetDerivedBy(XmlSchemaDerivationMethod.Union); } } catch (XmlSchemaException exception) { if (exception.SourceSchemaObject == null) { exception.SetSource(simpleType); } base.SendValidationEvent(exception); simpleType.SetDatatype(DatatypeImplementation.AnySimpleType.Datatype); } finally { SchemaElementDecl decl = new SchemaElementDecl { ContentValidator = ContentValidator.TextOnly, SchemaType = simpleType, Datatype = simpleType.Datatype }; simpleType.ElementDecl = decl; simpleType.IsProcessing = false; } } }
/// <summary> /// Begin the creation of an XmlSchemaSimpleType object that will be used to represent a static built-in type. /// Once StartBuiltinType has been called for all built-in types, FinishBuiltinType should be called in order /// to create links between the types. /// </summary> internal static XmlSchemaSimpleType StartBuiltinType(XmlQualifiedName qname, XmlSchemaDatatype dataType) { XmlSchemaSimpleType simpleType; Debug.Assert(qname != null && dataType != null); simpleType = new XmlSchemaSimpleType(); simpleType.SetQualifiedName(qname); simpleType.SetDatatype(dataType); simpleType.ElementDecl = new SchemaElementDecl(dataType); simpleType.ElementDecl.SchemaType = simpleType; return simpleType; }
private void CompileSimpleType(XmlSchemaSimpleType simpleType) { if (simpleType.IsProcessing) { throw new XmlSchemaException(Res.Sch_TypeCircularRef, simpleType); } if (simpleType.ElementDecl != null) { // already compiled return; } simpleType.IsProcessing = true; try { if (simpleType.Content is XmlSchemaSimpleTypeList) { XmlSchemaSimpleTypeList list = (XmlSchemaSimpleTypeList)simpleType.Content; XmlSchemaDatatype datatype; simpleType.SetBaseSchemaType(DatatypeImplementation.AnySimpleType); if (list.ItemTypeName.IsEmpty) { CompileSimpleType(list.ItemType); list.BaseItemType = list.ItemType; datatype = list.ItemType.Datatype; } else { XmlSchemaSimpleType type = GetSimpleType(list.ItemTypeName); if (type != null) { if ((type.FinalResolved & XmlSchemaDerivationMethod.List) != 0) { SendValidationEvent(Res.Sch_BaseFinalList, simpleType); } list.BaseItemType = type; datatype = type.Datatype; } else { throw new XmlSchemaException(Res.Sch_UndeclaredSimpleType, list.ItemTypeName.ToString(), list); } } simpleType.SetDatatype(datatype.DeriveByList(simpleType)); simpleType.SetDerivedBy(XmlSchemaDerivationMethod.List); } else if (simpleType.Content is XmlSchemaSimpleTypeRestriction) { XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction)simpleType.Content; XmlSchemaDatatype datatype; if (restriction.BaseTypeName.IsEmpty) { CompileSimpleType(restriction.BaseType); simpleType.SetBaseSchemaType(restriction.BaseType); datatype = restriction.BaseType.Datatype; } else if (simpleType.Redefined != null && restriction.BaseTypeName == simpleType.Redefined.QualifiedName) { CompileSimpleType((XmlSchemaSimpleType)simpleType.Redefined); simpleType.SetBaseSchemaType(simpleType.Redefined.BaseXmlSchemaType); datatype = simpleType.Redefined.Datatype; } else { if (restriction.BaseTypeName.Equals(DatatypeImplementation.QnAnySimpleType)) { XmlSchema parentSchema = Preprocessor.GetParentSchema(simpleType); if (parentSchema.TargetNamespace != XmlSchema.Namespace) { //If it is not SForS, then error throw new XmlSchemaException(Res.Sch_InvalidSimpleTypeRestriction, restriction.BaseTypeName.ToString(), simpleType); } } XmlSchemaSimpleType type = GetSimpleType(restriction.BaseTypeName); if (type != null) { if ((type.FinalResolved & XmlSchemaDerivationMethod.Restriction) != 0) { SendValidationEvent(Res.Sch_BaseFinalRestriction, simpleType); } simpleType.SetBaseSchemaType(type); datatype = type.Datatype; } else { throw new XmlSchemaException(Res.Sch_UndeclaredSimpleType, restriction.BaseTypeName.ToString(), restriction); } } simpleType.SetDatatype(datatype.DeriveByRestriction(restriction.Facets, NameTable, simpleType)); simpleType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction); } else { //simpleType.Content is XmlSchemaSimpleTypeUnion XmlSchemaSimpleType[] baseTypes = CompileBaseMemberTypes(simpleType); simpleType.SetBaseSchemaType(DatatypeImplementation.AnySimpleType); simpleType.SetDatatype(XmlSchemaDatatype.DeriveByUnion(baseTypes, simpleType)); simpleType.SetDerivedBy(XmlSchemaDerivationMethod.Union); } } catch (XmlSchemaException e) { if (e.SourceSchemaObject == null) { e.SetSource(simpleType); } SendValidationEvent(e); simpleType.SetDatatype(DatatypeImplementation.AnySimpleType.Datatype); } finally { SchemaElementDecl decl = new SchemaElementDecl(); decl.ContentValidator = ContentValidator.TextOnly; decl.SchemaType = simpleType; decl.Datatype = simpleType.Datatype; simpleType.ElementDecl = decl; simpleType.IsProcessing = false; } }
internal static XmlSchemaSimpleType GetTokenTypeV1Compat() { if (tokenTypeV1Compat == null) { XmlSchemaSimpleType correctType = GetSimpleTypeFromTypeCode(XmlTypeCode.Token); tokenTypeV1Compat = correctType.Clone() as XmlSchemaSimpleType; tokenTypeV1Compat.SetDatatype(c_tokenV1Compat); tokenTypeV1Compat.ElementDecl = new SchemaElementDecl(c_tokenV1Compat); tokenTypeV1Compat.ElementDecl.SchemaType = tokenTypeV1Compat; } return tokenTypeV1Compat; }
internal static XmlSchemaSimpleType GetNormalizedStringTypeV1Compat() { if (normalizedStringTypeV1Compat == null) { XmlSchemaSimpleType correctType = GetSimpleTypeFromTypeCode(XmlTypeCode.NormalizedString); normalizedStringTypeV1Compat = correctType.Clone() as XmlSchemaSimpleType; normalizedStringTypeV1Compat.SetDatatype(c_normalizedStringV1Compat); normalizedStringTypeV1Compat.ElementDecl = new SchemaElementDecl(c_normalizedStringV1Compat); normalizedStringTypeV1Compat.ElementDecl.SchemaType = normalizedStringTypeV1Compat; } return normalizedStringTypeV1Compat; }
private void CompileSimpleType(XmlSchemaSimpleType simpleType) { if (simpleType.Validating) { throw new XmlSchemaException(Res.Sch_TypeCircularRef, simpleType); } if (simpleType.ElementDecl != null) { // already compiled return; } simpleType.Validating = true; try { if (simpleType.Content is XmlSchemaSimpleTypeList) { XmlSchemaSimpleTypeList list = (XmlSchemaSimpleTypeList)simpleType.Content; XmlSchemaDatatype datatype; if (list.ItemTypeName.IsEmpty) { CompileSimpleType(list.ItemType); simpleType.SetBaseSchemaType(list.ItemType); datatype = list.ItemType.Datatype; } else { datatype = GetDatatype(list.ItemTypeName); if (datatype != null) { simpleType.SetBaseSchemaType(datatype); } else { XmlSchemaSimpleType type = GetSimpleType(list.ItemTypeName); if (type != null) { if ((type.FinalResolved & XmlSchemaDerivationMethod.List) != 0) { SendValidationEvent(Res.Sch_BaseFinalList, simpleType); } simpleType.SetBaseSchemaType(type); datatype = type.Datatype; } else { throw new XmlSchemaException(Res.Sch_UndeclaredSimpleType, list.ItemTypeName.ToString(), simpleType); } } } simpleType.SetDatatype(datatype.DeriveByList()); simpleType.SetDerivedBy(XmlSchemaDerivationMethod.List); } else if (simpleType.Content is XmlSchemaSimpleTypeRestriction) { XmlSchemaSimpleTypeRestriction restriction = (XmlSchemaSimpleTypeRestriction)simpleType.Content; XmlSchemaDatatype datatype; if (restriction.BaseTypeName.IsEmpty) { CompileSimpleType(restriction.BaseType); simpleType.SetBaseSchemaType(restriction.BaseType); datatype = restriction.BaseType.Datatype; } else if (simpleType.Redefined != null && restriction.BaseTypeName == simpleType.Redefined.QualifiedName) { CompileSimpleType((XmlSchemaSimpleType)simpleType.Redefined); simpleType.SetBaseSchemaType(simpleType.Redefined.BaseSchemaType); datatype = simpleType.Redefined.Datatype; } else { datatype = GetDatatype(restriction.BaseTypeName); if (datatype != null) { simpleType.SetBaseSchemaType(datatype); } else { XmlSchemaSimpleType type = GetSimpleType(restriction.BaseTypeName); if (type != null) { if ((type.FinalResolved & XmlSchemaDerivationMethod.Restriction) != 0) { SendValidationEvent(Res.Sch_BaseFinalRestriction, simpleType); } simpleType.SetBaseSchemaType(type); datatype = type.Datatype; } else { throw new XmlSchemaException(Res.Sch_UndeclaredSimpleType, restriction.BaseTypeName.ToString(), simpleType); } } } simpleType.SetDatatype(datatype.DeriveByRestriction(restriction.Facets, this.nameTable)); simpleType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction); } else { //simpleType.Content is XmlSchemaSimpleTypeUnion XmlSchemaSimpleTypeUnion union1 = (XmlSchemaSimpleTypeUnion)simpleType.Content; int baseTypeCount = union1.BaseTypes.Count; if (union1.MemberTypes != null) { baseTypeCount += union1.MemberTypes.Length; } object[] baseTypes = new object[baseTypeCount]; XmlSchemaDatatype[] baseDatatypes = new XmlSchemaDatatype[baseTypeCount]; int idx = 0; if (union1.MemberTypes != null) { foreach (XmlQualifiedName qname in union1.MemberTypes) { XmlSchemaDatatype datatype = GetDatatype(qname); if (datatype != null) { baseTypes[idx] = datatype; baseDatatypes[idx ++] = datatype; } else { XmlSchemaSimpleType type = GetSimpleType(qname); if (type != null) { if ((type.FinalResolved & XmlSchemaDerivationMethod.Union) != 0) { SendValidationEvent(Res.Sch_BaseFinalUnion, simpleType); } baseTypes[idx] = type; baseDatatypes[idx ++] = type.Datatype; } else { throw new XmlSchemaException(Res.Sch_UndeclaredSimpleType, qname.ToString(), simpleType); } } } } foreach (XmlSchemaSimpleType st in union1.BaseTypes) { CompileSimpleType(st); baseTypes[idx] = st; baseDatatypes[idx ++] = st.Datatype; } simpleType.SetBaseSchemaType(baseTypes); simpleType.SetDatatype(XmlSchemaDatatype.DeriveByUnion(baseDatatypes)); simpleType.SetDerivedBy(XmlSchemaDerivationMethod.Union); } } catch (XmlSchemaException e) { if (e.SourceSchemaObject == null) { e.SetSource(simpleType); } SendValidationEvent(e); simpleType.SetDatatype(XmlSchemaDatatype.AnyType); } finally { SchemaElementDecl decl = new SchemaElementDecl(); decl.Content = new CompiledContentModel(this.schemaNames); decl.Content.ContentType = CompiledContentModel.Type.Text; decl.SchemaType = simpleType; decl.Datatype = simpleType.Datatype; simpleType.ElementDecl = decl; simpleType.Validating = false; } }
internal static XmlSchemaSimpleType StartBuiltinType(XmlQualifiedName qname, XmlSchemaDatatype dataType) { XmlSchemaSimpleType type = new XmlSchemaSimpleType(); type.SetQualifiedName(qname); type.SetDatatype(dataType); type.ElementDecl = new SchemaElementDecl(dataType); type.ElementDecl.SchemaType = type; return type; }