///<remarks> /// 1. Content must be present and one of restriction or extention ///</remarks> internal override int Compile(ValidationEventHandler h, XmlSchema schema) { // If this is already compiled this time, simply skip. if (CompilationId == schema.CompilationId) { return(0); } if (Content == null) { error(h, "Content must be present in a simpleContent"); } else { if (Content is XmlSchemaSimpleContentRestriction) { XmlSchemaSimpleContentRestriction xscr = (XmlSchemaSimpleContentRestriction)Content; errorCount += xscr.Compile(h, schema); } else if (Content is XmlSchemaSimpleContentExtension) { XmlSchemaSimpleContentExtension xsce = (XmlSchemaSimpleContentExtension)Content; errorCount += xsce.Compile(h, schema); } else { error(h, "simpleContent can't have any value other than restriction or extention"); } } XmlSchemaUtil.CompileID(Id, this, schema.IDCollection, h); this.CompilationId = schema.CompilationId; return(errorCount); }
internal override int Compile(ValidationEventHandler h, XmlSchema schema) { if (this.CompilationId == schema.CompilationId) { return(0); } if (this.Content == null) { base.error(h, "Content must be present in a simpleContent"); } else if (this.Content is XmlSchemaSimpleContentRestriction) { XmlSchemaSimpleContentRestriction xmlSchemaSimpleContentRestriction = (XmlSchemaSimpleContentRestriction)this.Content; this.errorCount += xmlSchemaSimpleContentRestriction.Compile(h, schema); } else if (this.Content is XmlSchemaSimpleContentExtension) { XmlSchemaSimpleContentExtension xmlSchemaSimpleContentExtension = (XmlSchemaSimpleContentExtension)this.Content; this.errorCount += xmlSchemaSimpleContentExtension.Compile(h, schema); } else { base.error(h, "simpleContent can't have any value other than restriction or extention"); } XmlSchemaUtil.CompileID(base.Id, this, schema.IDCollection, h); this.CompilationId = schema.CompilationId; return(this.errorCount); }
private SOMList GetAttributes(ComplexType ct) { if (ct.ContentModel == null) { return(ct.Attributes); } SimpleModel sc = ct.ContentModel as SimpleModel; if (sc != null) { SimpleExt sce = sc.Content as SimpleExt; if (sce != null) { return(sce.Attributes); } SimpleRst scr = sc.Content as SimpleRst; if (scr != null) { return(scr.Attributes); } else { throw Error(sc, "Invalid simple content model."); } } ComplexModel cc = ct.ContentModel as ComplexModel; if (cc != null) { ComplexExt cce = cc.Content as ComplexExt; if (cce != null) { return(cce.Attributes); } ComplexRst ccr = cc.Content as ComplexRst; if (ccr != null) { return(ccr.Attributes); } else { throw Error(cc, "Invalid simple content model."); } } throw Error(cc, "Invalid complexType. Should not happen."); }
private void ToEmptiableSimpleContent( SimpleModel sm, bool isNew) { SimpleExt se = sm.Content as SimpleExt; if (se != null) { se.BaseTypeName = QNameString; } else { SimpleRst sr = sm.Content as SimpleRst; if (sr == null) { throw Error(sm, "Invalid simple content model was passed."); } sr.BaseTypeName = QNameString; sr.BaseType = null; } }
private ComplexType ToComplexType (Element el) { QName name = el.SchemaTypeName; XmlSchemaType type = el.SchemaType; // 1. element type is complex. ComplexType ct = type as ComplexType; if (ct != null) return ct; // 2. reference to global complexType. XmlSchemaType globalType = schemas.GlobalTypes [name] as XmlSchemaType; ct = globalType as ComplexType; if (ct != null) return ct; ct = new ComplexType (); el.SchemaType = ct; el.SchemaTypeName = QName.Empty; // 3. base type name is xs:anyType or no specification. // <xs:complexType /> if (name == QNameAnyType) return ct; else if (type == null && name == QName.Empty) return ct; SimpleModel sc = new SimpleModel (); ct.ContentModel = sc; // 4. type is simpleType // -> extension of existing simple type. SimpleType st = type as SimpleType; if (st != null) { SimpleRst scr = new SimpleRst (); scr.BaseType = st; sc.Content = scr; return ct; } SimpleExt sce = new SimpleExt (); sc.Content = sce; // 5. type name points to primitive type // -> simple extension of a primitive type st = XmlSchemaType.GetBuiltInSimpleType (name); if (st != null) { sce.BaseTypeName = name; return ct; } // 6. type name points to global simpleType. st = globalType as SimpleType; if (st != null) { sce.BaseTypeName = name; return ct; } throw Error (el, "Unexpected schema component that contains simpleTypeName that could not be resolved."); }
//<restriction //base = QName //id = ID //{any attributes with non-schema namespace . . .}> //Content: (annotation?, (simpleType?, (minExclusive | minInclusive | maxExclusive | maxInclusive | totalDigits | fractionDigits | length | minLength | maxLength | enumeration | whiteSpace | pattern)*)?, ((attribute | attributeGroup)*, anyAttribute?)) //</restriction> internal static XmlSchemaSimpleContentRestriction Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleContentRestriction restriction = new XmlSchemaSimpleContentRestriction(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaComplexContentRestriction.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } restriction.LineNumber = reader.LineNumber; restriction.LinePosition = reader.LinePosition; restriction.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "base") { Exception innerex; restriction.baseTypeName = XmlSchemaUtil.ReadQNameAttribute(reader, out innerex); if (innerex != null) { error(h, reader.Value + " is not a valid value for base attribute", innerex); } } else if (reader.Name == "id") { restriction.Id = reader.Value; } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for restriction", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, restriction); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(restriction); } //Content: 1.annotation?, // 2.simpleType?, // 3.(minExclusive |...| enumeration | whiteSpace | pattern)*, // 4.(attribute | attributeGroup)*, // 5.anyAttribute? int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaSimpleContentRestriction.Read, name=" + reader.Name, null); } break; } if (level <= 1 && reader.LocalName == "annotation") { level = 2; //Only one annotation XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader, h); if (annotation != null) { restriction.Annotation = annotation; } continue; } if (level <= 2 && reader.LocalName == "simpleType") { level = 3; XmlSchemaSimpleType stype = XmlSchemaSimpleType.Read(reader, h); if (stype != null) { restriction.baseType = stype; } continue; } if (level <= 3) { if (reader.LocalName == "minExclusive") { level = 3; XmlSchemaMinExclusiveFacet minex = XmlSchemaMinExclusiveFacet.Read(reader, h); if (minex != null) { restriction.facets.Add(minex); } continue; } else if (reader.LocalName == "minInclusive") { level = 3; XmlSchemaMinInclusiveFacet mini = XmlSchemaMinInclusiveFacet.Read(reader, h); if (mini != null) { restriction.facets.Add(mini); } continue; } else if (reader.LocalName == "maxExclusive") { level = 3; XmlSchemaMaxExclusiveFacet maxex = XmlSchemaMaxExclusiveFacet.Read(reader, h); if (maxex != null) { restriction.facets.Add(maxex); } continue; } else if (reader.LocalName == "maxInclusive") { level = 3; XmlSchemaMaxInclusiveFacet maxi = XmlSchemaMaxInclusiveFacet.Read(reader, h); if (maxi != null) { restriction.facets.Add(maxi); } continue; } else if (reader.LocalName == "totalDigits") { level = 3; XmlSchemaTotalDigitsFacet total = XmlSchemaTotalDigitsFacet.Read(reader, h); if (total != null) { restriction.facets.Add(total); } continue; } else if (reader.LocalName == "fractionDigits") { level = 3; XmlSchemaFractionDigitsFacet fraction = XmlSchemaFractionDigitsFacet.Read(reader, h); if (fraction != null) { restriction.facets.Add(fraction); } continue; } else if (reader.LocalName == "length") { level = 3; XmlSchemaLengthFacet length = XmlSchemaLengthFacet.Read(reader, h); if (length != null) { restriction.facets.Add(length); } continue; } else if (reader.LocalName == "minLength") { level = 3; XmlSchemaMinLengthFacet minlen = XmlSchemaMinLengthFacet.Read(reader, h); if (minlen != null) { restriction.facets.Add(minlen); } continue; } else if (reader.LocalName == "maxLength") { level = 3; XmlSchemaMaxLengthFacet maxlen = XmlSchemaMaxLengthFacet.Read(reader, h); if (maxlen != null) { restriction.facets.Add(maxlen); } continue; } else if (reader.LocalName == "enumeration") { level = 3; XmlSchemaEnumerationFacet enumeration = XmlSchemaEnumerationFacet.Read(reader, h); if (enumeration != null) { restriction.facets.Add(enumeration); } continue; } else if (reader.LocalName == "whiteSpace") { level = 3; XmlSchemaWhiteSpaceFacet ws = XmlSchemaWhiteSpaceFacet.Read(reader, h); if (ws != null) { restriction.facets.Add(ws); } continue; } else if (reader.LocalName == "pattern") { level = 3; XmlSchemaPatternFacet pattern = XmlSchemaPatternFacet.Read(reader, h); if (pattern != null) { restriction.facets.Add(pattern); } continue; } } if (level <= 4) { if (reader.LocalName == "attribute") { level = 4; XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader, h); if (attr != null) { restriction.Attributes.Add(attr); } continue; } if (reader.LocalName == "attributeGroup") { level = 4; XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader, h); if (attr != null) { restriction.attributes.Add(attr); } continue; } } if (level <= 5 && reader.LocalName == "anyAttribute") { level = 6; XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader, h); if (anyattr != null) { restriction.AnyAttribute = anyattr; } continue; } reader.RaiseInvalidElementError(); } return(restriction); }
internal XmlSchemaObject Clone(XmlSchema?parentSchema) { XmlSchemaComplexType complexType = (XmlSchemaComplexType)MemberwiseClone(); //Deep clone the QNames as these will be updated on chameleon includes if (complexType.ContentModel != null) { //simpleContent or complexContent XmlSchemaSimpleContent?simpleContent = complexType.ContentModel as XmlSchemaSimpleContent; if (simpleContent != null) { XmlSchemaSimpleContent newSimpleContent = (XmlSchemaSimpleContent)simpleContent.Clone(); XmlSchemaSimpleContentExtension?simpleExt = simpleContent.Content as XmlSchemaSimpleContentExtension; if (simpleExt != null) { XmlSchemaSimpleContentExtension newSimpleExt = (XmlSchemaSimpleContentExtension)simpleExt.Clone(); newSimpleExt.BaseTypeName = simpleExt.BaseTypeName.Clone(); newSimpleExt.SetAttributes(CloneAttributes(simpleExt.Attributes)); newSimpleContent.Content = newSimpleExt; } else { //simpleContent.Content is XmlSchemaSimpleContentRestriction XmlSchemaSimpleContentRestriction simpleRest = (XmlSchemaSimpleContentRestriction)simpleContent.Content !; XmlSchemaSimpleContentRestriction newSimpleRest = (XmlSchemaSimpleContentRestriction)simpleRest.Clone(); newSimpleRest.BaseTypeName = simpleRest.BaseTypeName.Clone(); newSimpleRest.SetAttributes(CloneAttributes(simpleRest.Attributes)); newSimpleContent.Content = newSimpleRest; } complexType.ContentModel = newSimpleContent; } else { // complexType.ContentModel is XmlSchemaComplexContent XmlSchemaComplexContent complexContent = (XmlSchemaComplexContent)complexType.ContentModel; XmlSchemaComplexContent newComplexContent = (XmlSchemaComplexContent)complexContent.Clone(); XmlSchemaComplexContentExtension?complexExt = complexContent.Content as XmlSchemaComplexContentExtension; if (complexExt != null) { XmlSchemaComplexContentExtension newComplexExt = (XmlSchemaComplexContentExtension)complexExt.Clone(); newComplexExt.BaseTypeName = complexExt.BaseTypeName.Clone(); newComplexExt.SetAttributes(CloneAttributes(complexExt.Attributes)); if (HasParticleRef(complexExt.Particle, parentSchema)) { newComplexExt.Particle = CloneParticle(complexExt.Particle, parentSchema); } newComplexContent.Content = newComplexExt; } else { // complexContent.Content is XmlSchemaComplexContentRestriction XmlSchemaComplexContentRestriction complexRest = (complexContent.Content as XmlSchemaComplexContentRestriction) !; XmlSchemaComplexContentRestriction newComplexRest = (XmlSchemaComplexContentRestriction)complexRest.Clone(); newComplexRest.BaseTypeName = complexRest.BaseTypeName.Clone(); newComplexRest.SetAttributes(CloneAttributes(complexRest.Attributes)); if (HasParticleRef(newComplexRest.Particle, parentSchema)) { newComplexRest.Particle = CloneParticle(newComplexRest.Particle, parentSchema); } newComplexContent.Content = newComplexRest; } complexType.ContentModel = newComplexContent; } } else { //equals XmlSchemaComplexContent with baseType is anyType if (HasParticleRef(complexType.Particle, parentSchema)) { complexType.Particle = CloneParticle(complexType.Particle, parentSchema); } complexType.SetAttributes(CloneAttributes(complexType.Attributes)); } complexType.ClearCompiledState(); return(complexType); }
private void NavigateSimpleContentRestriction(XmlSchemaSimpleContentRestriction simpleContentRestriction) { handler.BeginSimpleContentRestriction(simpleContentRestriction); NavigateObjectCollection(simpleContentRestriction.Attributes); handler.EndSimpleContentRestriction(); }
protected override void Visit(XmlSchemaSimpleContentRestriction restriction) { if (restriction.Facets.Count == 0) TraverseBaseType(restriction.BaseTypeName); else { PushNode(SimpleTypeStructureNodeType.Restriction, restriction); TraverseBaseType(restriction.BaseTypeName); Traverse(restriction.Facets); PopNode(); } }
//<restriction //base = QName //id = ID //{any attributes with non-schema namespace . . .}> //Content: (annotation?, (simpleType?, (minExclusive | minInclusive | maxExclusive | maxInclusive | totalDigits | fractionDigits | length | minLength | maxLength | enumeration | whiteSpace | pattern)*)?, ((attribute | attributeGroup)*, anyAttribute?)) //</restriction> internal static XmlSchemaSimpleContentRestriction Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleContentRestriction restriction = new XmlSchemaSimpleContentRestriction(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaComplexContentRestriction.Read, name="+reader.Name,null); reader.SkipToEnd(); return null; } restriction.LineNumber = reader.LineNumber; restriction.LinePosition = reader.LinePosition; restriction.SourceUri = reader.BaseURI; while(reader.MoveToNextAttribute()) { if(reader.Name == "base") { Exception innerex; restriction.baseTypeName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex); if(innerex != null) error(h, reader.Value + " is not a valid value for base attribute",innerex); } else if(reader.Name == "id") { restriction.Id = reader.Value; } else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h,reader.Name + " is not a valid attribute for restriction",null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,restriction); } } reader.MoveToElement(); if(reader.IsEmptyElement) return restriction; //Content: 1.annotation?, // 2.simpleType?, // 3.(minExclusive |...| enumeration | whiteSpace | pattern)*, // 4.(attribute | attributeGroup)*, // 5.anyAttribute? int level = 1; while(reader.ReadNextElement()) { if(reader.NodeType == XmlNodeType.EndElement) { if(reader.LocalName != xmlname) error(h,"Should not happen :2: XmlSchemaSimpleContentRestriction.Read, name="+reader.Name,null); break; } if(level <= 1 && reader.LocalName == "annotation") { level = 2; //Only one annotation XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h); if(annotation != null) restriction.Annotation = annotation; continue; } if(level <=2 && reader.LocalName == "simpleType") { level = 3; XmlSchemaSimpleType stype = XmlSchemaSimpleType.Read(reader,h); if(stype != null) restriction.baseType = stype; continue; } if(level <= 3) { if(reader.LocalName == "minExclusive") { level = 3; XmlSchemaMinExclusiveFacet minex = XmlSchemaMinExclusiveFacet.Read(reader,h); if(minex != null) restriction.facets.Add(minex); continue; } else if(reader.LocalName == "minInclusive") { level = 3; XmlSchemaMinInclusiveFacet mini = XmlSchemaMinInclusiveFacet.Read(reader,h); if(mini != null) restriction.facets.Add(mini); continue; } else if(reader.LocalName == "maxExclusive") { level = 3; XmlSchemaMaxExclusiveFacet maxex = XmlSchemaMaxExclusiveFacet.Read(reader,h); if(maxex != null) restriction.facets.Add(maxex); continue; } else if(reader.LocalName == "maxInclusive") { level = 3; XmlSchemaMaxInclusiveFacet maxi = XmlSchemaMaxInclusiveFacet.Read(reader,h); if(maxi != null) restriction.facets.Add(maxi); continue; } else if(reader.LocalName == "totalDigits") { level = 3; XmlSchemaTotalDigitsFacet total = XmlSchemaTotalDigitsFacet.Read(reader,h); if(total != null) restriction.facets.Add(total); continue; } else if(reader.LocalName == "fractionDigits") { level = 3; XmlSchemaFractionDigitsFacet fraction = XmlSchemaFractionDigitsFacet.Read(reader,h); if(fraction != null) restriction.facets.Add(fraction); continue; } else if(reader.LocalName == "length") { level = 3; XmlSchemaLengthFacet length = XmlSchemaLengthFacet.Read(reader,h); if(length != null) restriction.facets.Add(length); continue; } else if(reader.LocalName == "minLength") { level = 3; XmlSchemaMinLengthFacet minlen = XmlSchemaMinLengthFacet.Read(reader,h); if(minlen != null) restriction.facets.Add(minlen); continue; } else if(reader.LocalName == "maxLength") { level = 3; XmlSchemaMaxLengthFacet maxlen = XmlSchemaMaxLengthFacet.Read(reader,h); if(maxlen != null) restriction.facets.Add(maxlen); continue; } else if(reader.LocalName == "enumeration") { level = 3; XmlSchemaEnumerationFacet enumeration = XmlSchemaEnumerationFacet.Read(reader,h); if(enumeration != null) restriction.facets.Add(enumeration); continue; } else if(reader.LocalName == "whiteSpace") { level = 3; XmlSchemaWhiteSpaceFacet ws = XmlSchemaWhiteSpaceFacet.Read(reader,h); if(ws != null) restriction.facets.Add(ws); continue; } else if(reader.LocalName == "pattern") { level = 3; XmlSchemaPatternFacet pattern = XmlSchemaPatternFacet.Read(reader,h); if(pattern != null) restriction.facets.Add(pattern); continue; } } if(level <= 4) { if(reader.LocalName == "attribute") { level = 4; XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader,h); if(attr != null) restriction.Attributes.Add(attr); continue; } if(reader.LocalName == "attributeGroup") { level = 4; XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader,h); if(attr != null) restriction.attributes.Add(attr); continue; } } if(level <= 5 && reader.LocalName == "anyAttribute") { level = 6; XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader,h); if(anyattr != null) restriction.AnyAttribute = anyattr; continue; } reader.RaiseInvalidElementError(); } return restriction; }
void Write40_XmlSchemaSimpleContentRestriction(XmlSchemaSimpleContentRestriction o) { if ((object)o == null) return; WriteStartElement("restriction"); WriteAttribute(@"id", @"", ((System.String)o.@Id)); WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o); if ([email protected]){ WriteAttribute(@"base", @"", o.@BaseTypeName); } Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation); Write9_XmlSchemaSimpleType((XmlSchemaSimpleType)o.@BaseType); WriteFacets(o.Facets); WriteSortedItems(o.Attributes); Write33_XmlSchemaAnyAttribute((XmlSchemaAnyAttribute)o.@AnyAttribute); WriteEndElement(); }
private ComplexType ToComplexType(Element el) { QName name = el.SchemaTypeName; XmlSchemaType type = el.SchemaType; // 1. element type is complex. ComplexType ct = type as ComplexType; if (ct != null) { return(ct); } // 2. reference to global complexType. XmlSchemaType globalType = schemas.GlobalTypes [name] as XmlSchemaType; ct = globalType as ComplexType; if (ct != null) { return(ct); } ct = new ComplexType(); el.SchemaType = ct; el.SchemaTypeName = QName.Empty; // 3. base type name is xs:anyType or no specification. // <xs:complexType /> if (name == QNameAnyType) { return(ct); } else if (type == null && name == QName.Empty) { return(ct); } SimpleModel sc = new SimpleModel(); ct.ContentModel = sc; // 4. type is simpleType // -> extension of existing simple type. SimpleType st = type as SimpleType; if (st != null) { SimpleRst scr = new SimpleRst(); scr.BaseType = st; sc.Content = scr; return(ct); } SimpleExt sce = new SimpleExt(); sc.Content = sce; // 5. type name points to primitive type // -> simple extension of a primitive type st = XmlSchemaType.GetBuiltInSimpleType(name); if (st != null) { sce.BaseTypeName = name; return(ct); } // 6. type name points to global simpleType. st = globalType as SimpleType; if (st != null) { sce.BaseTypeName = name; return(ct); } throw Error(el, "Unexpected schema component that contains simpleTypeName that could not be resolved."); }
private void InferTextContent(Element el, bool isNew) { string value = source.ReadString(); if (el.SchemaType == null) { if (el.SchemaTypeName == QName.Empty) { // no type information -> infer type if (isNew) { el.SchemaTypeName = InferSimpleType( value); } else { el.SchemaTypeName = QNameString; } return; } switch (el.SchemaTypeName.Namespace) { case XmlSchema.Namespace: case XdtNamespace: // existing primitive type el.SchemaTypeName = InferMergedType( value, el.SchemaTypeName); break; default: ComplexType ct = schemas.GlobalTypes [ el.SchemaTypeName] as ComplexType; // If it is complex, then just set // mixed='true' (type cannot be set.) // If it is simple, then we cannot // make sure that string value is // valid. So just set as xs:string. if (ct != null) { MarkAsMixed(ct); } else { el.SchemaTypeName = QNameString; } break; } return; } // simpleType SimpleType st = el.SchemaType as SimpleType; if (st != null) { // If simple, then (described above) el.SchemaType = null; el.SchemaTypeName = QNameString; return; } // complexType ComplexType ect = el.SchemaType as ComplexType; SimpleModel sm = ect.ContentModel as SimpleModel; if (sm == null) { // - ComplexContent MarkAsMixed(ect); return; } // - SimpleContent SimpleExt se = sm.Content as SimpleExt; if (se != null) { se.BaseTypeName = InferMergedType(value, se.BaseTypeName); } SimpleRst sr = sm.Content as SimpleRst; if (sr != null) { sr.BaseTypeName = InferMergedType(value, sr.BaseTypeName); sr.BaseType = null; } }
private void Write59_Item(string n, string ns, XmlSchemaSimpleContentRestriction o, bool isNullable, bool needType) { if (o == null) { if (isNullable) { base.WriteNullTagLiteral(n, ns); } } else { if (!needType && !(o.GetType() == typeof(XmlSchemaSimpleContentRestriction))) { throw base.CreateUnknownTypeException(o); } base.EscapeName = false; base.WriteStartElement(n, ns, o, false, o.Namespaces); if (needType) { base.WriteXsiType("XmlSchemaSimpleContentRestriction", "http://www.w3.org/2001/XMLSchema"); } base.WriteAttribute("id", "", o.Id); XmlAttribute[] unhandledAttributes = o.UnhandledAttributes; if (unhandledAttributes != null) { for (int i = 0; i < unhandledAttributes.Length; i++) { XmlAttribute node = unhandledAttributes[i]; base.WriteXmlAttribute(node, o); } } base.WriteAttribute("base", "", base.FromXmlQualifiedName(o.BaseTypeName)); this.Write11_XmlSchemaAnnotation("annotation", "http://www.w3.org/2001/XMLSchema", o.Annotation, false, false); this.Write34_XmlSchemaSimpleType("simpleType", "http://www.w3.org/2001/XMLSchema", o.BaseType, false, false); XmlSchemaObjectCollection facets = o.Facets; if (facets != null) { for (int j = 0; j < facets.Count; j++) { XmlSchemaObject obj2 = facets[j]; if (obj2 is XmlSchemaMinLengthFacet) { this.Write31_XmlSchemaMinLengthFacet("minLength", "http://www.w3.org/2001/XMLSchema", (XmlSchemaMinLengthFacet) obj2, false, false); } else if (obj2 is XmlSchemaMaxLengthFacet) { this.Write22_XmlSchemaMaxLengthFacet("maxLength", "http://www.w3.org/2001/XMLSchema", (XmlSchemaMaxLengthFacet) obj2, false, false); } else if (obj2 is XmlSchemaLengthFacet) { this.Write23_XmlSchemaLengthFacet("length", "http://www.w3.org/2001/XMLSchema", (XmlSchemaLengthFacet) obj2, false, false); } else if (obj2 is XmlSchemaFractionDigitsFacet) { this.Write20_XmlSchemaFractionDigitsFacet("fractionDigits", "http://www.w3.org/2001/XMLSchema", (XmlSchemaFractionDigitsFacet) obj2, false, false); } else if (obj2 is XmlSchemaTotalDigitsFacet) { this.Write24_XmlSchemaTotalDigitsFacet("totalDigits", "http://www.w3.org/2001/XMLSchema", (XmlSchemaTotalDigitsFacet) obj2, false, false); } else if (obj2 is XmlSchemaMinExclusiveFacet) { this.Write30_XmlSchemaMinExclusiveFacet("minExclusive", "http://www.w3.org/2001/XMLSchema", (XmlSchemaMinExclusiveFacet) obj2, false, false); } else if (obj2 is XmlSchemaMaxInclusiveFacet) { this.Write27_XmlSchemaMaxInclusiveFacet("maxInclusive", "http://www.w3.org/2001/XMLSchema", (XmlSchemaMaxInclusiveFacet) obj2, false, false); } else if (obj2 is XmlSchemaMaxExclusiveFacet) { this.Write28_XmlSchemaMaxExclusiveFacet("maxExclusive", "http://www.w3.org/2001/XMLSchema", (XmlSchemaMaxExclusiveFacet) obj2, false, false); } else if (obj2 is XmlSchemaMinInclusiveFacet) { this.Write21_XmlSchemaMinInclusiveFacet("minInclusive", "http://www.w3.org/2001/XMLSchema", (XmlSchemaMinInclusiveFacet) obj2, false, false); } else if (obj2 is XmlSchemaWhiteSpaceFacet) { this.Write29_XmlSchemaWhiteSpaceFacet("whiteSpace", "http://www.w3.org/2001/XMLSchema", (XmlSchemaWhiteSpaceFacet) obj2, false, false); } else if (obj2 is XmlSchemaEnumerationFacet) { this.Write26_XmlSchemaEnumerationFacet("enumeration", "http://www.w3.org/2001/XMLSchema", (XmlSchemaEnumerationFacet) obj2, false, false); } else if (obj2 is XmlSchemaPatternFacet) { this.Write25_XmlSchemaPatternFacet("pattern", "http://www.w3.org/2001/XMLSchema", (XmlSchemaPatternFacet) obj2, false, false); } else if (obj2 != null) { throw base.CreateUnknownTypeException(obj2); } } } XmlSchemaObjectCollection attributes = o.Attributes; if (attributes != null) { for (int k = 0; k < attributes.Count; k++) { XmlSchemaObject obj3 = attributes[k]; if (obj3 is XmlSchemaAttribute) { this.Write36_XmlSchemaAttribute("attribute", "http://www.w3.org/2001/XMLSchema", (XmlSchemaAttribute) obj3, false, false); } else if (obj3 is XmlSchemaAttributeGroupRef) { this.Write37_XmlSchemaAttributeGroupRef("attributeGroup", "http://www.w3.org/2001/XMLSchema", (XmlSchemaAttributeGroupRef) obj3, false, false); } else if (obj3 != null) { throw base.CreateUnknownTypeException(obj3); } } } this.Write39_XmlSchemaAnyAttribute("anyAttribute", "http://www.w3.org/2001/XMLSchema", o.AnyAttribute, false, false); base.WriteEndElement(o); } }
internal static XmlSchemaSimpleContent Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleContent xmlSchemaSimpleContent = new XmlSchemaSimpleContent(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "simpleContent") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaComplexContent.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } xmlSchemaSimpleContent.LineNumber = reader.LineNumber; xmlSchemaSimpleContent.LinePosition = reader.LinePosition; xmlSchemaSimpleContent.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaSimpleContent.Id = reader.Value; } else if ((reader.NamespaceURI == string.Empty && reader.Name != "xmlns") || reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema") { XmlSchemaObject.error(h, reader.Name + " is not a valid attribute for simpleContent", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaSimpleContent); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaSimpleContent); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "simpleContent") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaSimpleContent.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaSimpleContent.Annotation = xmlSchemaAnnotation; } } else { if (num <= 2) { if (reader.LocalName == "restriction") { num = 3; XmlSchemaSimpleContentRestriction xmlSchemaSimpleContentRestriction = XmlSchemaSimpleContentRestriction.Read(reader, h); if (xmlSchemaSimpleContentRestriction != null) { xmlSchemaSimpleContent.content = xmlSchemaSimpleContentRestriction; } continue; } if (reader.LocalName == "extension") { num = 3; XmlSchemaSimpleContentExtension xmlSchemaSimpleContentExtension = XmlSchemaSimpleContentExtension.Read(reader, h); if (xmlSchemaSimpleContentExtension != null) { xmlSchemaSimpleContent.content = xmlSchemaSimpleContentExtension; } continue; } } reader.RaiseInvalidElementError(); } } return(xmlSchemaSimpleContent); }
protected override void Visit(XmlSchemaSimpleContentRestriction restriction) { AddBaseTypeUsage(restriction.BaseTypeName); base.Visit(restriction); }
internal XmlSchemaObject Clone(XmlSchema parentSchema) { XmlSchemaComplexType type = (XmlSchemaComplexType) base.MemberwiseClone(); if (type.ContentModel != null) { XmlSchemaSimpleContent contentModel = type.ContentModel as XmlSchemaSimpleContent; if (contentModel != null) { XmlSchemaSimpleContent content2 = (XmlSchemaSimpleContent) contentModel.Clone(); XmlSchemaSimpleContentExtension content = contentModel.Content as XmlSchemaSimpleContentExtension; if (content != null) { XmlSchemaSimpleContentExtension extension2 = (XmlSchemaSimpleContentExtension) content.Clone(); extension2.BaseTypeName = content.BaseTypeName.Clone(); extension2.SetAttributes(CloneAttributes(content.Attributes)); content2.Content = extension2; } else { XmlSchemaSimpleContentRestriction restriction = (XmlSchemaSimpleContentRestriction) contentModel.Content; XmlSchemaSimpleContentRestriction restriction2 = (XmlSchemaSimpleContentRestriction) restriction.Clone(); restriction2.BaseTypeName = restriction.BaseTypeName.Clone(); restriction2.SetAttributes(CloneAttributes(restriction.Attributes)); content2.Content = restriction2; } type.ContentModel = content2; } else { XmlSchemaComplexContent content3 = (XmlSchemaComplexContent) type.ContentModel; XmlSchemaComplexContent content4 = (XmlSchemaComplexContent) content3.Clone(); XmlSchemaComplexContentExtension extension3 = content3.Content as XmlSchemaComplexContentExtension; if (extension3 != null) { XmlSchemaComplexContentExtension extension4 = (XmlSchemaComplexContentExtension) extension3.Clone(); extension4.BaseTypeName = extension3.BaseTypeName.Clone(); extension4.SetAttributes(CloneAttributes(extension3.Attributes)); if (HasParticleRef(extension3.Particle, parentSchema)) { extension4.Particle = CloneParticle(extension3.Particle, parentSchema); } content4.Content = extension4; } else { XmlSchemaComplexContentRestriction restriction3 = content3.Content as XmlSchemaComplexContentRestriction; XmlSchemaComplexContentRestriction restriction4 = (XmlSchemaComplexContentRestriction) restriction3.Clone(); restriction4.BaseTypeName = restriction3.BaseTypeName.Clone(); restriction4.SetAttributes(CloneAttributes(restriction3.Attributes)); if (HasParticleRef(restriction4.Particle, parentSchema)) { restriction4.Particle = CloneParticle(restriction4.Particle, parentSchema); } content4.Content = restriction4; } type.ContentModel = content4; } } else { if (HasParticleRef(type.Particle, parentSchema)) { type.Particle = CloneParticle(type.Particle, parentSchema); } type.SetAttributes(CloneAttributes(type.Attributes)); } type.ClearCompiledState(); return type; }
void Handler.BeginSimpleContentRestriction(XmlSchemaSimpleContentRestriction simpleContentRestriction) { }
internal static XmlSchemaSimpleContentRestriction Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleContentRestriction xmlSchemaSimpleContentRestriction = new XmlSchemaSimpleContentRestriction(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "restriction") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaComplexContentRestriction.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } xmlSchemaSimpleContentRestriction.LineNumber = reader.LineNumber; xmlSchemaSimpleContentRestriction.LinePosition = reader.LinePosition; xmlSchemaSimpleContentRestriction.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "base") { Exception ex; xmlSchemaSimpleContentRestriction.baseTypeName = XmlSchemaUtil.ReadQNameAttribute(reader, out ex); if (ex != null) { XmlSchemaObject.error(h, reader.Value + " is not a valid value for base attribute", ex); } } else if (reader.Name == "id") { xmlSchemaSimpleContentRestriction.Id = reader.Value; } else if ((reader.NamespaceURI == string.Empty && reader.Name != "xmlns") || reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema") { XmlSchemaObject.error(h, reader.Name + " is not a valid attribute for restriction", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaSimpleContentRestriction); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaSimpleContentRestriction); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "restriction") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaSimpleContentRestriction.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaSimpleContentRestriction.Annotation = xmlSchemaAnnotation; } } else if (num <= 2 && reader.LocalName == "simpleType") { num = 3; XmlSchemaSimpleType xmlSchemaSimpleType = XmlSchemaSimpleType.Read(reader, h); if (xmlSchemaSimpleType != null) { xmlSchemaSimpleContentRestriction.baseType = xmlSchemaSimpleType; } } else { if (num <= 3) { if (reader.LocalName == "minExclusive") { num = 3; XmlSchemaMinExclusiveFacet xmlSchemaMinExclusiveFacet = XmlSchemaMinExclusiveFacet.Read(reader, h); if (xmlSchemaMinExclusiveFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaMinExclusiveFacet); } continue; } if (reader.LocalName == "minInclusive") { num = 3; XmlSchemaMinInclusiveFacet xmlSchemaMinInclusiveFacet = XmlSchemaMinInclusiveFacet.Read(reader, h); if (xmlSchemaMinInclusiveFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaMinInclusiveFacet); } continue; } if (reader.LocalName == "maxExclusive") { num = 3; XmlSchemaMaxExclusiveFacet xmlSchemaMaxExclusiveFacet = XmlSchemaMaxExclusiveFacet.Read(reader, h); if (xmlSchemaMaxExclusiveFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaMaxExclusiveFacet); } continue; } if (reader.LocalName == "maxInclusive") { num = 3; XmlSchemaMaxInclusiveFacet xmlSchemaMaxInclusiveFacet = XmlSchemaMaxInclusiveFacet.Read(reader, h); if (xmlSchemaMaxInclusiveFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaMaxInclusiveFacet); } continue; } if (reader.LocalName == "totalDigits") { num = 3; XmlSchemaTotalDigitsFacet xmlSchemaTotalDigitsFacet = XmlSchemaTotalDigitsFacet.Read(reader, h); if (xmlSchemaTotalDigitsFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaTotalDigitsFacet); } continue; } if (reader.LocalName == "fractionDigits") { num = 3; XmlSchemaFractionDigitsFacet xmlSchemaFractionDigitsFacet = XmlSchemaFractionDigitsFacet.Read(reader, h); if (xmlSchemaFractionDigitsFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaFractionDigitsFacet); } continue; } if (reader.LocalName == "length") { num = 3; XmlSchemaLengthFacet xmlSchemaLengthFacet = XmlSchemaLengthFacet.Read(reader, h); if (xmlSchemaLengthFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaLengthFacet); } continue; } if (reader.LocalName == "minLength") { num = 3; XmlSchemaMinLengthFacet xmlSchemaMinLengthFacet = XmlSchemaMinLengthFacet.Read(reader, h); if (xmlSchemaMinLengthFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaMinLengthFacet); } continue; } if (reader.LocalName == "maxLength") { num = 3; XmlSchemaMaxLengthFacet xmlSchemaMaxLengthFacet = XmlSchemaMaxLengthFacet.Read(reader, h); if (xmlSchemaMaxLengthFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaMaxLengthFacet); } continue; } if (reader.LocalName == "enumeration") { num = 3; XmlSchemaEnumerationFacet xmlSchemaEnumerationFacet = XmlSchemaEnumerationFacet.Read(reader, h); if (xmlSchemaEnumerationFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaEnumerationFacet); } continue; } if (reader.LocalName == "whiteSpace") { num = 3; XmlSchemaWhiteSpaceFacet xmlSchemaWhiteSpaceFacet = XmlSchemaWhiteSpaceFacet.Read(reader, h); if (xmlSchemaWhiteSpaceFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaWhiteSpaceFacet); } continue; } if (reader.LocalName == "pattern") { num = 3; XmlSchemaPatternFacet xmlSchemaPatternFacet = XmlSchemaPatternFacet.Read(reader, h); if (xmlSchemaPatternFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaPatternFacet); } continue; } } if (num <= 4) { if (reader.LocalName == "attribute") { num = 4; XmlSchemaAttribute xmlSchemaAttribute = XmlSchemaAttribute.Read(reader, h); if (xmlSchemaAttribute != null) { xmlSchemaSimpleContentRestriction.Attributes.Add(xmlSchemaAttribute); } continue; } if (reader.LocalName == "attributeGroup") { num = 4; XmlSchemaAttributeGroupRef xmlSchemaAttributeGroupRef = XmlSchemaAttributeGroupRef.Read(reader, h); if (xmlSchemaAttributeGroupRef != null) { xmlSchemaSimpleContentRestriction.attributes.Add(xmlSchemaAttributeGroupRef); } continue; } } if (num <= 5 && reader.LocalName == "anyAttribute") { num = 6; XmlSchemaAnyAttribute xmlSchemaAnyAttribute = XmlSchemaAnyAttribute.Read(reader, h); if (xmlSchemaAnyAttribute != null) { xmlSchemaSimpleContentRestriction.AnyAttribute = xmlSchemaAnyAttribute; } } else { reader.RaiseInvalidElementError(); } } } return(xmlSchemaSimpleContentRestriction); }
internal static XmlSchema BuildSchema (DiscoveryVersion version) { var schema = new XmlSchema () { TargetNamespace = version.Namespace }; var anyAttr = new XmlSchemaAnyAttribute () { Namespace = "##other", ProcessContents = XmlSchemaContentProcessing.Lax }; var probePart = new XmlSchemaSequence (); probePart.Items.Add (new XmlSchemaElement () { RefName = new XmlQualifiedName ("Types", version.Namespace), MinOccurs = 0 }); probePart.Items.Add (new XmlSchemaElement () { RefName = new XmlQualifiedName ("Scopes", version.Namespace), MinOccurs = 0 }); probePart.Items.Add (new XmlSchemaAny () { MinOccurs = 0, MaxOccursString = "unbounded", Namespace = "##other", ProcessContents = XmlSchemaContentProcessing.Lax }); var ct = new XmlSchemaComplexType () { Name = "ProbeType", Particle = probePart, AnyAttribute = anyAttr }; schema.Items.Add (ct); schema.Items.Add (new XmlSchemaSimpleType () { Name = "QNameListType", Content = new XmlSchemaSimpleTypeList () { ItemTypeName = new XmlQualifiedName ("QName", XmlSchema.Namespace) } }); var scr = new XmlSchemaSimpleContentRestriction () { BaseTypeName = new XmlQualifiedName ("UriListType", version.Namespace), AnyAttribute = anyAttr }; scr.Attributes.Add (new XmlSchemaAttribute () { Name = "matchBy", SchemaTypeName = new XmlQualifiedName ("anyURI", XmlSchema.Namespace) }); schema.Items.Add (new XmlSchemaComplexType () { Name = "ScopesType", ContentModel = new XmlSchemaSimpleContent () { Content = scr } }); schema.Items.Add (new XmlSchemaSimpleType () { Name = "UriListType", Content = new XmlSchemaSimpleTypeList () { ItemTypeName = new XmlQualifiedName ("anyURI", XmlSchema.Namespace) } }); schema.Items.Add (new XmlSchemaElement () { Name = "Types", SchemaTypeName = new XmlQualifiedName ("QNameListType", version.Namespace) }); schema.Items.Add (new XmlSchemaElement () { Name = "Scopes", SchemaTypeName = new XmlQualifiedName ("ScopesType", version.Namespace) }); return schema; }
protected virtual void Visit(XmlSchemaSimpleContentRestriction restriction) { Traverse(restriction.Facets); Traverse(restriction.Attributes); if (restriction.AnyAttribute != null) Traverse(restriction.AnyAttribute); }
//<simpleContent // id = ID // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (restriction | extension)) //</simpleContent> internal static XmlSchemaSimpleContent Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleContent simple = new XmlSchemaSimpleContent(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaComplexContent.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } simple.LineNumber = reader.LineNumber; simple.LinePosition = reader.LinePosition; simple.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { simple.Id = reader.Value; } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for simpleContent", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, simple); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(simple); } //Content: (annotation?, (restriction | extension)) int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaSimpleContent.Read, name=" + reader.Name, null); } break; } if (level <= 1 && reader.LocalName == "annotation") { level = 2; //Only one annotation XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader, h); if (annotation != null) { simple.Annotation = annotation; } continue; } if (level <= 2) { if (reader.LocalName == "restriction") { level = 3; XmlSchemaSimpleContentRestriction restriction = XmlSchemaSimpleContentRestriction.Read(reader, h); if (restriction != null) { simple.content = restriction; } continue; } if (reader.LocalName == "extension") { level = 3; XmlSchemaSimpleContentExtension extension = XmlSchemaSimpleContentExtension.Read(reader, h); if (extension != null) { simple.content = extension; } continue; } } reader.RaiseInvalidElementError(); } return(simple); }
private void Write40_XmlSchemaSimpleContentRestriction(XmlSchemaSimpleContentRestriction o) { if (o != null) { this.WriteStartElement("restriction"); this.WriteAttribute("id", "", o.Id); this.WriteAttributes(o.UnhandledAttributes, o); if (!o.BaseTypeName.IsEmpty) { this.WriteAttribute("base", "", o.BaseTypeName); } this.Write5_XmlSchemaAnnotation(o.Annotation); this.Write9_XmlSchemaSimpleType(o.BaseType); this.WriteFacets(o.Facets); this.WriteSortedItems(o.Attributes); this.Write33_XmlSchemaAnyAttribute(o.AnyAttribute); this.WriteEndElement(); } }
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaSimpleContentRestriction value) {}
private void CompileSimpleContentRestriction(XmlSchemaComplexType complexType, XmlSchemaSimpleContentRestriction simpleRestriction) { XmlSchemaComplexType baseType = null; XmlSchemaDatatype datatype = null; if (complexType.Redefined != null && simpleRestriction.BaseTypeName == complexType.Redefined.QualifiedName) { baseType = (XmlSchemaComplexType)complexType.Redefined; CompileComplexType(baseType); datatype = baseType.Datatype; } else { baseType = GetComplexType(simpleRestriction.BaseTypeName); if (baseType == null) { SendValidationEvent(Res.Sch_UndefBaseRestriction, simpleRestriction.BaseTypeName.ToString(), simpleRestriction); return; } if (baseType.ContentType == XmlSchemaContentType.TextOnly) { if (simpleRestriction.BaseType == null) { datatype = baseType.Datatype; //There is a bug here. Need to check if simpleRestriction has facets. //If yes, Need tp apply these facets as well. } else { CompileSimpleType(simpleRestriction.BaseType); if(!XmlSchemaType.IsDerivedFromDatatype(simpleRestriction.BaseType.Datatype, baseType.Datatype, XmlSchemaDerivationMethod.None)) { SendValidationEvent(Res.Sch_DerivedNotFromBase, simpleRestriction); } datatype = simpleRestriction.BaseType.Datatype; } } else if (baseType.ContentType == XmlSchemaContentType.Mixed && baseType.ElementDecl.ContentValidator.IsEmptiable) { if (simpleRestriction.BaseType != null) { CompileSimpleType(simpleRestriction.BaseType); complexType.SetBaseSchemaType(simpleRestriction.BaseType); datatype = simpleRestriction.BaseType.Datatype; } else { SendValidationEvent(Res.Sch_NeedSimpleTypeChild, simpleRestriction); } } else { SendValidationEvent(Res.Sch_NotSimpleContent, complexType); } } if (baseType != null && baseType.ElementDecl != null) { if ((baseType.FinalResolved & XmlSchemaDerivationMethod.Restriction) != 0) { SendValidationEvent(Res.Sch_BaseFinalRestriction, complexType); } } if (baseType != null) { complexType.SetBaseSchemaType(baseType); } if (datatype != null) { try { complexType.SetDatatype(datatype.DeriveByRestriction(simpleRestriction.Facets, NameTable, complexType)); } catch (XmlSchemaException e) { if (e.SourceSchemaObject == null) { e.SetSource(complexType); } SendValidationEvent(e); complexType.SetDatatype(DatatypeImplementation.AnySimpleType.Datatype); } } complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction); CompileLocalAttributes(baseType, complexType, simpleRestriction.Attributes, simpleRestriction.AnyAttribute, XmlSchemaDerivationMethod.Restriction); }
public override void Check (ConformanceCheckContext ctx, XmlSchemaSimpleContentRestriction value) { CheckSchemaQName (ctx, value, value.BaseTypeName); }
private void SetContainer(State state, object container) { switch (state) { case State.Root: break; case State.Schema: break; case State.Annotation: this.annotation = (XmlSchemaAnnotation)container; break; case State.Include: this.include = (XmlSchemaInclude)container; break; case State.Import: this.import = (XmlSchemaImport)container; break; case State.Element: this.element = (XmlSchemaElement)container; break; case State.Attribute: this.attribute = (XmlSchemaAttribute)container; break; case State.AttributeGroup: this.attributeGroup = (XmlSchemaAttributeGroup)container; break; case State.AttributeGroupRef: this.attributeGroupRef = (XmlSchemaAttributeGroupRef)container; break; case State.AnyAttribute: this.anyAttribute = (XmlSchemaAnyAttribute)container; break; case State.Group: this.group = (XmlSchemaGroup)container; break; case State.GroupRef: this.groupRef = (XmlSchemaGroupRef)container; break; case State.All: this.all = (XmlSchemaAll)container; break; case State.Choice: this.choice = (XmlSchemaChoice)container; break; case State.Sequence: this.sequence = (XmlSchemaSequence)container; break; case State.Any: this.anyElement = (XmlSchemaAny)container; break; case State.Notation: this.notation = (XmlSchemaNotation)container; break; case State.SimpleType: this.simpleType = (XmlSchemaSimpleType)container; break; case State.ComplexType: this.complexType = (XmlSchemaComplexType)container; break; case State.ComplexContent: this.complexContent = (XmlSchemaComplexContent)container; break; case State.ComplexContentExtension: this.complexContentExtension = (XmlSchemaComplexContentExtension)container; break; case State.ComplexContentRestriction: this.complexContentRestriction = (XmlSchemaComplexContentRestriction)container; break; case State.SimpleContent: this.simpleContent = (XmlSchemaSimpleContent)container; break; case State.SimpleContentExtension: this.simpleContentExtension = (XmlSchemaSimpleContentExtension)container; break; case State.SimpleContentRestriction: this.simpleContentRestriction = (XmlSchemaSimpleContentRestriction)container; break; case State.SimpleTypeUnion: this.simpleTypeUnion = (XmlSchemaSimpleTypeUnion)container; break; case State.SimpleTypeList: this.simpleTypeList = (XmlSchemaSimpleTypeList)container; break; case State.SimpleTypeRestriction: this.simpleTypeRestriction = (XmlSchemaSimpleTypeRestriction)container; break; case State.Unique: case State.Key: case State.KeyRef: this.identityConstraint = (XmlSchemaIdentityConstraint)container; break; case State.Selector: case State.Field: this.xpath = (XmlSchemaXPath)container; break; case State.MinExclusive: case State.MinInclusive: case State.MaxExclusive: case State.MaxInclusive: case State.TotalDigits: case State.FractionDigits: case State.Length: case State.MinLength: case State.MaxLength: case State.Enumeration: case State.Pattern: case State.WhiteSpace: this.facet = (XmlSchemaFacet)container; break; case State.AppInfo: this.appInfo = (XmlSchemaAppInfo)container; break; case State.Documentation: this.documentation = (XmlSchemaDocumentation)container; break; case State.Redefine: this.redefine = (XmlSchemaRedefine)container; break; default: Debug.Assert(false, "State is " + state); break; } }
protected override void Visit(XmlSchemaSimpleContentRestriction restriction) { ProcessRestriction(restriction.BaseTypeName, restriction.Attributes, restriction.AnyAttribute); }
private void CompileSimpleContentRestriction(XmlSchemaComplexType complexType, XmlSchemaSimpleContentRestriction simpleRestriction) { XmlSchemaComplexType redefined = null; XmlSchemaDatatype datatype = null; if ((complexType.Redefined != null) && (simpleRestriction.BaseTypeName == complexType.Redefined.QualifiedName)) { redefined = (XmlSchemaComplexType) complexType.Redefined; this.CompileComplexType(redefined); datatype = redefined.Datatype; } else { redefined = this.GetComplexType(simpleRestriction.BaseTypeName); if (redefined == null) { base.SendValidationEvent("Sch_UndefBaseRestriction", simpleRestriction.BaseTypeName.ToString(), simpleRestriction); return; } if (redefined.ContentType == XmlSchemaContentType.TextOnly) { if (simpleRestriction.BaseType == null) { datatype = redefined.Datatype; } else { this.CompileSimpleType(simpleRestriction.BaseType); if (!XmlSchemaType.IsDerivedFromDatatype(simpleRestriction.BaseType.Datatype, redefined.Datatype, XmlSchemaDerivationMethod.None)) { base.SendValidationEvent("Sch_DerivedNotFromBase", simpleRestriction); } datatype = simpleRestriction.BaseType.Datatype; } } else if ((redefined.ContentType == XmlSchemaContentType.Mixed) && redefined.ElementDecl.ContentValidator.IsEmptiable) { if (simpleRestriction.BaseType != null) { this.CompileSimpleType(simpleRestriction.BaseType); complexType.SetBaseSchemaType(simpleRestriction.BaseType); datatype = simpleRestriction.BaseType.Datatype; } else { base.SendValidationEvent("Sch_NeedSimpleTypeChild", simpleRestriction); } } else { base.SendValidationEvent("Sch_NotSimpleContent", complexType); } } if (((redefined != null) && (redefined.ElementDecl != null)) && ((redefined.FinalResolved & XmlSchemaDerivationMethod.Restriction) != XmlSchemaDerivationMethod.Empty)) { base.SendValidationEvent("Sch_BaseFinalRestriction", complexType); } if (redefined != null) { complexType.SetBaseSchemaType(redefined); } if (datatype != null) { try { complexType.SetDatatype(datatype.DeriveByRestriction(simpleRestriction.Facets, base.NameTable, complexType)); } catch (XmlSchemaException exception) { if (exception.SourceSchemaObject == null) { exception.SetSource(complexType); } base.SendValidationEvent(exception); complexType.SetDatatype(DatatypeImplementation.AnySimpleType.Datatype); } } complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction); this.CompileLocalAttributes(redefined, complexType, simpleRestriction.Attributes, simpleRestriction.AnyAttribute, XmlSchemaDerivationMethod.Restriction); }
void Handler.BeginSimpleContentRestriction(XmlSchemaSimpleContentRestriction simpleContentRestriction) { counts.Increment(Counts.Index.SimpleContentRestriction); }