private Particle PopulateParticle(ComplexType ct) { if (ct.ContentModel == null) { if (ct.Particle == null) { ct.Particle = CreateSequence(); } return(ct.Particle); } ComplexModel cm = ct.ContentModel as ComplexModel; if (cm != null) { ComplexExt ce = cm.Content as ComplexExt; if (ce != null) { if (ce.Particle == null) { ce.Particle = CreateSequence(); } return(ce.Particle); } ComplexRst cr = cm.Content as ComplexRst; if (cr != null) { if (cr.Particle == null) { cr.Particle = CreateSequence(); } return(cr.Particle); } } throw Error(ct, "Schema inference internal error. The complexType should have been converted to have a complex content."); }
/// <remarks> /// 1. Content must be present /// </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 (isRedefinedComponent) { if (Annotation != null) { Annotation.isRedefinedComponent = true; } if (Content != null) { Content.isRedefinedComponent = true; } } if (Content == null) { error(h, "Content must be present in a complexContent"); } else { if (Content is XmlSchemaComplexContentRestriction) { XmlSchemaComplexContentRestriction xscr = (XmlSchemaComplexContentRestriction)Content; errorCount += xscr.Compile(h, schema); } else if (Content is XmlSchemaComplexContentExtension) { XmlSchemaComplexContentExtension xsce = (XmlSchemaComplexContentExtension)Content; errorCount += xsce.Compile(h, schema); } else { error(h, "complexContent can't have any value other than restriction or extention"); } } XmlSchemaUtil.CompileID(Id, this, schema.IDCollection, h); this.CompilationId = schema.CompilationId; return(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."); }
internal override int Compile(ValidationEventHandler h, XmlSchema schema) { if (this.CompilationId == schema.CompilationId) { return(0); } if (this.isRedefinedComponent) { if (base.Annotation != null) { base.Annotation.isRedefinedComponent = true; } if (this.Content != null) { this.Content.isRedefinedComponent = true; } } if (this.Content == null) { base.error(h, "Content must be present in a complexContent"); } else if (this.Content is XmlSchemaComplexContentRestriction) { XmlSchemaComplexContentRestriction xmlSchemaComplexContentRestriction = (XmlSchemaComplexContentRestriction)this.Content; this.errorCount += xmlSchemaComplexContentRestriction.Compile(h, schema); } else if (this.Content is XmlSchemaComplexContentExtension) { XmlSchemaComplexContentExtension xmlSchemaComplexContentExtension = (XmlSchemaComplexContentExtension)this.Content; this.errorCount += xmlSchemaComplexContentExtension.Compile(h, schema); } else { base.error(h, "complexContent 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 void ToEmptiableComplexContent( ComplexModel cm, bool isNew) { ComplexExt ce = cm.Content as ComplexExt; if (ce != null) { if (ce.Particle != null) { ce.Particle.MinOccurs = 0; } else if (ce.BaseTypeName != null && ce.BaseTypeName != QName.Empty && ce.BaseTypeName != QNameAnyType) { throw Error(ce, "Complex type content extension has a reference to an external component that is not supported."); } } else { ComplexRst cr = cm.Content as ComplexRst; if (cr == null) { throw Error(cm, "Invalid complex content model was passed."); } if (cr.Particle != null) { cr.Particle.MinOccurs = 0; } else if (cr.BaseTypeName != null && cr.BaseTypeName != QName.Empty && cr.BaseTypeName != QNameAnyType) { throw Error(cr, "Complex type content extension has a reference to an external component that is not supported."); } } }
protected override void Visit(XmlSchemaComplexContentRestriction restriction) { AddBaseTypeUsage(restriction.BaseTypeName); base.Visit(restriction); }
XmlCompletionItemCollection GetChildElementCompletion(XmlSchemaComplexContentRestriction restriction, string prefix) { // Add any elements. if (restriction.Particle != null) { XmlSchemaSequence sequence = restriction.Particle as XmlSchemaSequence; XmlSchemaChoice choice = restriction.Particle as XmlSchemaChoice; XmlSchemaGroupRef groupRef = restriction.Particle as XmlSchemaGroupRef; if(sequence != null) { return GetChildElementCompletion(sequence.Items, prefix); } else if (choice != null) { return GetChildElementCompletion(choice.Items, prefix); } else if (groupRef != null) { return GetChildElementCompletion(groupRef, prefix); } } return new XmlCompletionItemCollection(); }
/// <summary> /// Finds the named child element contained in the restriction element. /// </summary> XmlSchemaElement FindChildElement(XmlSchemaComplexContentRestriction restriction, QualifiedName name) { XmlSchemaSequence sequence = restriction.Particle as XmlSchemaSequence; XmlSchemaGroupRef groupRef = restriction.Particle as XmlSchemaGroupRef; if (sequence != null) { return FindElement(sequence.Items, name); } else if (groupRef != null) { return FindElement(groupRef, name); } return null; }
XmlSchemaComplexType FindComplexTyype(XmlQualifiedName qname) { if (qname.Name.IndexOf("[]") != -1) { XmlSchemaComplexType stype = new XmlSchemaComplexType(); stype.ContentModel = new XmlSchemaComplexContent(); XmlSchemaComplexContentRestriction res = new XmlSchemaComplexContentRestriction(); stype.ContentModel.Content = res; res.BaseTypeName = arrayType; XmlSchemaAttribute att = new XmlSchemaAttribute(); att.RefName = arrayTypeRefName; res.Attributes.Add(att); XmlAttribute xat = document.CreateAttribute("arrayType", WsdlNamespace); xat.Value = qname.Namespace + ":" + qname.Name; att.UnhandledAttributes = new XmlAttribute[] { xat }; return stype; } return (XmlSchemaComplexType)schemas.Find(qname, typeof(XmlSchemaComplexType)); }
internal static XmlSchemaComplexContentRestriction Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaComplexContentRestriction xmlSchemaComplexContentRestriction = new XmlSchemaComplexContentRestriction(); 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.Skip(); return(null); } xmlSchemaComplexContentRestriction.LineNumber = reader.LineNumber; xmlSchemaComplexContentRestriction.LinePosition = reader.LinePosition; xmlSchemaComplexContentRestriction.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "base") { Exception ex; xmlSchemaComplexContentRestriction.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") { xmlSchemaComplexContentRestriction.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, xmlSchemaComplexContentRestriction); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaComplexContentRestriction); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "restriction") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaComplexContentRestriction.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaComplexContentRestriction.Annotation = xmlSchemaAnnotation; } } else { if (num <= 2) { if (reader.LocalName == "group") { num = 3; XmlSchemaGroupRef xmlSchemaGroupRef = XmlSchemaGroupRef.Read(reader, h); if (xmlSchemaGroupRef != null) { xmlSchemaComplexContentRestriction.particle = xmlSchemaGroupRef; } continue; } if (reader.LocalName == "all") { num = 3; XmlSchemaAll xmlSchemaAll = XmlSchemaAll.Read(reader, h); if (xmlSchemaAll != null) { xmlSchemaComplexContentRestriction.particle = xmlSchemaAll; } continue; } if (reader.LocalName == "choice") { num = 3; XmlSchemaChoice xmlSchemaChoice = XmlSchemaChoice.Read(reader, h); if (xmlSchemaChoice != null) { xmlSchemaComplexContentRestriction.particle = xmlSchemaChoice; } continue; } if (reader.LocalName == "sequence") { num = 3; XmlSchemaSequence xmlSchemaSequence = XmlSchemaSequence.Read(reader, h); if (xmlSchemaSequence != null) { xmlSchemaComplexContentRestriction.particle = xmlSchemaSequence; } continue; } } if (num <= 3) { if (reader.LocalName == "attribute") { num = 3; XmlSchemaAttribute xmlSchemaAttribute = XmlSchemaAttribute.Read(reader, h); if (xmlSchemaAttribute != null) { xmlSchemaComplexContentRestriction.Attributes.Add(xmlSchemaAttribute); } continue; } if (reader.LocalName == "attributeGroup") { num = 3; XmlSchemaAttributeGroupRef xmlSchemaAttributeGroupRef = XmlSchemaAttributeGroupRef.Read(reader, h); if (xmlSchemaAttributeGroupRef != null) { xmlSchemaComplexContentRestriction.attributes.Add(xmlSchemaAttributeGroupRef); } continue; } } if (num <= 4 && reader.LocalName == "anyAttribute") { num = 5; XmlSchemaAnyAttribute xmlSchemaAnyAttribute = XmlSchemaAnyAttribute.Read(reader, h); if (xmlSchemaAnyAttribute != null) { xmlSchemaComplexContentRestriction.AnyAttribute = xmlSchemaAnyAttribute; } } else { reader.RaiseInvalidElementError(); } } } return(xmlSchemaComplexContentRestriction); }
void GetAttributeCompletionData (XmlCompletionDataList data, XmlSchemaComplexContentRestriction restriction) { GetAttributeCompletionData (data, restriction.Attributes); var baseComplexType = FindNamedType(schema, restriction.BaseTypeName); if (baseComplexType != null) { GetAttributeCompletionData (data, baseComplexType); } }
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); }
//<restriction // base = QName // id = ID // {any attributes with non-schema namespace . . .}> // Content: (annotation?, ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?))) //</restriction> internal static XmlSchemaComplexContentRestriction Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaComplexContentRestriction restriction = new XmlSchemaComplexContentRestriction(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaComplexContentRestriction.Read, name=" + reader.Name, null); reader.Skip(); 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.(group | all | choice | sequence)?, (3.(attribute | attributeGroup)*, 4.anyAttribute?))) int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaComplexContentRestriction.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) { if (reader.LocalName == "group") { level = 3; XmlSchemaGroupRef group = XmlSchemaGroupRef.Read(reader, h); if (group != null) { restriction.particle = group; } continue; } if (reader.LocalName == "all") { level = 3; XmlSchemaAll all = XmlSchemaAll.Read(reader, h); if (all != null) { restriction.particle = all; } continue; } if (reader.LocalName == "choice") { level = 3; XmlSchemaChoice choice = XmlSchemaChoice.Read(reader, h); if (choice != null) { restriction.particle = choice; } continue; } if (reader.LocalName == "sequence") { level = 3; XmlSchemaSequence sequence = XmlSchemaSequence.Read(reader, h); if (sequence != null) { restriction.particle = sequence; } continue; } } if (level <= 3) { if (reader.LocalName == "attribute") { level = 3; XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader, h); if (attr != null) { restriction.Attributes.Add(attr); } continue; } if (reader.LocalName == "attributeGroup") { level = 3; XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader, h); if (attr != null) { restriction.attributes.Add(attr); } continue; } } if (level <= 4 && reader.LocalName == "anyAttribute") { level = 5; XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader, h); if (anyattr != null) { restriction.AnyAttribute = anyattr; } continue; } reader.RaiseInvalidElementError(); } return(restriction); }
public virtual void Check (ConformanceCheckContext ctx, XmlSchemaComplexContentRestriction value) {}
internal static XmlSchemaComplexContent Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaComplexContent xmlSchemaComplexContent = new XmlSchemaComplexContent(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "complexContent") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaComplexContent.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaComplexContent.LineNumber = reader.LineNumber; xmlSchemaComplexContent.LinePosition = reader.LinePosition; xmlSchemaComplexContent.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaComplexContent.Id = reader.Value; } else if (reader.Name == "mixed") { Exception ex; xmlSchemaComplexContent.isMixed = XmlSchemaUtil.ReadBoolAttribute(reader, out ex); if (ex != null) { XmlSchemaObject.error(h, reader.Value + " is an invalid value for mixed", ex); } } 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 complexContent", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaComplexContent); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaComplexContent); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "complexContent") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaComplexContent.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaComplexContent.Annotation = xmlSchemaAnnotation; } } else { if (num <= 2) { if (reader.LocalName == "restriction") { num = 3; XmlSchemaComplexContentRestriction xmlSchemaComplexContentRestriction = XmlSchemaComplexContentRestriction.Read(reader, h); if (xmlSchemaComplexContentRestriction != null) { xmlSchemaComplexContent.content = xmlSchemaComplexContentRestriction; } continue; } if (reader.LocalName == "extension") { num = 3; XmlSchemaComplexContentExtension xmlSchemaComplexContentExtension = XmlSchemaComplexContentExtension.Read(reader, h); if (xmlSchemaComplexContentExtension != null) { xmlSchemaComplexContent.content = xmlSchemaComplexContentExtension; } continue; } } reader.RaiseInvalidElementError(); } } return(xmlSchemaComplexContent); }
//<restriction // base = QName // id = ID // {any attributes with non-schema namespace . . .}> // Content: (annotation?, ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?))) //</restriction> internal static XmlSchemaComplexContentRestriction Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaComplexContentRestriction restriction = new XmlSchemaComplexContentRestriction(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaComplexContentRestriction.Read, name="+reader.Name,null); reader.Skip(); 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.(group | all | choice | sequence)?, (3.(attribute | attributeGroup)*, 4.anyAttribute?))) int level = 1; while(reader.ReadNextElement()) { if(reader.NodeType == XmlNodeType.EndElement) { if(reader.LocalName != xmlname) error(h,"Should not happen :2: XmlSchemaComplexContentRestriction.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) { if(reader.LocalName == "group") { level = 3; XmlSchemaGroupRef group = XmlSchemaGroupRef.Read(reader,h); if(group != null) restriction.particle = group; continue; } if(reader.LocalName == "all") { level = 3; XmlSchemaAll all = XmlSchemaAll.Read(reader,h); if(all != null) restriction.particle = all; continue; } if(reader.LocalName == "choice") { level = 3; XmlSchemaChoice choice = XmlSchemaChoice.Read(reader,h); if(choice != null) restriction.particle = choice; continue; } if(reader.LocalName == "sequence") { level = 3; XmlSchemaSequence sequence = XmlSchemaSequence.Read(reader,h); if(sequence != null) restriction.particle = sequence; continue; } } if(level <= 3) { if(reader.LocalName == "attribute") { level = 3; XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader,h); if(attr != null) restriction.Attributes.Add(attr); continue; } if(reader.LocalName == "attributeGroup") { level = 3; XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader,h); if(attr != null) restriction.attributes.Add(attr); continue; } } if(level <= 4 && reader.LocalName == "anyAttribute") { level = 5; XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader,h); if(anyattr != null) restriction.AnyAttribute = anyattr; continue; } reader.RaiseInvalidElementError(); } return restriction; }
//<complexContent // id = ID // mixed = boolean // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (restriction | extension)) //</complexContent> internal static XmlSchemaComplexContent Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaComplexContent complex = new XmlSchemaComplexContent(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaComplexContent.Read, name=" + reader.Name, null); reader.Skip(); return(null); } complex.LineNumber = reader.LineNumber; complex.LinePosition = reader.LinePosition; complex.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { complex.Id = reader.Value; } else if (reader.Name == "mixed") { Exception innerex; complex.isMixed = XmlSchemaUtil.ReadBoolAttribute(reader, out innerex); if (innerex != null) { error(h, reader.Value + " is an invalid value for mixed", innerex); } } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for complexContent", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, complex); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(complex); } //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: XmlSchemaComplexContent.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) { complex.Annotation = annotation; } continue; } if (level <= 2) { if (reader.LocalName == "restriction") { level = 3; XmlSchemaComplexContentRestriction restriction = XmlSchemaComplexContentRestriction.Read(reader, h); if (restriction != null) { complex.content = restriction; } continue; } if (reader.LocalName == "extension") { level = 3; XmlSchemaComplexContentExtension extension = XmlSchemaComplexContentExtension.Read(reader, h); if (extension != null) { complex.content = extension; } continue; } } reader.RaiseInvalidElementError(); } return(complex); }
private void Write56_XmlSchemaComplexContentRestriction(XmlSchemaComplexContentRestriction 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); if (o.Particle is XmlSchemaSequence) { this.Write54_XmlSchemaSequence((XmlSchemaSequence) o.Particle); } else if (o.Particle is XmlSchemaGroupRef) { this.Write55_XmlSchemaGroupRef((XmlSchemaGroupRef) o.Particle); } else if (o.Particle is XmlSchemaChoice) { this.Write52_XmlSchemaChoice((XmlSchemaChoice) o.Particle); } else if (o.Particle is XmlSchemaAll) { this.Write43_XmlSchemaAll((XmlSchemaAll) o.Particle); } this.WriteSortedItems(o.Attributes); this.Write33_XmlSchemaAnyAttribute(o.AnyAttribute); this.WriteEndElement(); } }
protected virtual void Visit(XmlSchemaComplexContentRestriction restriction) { if (restriction.Particle != null) Traverse(restriction.Particle); Traverse(restriction.Attributes); if (restriction.AnyAttribute != null) Traverse(restriction.AnyAttribute); }
XmlQualifiedName ExportArraySchema (XmlTypeMapping map, string defaultNamespace) { ListMap lmap = (ListMap) map.ObjectMap; if (encodedFormat) { string name, ns, schemaNs; lmap.GetArrayType (-1, out name, out ns); if (ns == XmlSchema.Namespace) schemaNs = defaultNamespace; else schemaNs = ns; if (IsMapExported (map)) return new XmlQualifiedName (lmap.GetSchemaArrayName (), schemaNs); SetMapExported (map); XmlSchema schema = GetSchema (schemaNs); XmlSchemaComplexType stype = new XmlSchemaComplexType (); stype.Name = lmap.GetSchemaArrayName (); schema.Items.Add (stype); XmlSchemaComplexContent content = new XmlSchemaComplexContent(); content.IsMixed = false; stype.ContentModel = content; XmlSchemaComplexContentRestriction rest = new XmlSchemaComplexContentRestriction (); content.Content = rest; rest.BaseTypeName = new XmlQualifiedName ("Array", XmlSerializer.EncodingNamespace); XmlSchemaAttribute at = new XmlSchemaAttribute (); rest.Attributes.Add (at); at.RefName = new XmlQualifiedName ("arrayType", XmlSerializer.EncodingNamespace); XmlAttribute arrayType = Document.CreateAttribute ("arrayType", XmlSerializer.WsdlNamespace); arrayType.Value = ns + (ns != "" ? ":" : "") + name; at.UnhandledAttributes = new XmlAttribute [] { arrayType }; ImportNamespace (schema, XmlSerializer.WsdlNamespace); XmlTypeMapElementInfo einfo = (XmlTypeMapElementInfo) lmap.ItemInfo[0]; if (einfo.MappedType != null) { switch (einfo.TypeData.SchemaType) { case SchemaTypes.Enum: ExportEnumSchema (einfo.MappedType); break; case SchemaTypes.Array: ExportArraySchema (einfo.MappedType, schemaNs); break; case SchemaTypes.Class: ExportClassSchema (einfo.MappedType); break; } } return new XmlQualifiedName (lmap.GetSchemaArrayName (), schemaNs); } else { if (IsMapExported (map)) return new XmlQualifiedName (map.XmlType, map.XmlTypeNamespace); SetMapExported (map); XmlSchema schema = GetSchema (map.XmlTypeNamespace); XmlSchemaComplexType stype = new XmlSchemaComplexType (); stype.Name = map.ElementName; schema.Items.Add (stype); XmlSchemaParticle spart = GetSchemaArrayElement (schema, lmap.ItemInfo); if (spart is XmlSchemaChoice) stype.Particle = spart; else { XmlSchemaSequence seq = new XmlSchemaSequence (); seq.Items.Add (spart); stype.Particle = seq; } return new XmlQualifiedName (map.XmlType, map.XmlTypeNamespace); } }
XmlQualifiedName ExportArrayMapping(ArrayMapping mapping, string ns) { // for the Rpc ArrayMapping different mappings could have the same schema type // we link all mappings corresponding to the same type together // loop through all mapping that will map to the same complexType, and export only one, // the obvious choice is the last one. while (mapping.Next != null) { mapping = mapping.Next; } XmlSchemaComplexType type = (XmlSchemaComplexType)types[mapping]; if (type == null) { CheckForDuplicateType(mapping.TypeName, mapping.Namespace); type = new XmlSchemaComplexType(); type.Name = mapping.TypeName; types.Add(mapping, type); // we need to add the type first, to make sure that the schema get created AddSchemaItem(type, mapping.Namespace, ns); AddSchemaImport(Soap.Encoding, mapping.Namespace); AddSchemaImport(Wsdl.Namespace, mapping.Namespace); XmlSchemaComplexContentRestriction restriction = new XmlSchemaComplexContentRestriction(); XmlQualifiedName qname = ExportTypeMapping(mapping.Elements[0].Mapping, mapping.Namespace); if (qname.IsEmpty) { // this is a root mapping qname = new XmlQualifiedName(Soap.UrType, XmlSchema.Namespace); } //<attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:float[]"/> XmlSchemaAttribute attr = new XmlSchemaAttribute(); attr.RefName = ArrayTypeQName; XmlAttribute attribute = new XmlAttribute("wsdl", Wsdl.ArrayType, Wsdl.Namespace, Document); attribute.Value = qname.Namespace + ":" + qname.Name + "[]"; attr.UnhandledAttributes = new XmlAttribute[] {attribute}; restriction.Attributes.Add(attr); restriction.BaseTypeName = ArrayQName; XmlSchemaComplexContent model = new XmlSchemaComplexContent(); model.Content = restriction; type.ContentModel = model; } else { AddSchemaImport(mapping.Namespace, ns); } return new XmlQualifiedName(mapping.TypeName, mapping.Namespace); }
void GetChildElementCompletionData (XmlCompletionDataList data, XmlSchemaComplexContentRestriction restriction, string prefix) { if (restriction.Particle == null) return; var sequence = restriction.Particle as XmlSchemaSequence; if (sequence != null) { GetChildElementCompletionData (data, sequence.Items, prefix); return; } var choice = restriction.Particle as XmlSchemaChoice; if (choice != null) { GetChildElementCompletionData (data, choice.Items, prefix); return; } var groupRef = restriction.Particle as XmlSchemaGroupRef; if (groupRef != null) { GetChildElementCompletionData (data, groupRef, prefix); return; } }
private void CompileComplexContentRestriction(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaComplexContentRestriction complexRestriction) { XmlSchemaComplexType baseType = null; if (complexType.Redefined != null && complexRestriction.BaseTypeName == complexType.Redefined.QualifiedName) { baseType = (XmlSchemaComplexType)complexType.Redefined; CompileComplexType(baseType); } else { baseType = GetComplexType(complexRestriction.BaseTypeName); if (baseType == null) { SendValidationEvent(Res.Sch_UndefBaseRestriction, complexRestriction.BaseTypeName.ToString(), complexRestriction); return; } } if (baseType != null && baseType.ElementDecl != null) { if (baseType.ContentType == XmlSchemaContentType.TextOnly) { SendValidationEvent(Res.Sch_NotComplexContent, complexType); return; } } complexType.SetBaseSchemaType(baseType); if ((baseType.FinalResolved & XmlSchemaDerivationMethod.Restriction) != 0) { SendValidationEvent(Res.Sch_BaseFinalRestriction, complexType); } CompileLocalAttributes(baseType, complexType, complexRestriction.Attributes, complexRestriction.AnyAttribute, XmlSchemaDerivationMethod.Restriction); complexType.SetContentTypeParticle(CompileContentTypeParticle(complexRestriction.Particle, true)); complexType.SetContentType(GetSchemaContentType(complexType, complexContent, complexType.ContentTypeParticle)); if (complexType.ContentType == XmlSchemaContentType.Empty) { if (baseType.ElementDecl != null) { Debug.Assert(baseType.ElementDecl.ContentValidator != null); } if (baseType.ElementDecl != null && !baseType.ElementDecl.ContentValidator.IsEmptiable) { SendValidationEvent(Res.Sch_InvalidContentRestriction, complexType); } } complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction); }
internal void ReflectStringParametersMessage() { Message inputMessage = InputMessage; foreach (ParameterInfo parameterInfo in Method.InParameters) { MessagePart part = new MessagePart(); part.Name = XmlConvert.EncodeLocalName(parameterInfo.Name); if (parameterInfo.ParameterType.IsArray) { string typeNs = DefaultNamespace; if (typeNs.EndsWith("/", StringComparison.Ordinal)) typeNs += "AbstractTypes"; else typeNs += "/AbstractTypes"; string typeName = "StringArray"; if (!ServiceDescription.Types.Schemas.Contains(typeNs)) { XmlSchema schema = new XmlSchema(); schema.TargetNamespace = typeNs; ServiceDescription.Types.Schemas.Add(schema); XmlSchemaElement element = new XmlSchemaElement(); element.Name = "String"; element.SchemaTypeName = new XmlQualifiedName("string", XmlSchema.Namespace); element.MinOccurs = decimal.Zero; element.MaxOccurs = decimal.MaxValue; XmlSchemaSequence all = new XmlSchemaSequence(); all.Items.Add(element); XmlSchemaComplexContentRestriction restriction = new XmlSchemaComplexContentRestriction(); restriction.BaseTypeName = new XmlQualifiedName(Soap.ArrayType, Soap.Encoding); restriction.Particle = all; XmlSchemaImport import = new XmlSchemaImport(); import.Namespace = restriction.BaseTypeName.Namespace; XmlSchemaComplexContent model = new XmlSchemaComplexContent(); model.Content = restriction; XmlSchemaComplexType type = new XmlSchemaComplexType(); type.Name = typeName; type.ContentModel = model; schema.Items.Add(type); schema.Includes.Add(import); } part.Type = new XmlQualifiedName(typeName, typeNs); } else { part.Type = new XmlQualifiedName("string", XmlSchema.Namespace); } inputMessage.Parts.Add(part); } }
public override void Check (ConformanceCheckContext ctx, XmlSchemaComplexContentRestriction value) { CheckSchemaQName (ctx, value, value.BaseTypeName); if (value.BaseTypeName.Namespace == "http://schemas.xmlsoap.org/soap/encoding/" && value.BaseTypeName.Name == "Array") ctx.ReportRuleViolation (value, BasicProfileRules.R2110); }
static void AddAppSequenceType(DiscoveryVersion discoveryVersion, XmlSchema schema) { //<xs:complexType name="AppSequenceType" > XmlSchemaComplexType appSequenceType = new XmlSchemaComplexType(); appSequenceType.Name = ProtocolStrings.SchemaNames.AppSequenceType; // <xs:complexContent> XmlSchemaComplexContent complexContent = new XmlSchemaComplexContent(); appSequenceType.ContentModel = complexContent; // <xs:restriction base="xs:anyType" > XmlSchemaComplexContentRestriction contentRestriction = new XmlSchemaComplexContentRestriction(); complexContent.Content = contentRestriction; contentRestriction.BaseTypeName = discoveryVersion.Implementation.QualifiedNames.AnyType; // <xs:attribute name="InstanceId" type="xs:unsignedInt" use="required" /> XmlSchemaAttribute instanceId = new XmlSchemaAttribute(); instanceId.Name = ProtocolStrings.SchemaNames.AppSequenceInstanceId; instanceId.SchemaTypeName = discoveryVersion.Implementation.QualifiedNames.UnsignedIntType; instanceId.Use = XmlSchemaUse.Required; // <xs:attribute name="SequenceId" type="xs:anyURI" /> XmlSchemaAttribute sequenceId = new XmlSchemaAttribute(); sequenceId.Name = ProtocolStrings.SchemaNames.AppSequenceSequenceId; sequenceId.SchemaTypeName = discoveryVersion.Implementation.QualifiedNames.AnyUriType; // <xs:attribute name="MessageNumber" type="xs:unsignedInt" use="required" /> XmlSchemaAttribute messageNumber = new XmlSchemaAttribute(); messageNumber.Name = ProtocolStrings.SchemaNames.AppSequenceMessageNumber; messageNumber.SchemaTypeName = discoveryVersion.Implementation.QualifiedNames.UnsignedIntType; messageNumber.Use = XmlSchemaUse.Required; // <xs:anyAttribute namespace="##other" processContents="lax" /> XmlSchemaAnyAttribute anyAttribue = new XmlSchemaAnyAttribute(); anyAttribue.Namespace = "##other"; anyAttribue.ProcessContents = XmlSchemaContentProcessing.Lax; contentRestriction.Attributes.Add(instanceId); contentRestriction.Attributes.Add(sequenceId); contentRestriction.Attributes.Add(messageNumber); contentRestriction.AnyAttribute = anyAttribue; schema.Items.Add(appSequenceType); }
void Handler.BeginComplexContentRestriction(XmlSchemaComplexContentRestriction complexContentRestriction) { }
void ParseArrayType(XmlSchemaComplexContentRestriction rest, out XmlQualifiedName qtype) { XmlSchemaAttribute arrayTypeAt = FindArrayAttribute(rest.Attributes); XmlAttribute[] uatts = arrayTypeAt.UnhandledAttributes; if (uatts == null || uatts.Length == 0) throw new InvalidOperationException("arrayType attribute not specified in array declaration"); XmlAttribute xat = null; foreach (XmlAttribute at in uatts) if (at.LocalName == "arrayType" && at.NamespaceURI == WsdlNamespace) { xat = at; break; } if (xat == null) throw new InvalidOperationException("arrayType attribute not specified in array declaration"); string arrayType = xat.Value; string type, ns; int i = arrayType.LastIndexOf(":"); if (i == -1) ns = ""; else ns = arrayType.Substring(0, i); int j = arrayType.IndexOf("[", i + 1); if (j == -1) throw new InvalidOperationException("Cannot parse WSDL array type: " + arrayType); type = arrayType.Substring(i + 1); type = type.Substring(0, type.Length - 2); qtype = new XmlQualifiedName(type, ns); }
private void CompileComplexContentRestriction(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaComplexContentRestriction complexRestriction) { XmlSchemaComplexType baseType = null; if (complexType.Redefined != null && complexRestriction.BaseTypeName == complexType.Redefined.QualifiedName) { baseType = (XmlSchemaComplexType)complexType.Redefined; CompileComplexType(baseType); } else { baseType = GetComplexType(complexRestriction.BaseTypeName); if (baseType == null) { SendValidationEvent(Res.Sch_UndefBaseRestriction, complexRestriction.BaseTypeName.ToString(), complexRestriction); return; } } complexType.SetBaseSchemaType(baseType); if ((baseType.FinalResolved & XmlSchemaDerivationMethod.Restriction) != 0) { SendValidationEvent(Res.Sch_BaseFinalRestriction, complexType); } CompileLocalAttributes(baseType, complexType, complexRestriction.Attributes, complexRestriction.AnyAttribute, XmlSchemaDerivationMethod.Restriction); complexType.SetContentTypeParticle(CompileContentTypeParticle(complexRestriction.Particle)); XmlSchemaContentType derivedContentType = GetSchemaContentType(complexType, complexContent, complexType.ContentTypeParticle); complexType.SetContentType(derivedContentType); switch(derivedContentType) { case XmlSchemaContentType.Empty: if (baseType.ElementDecl != null && !baseType.ElementDecl.ContentValidator.IsEmptiable) { //base is either TextOnly or its ElementOnly/Mixed and not emptiable SendValidationEvent(Res.Sch_InvalidContentRestrictionDetailed, Res.GetString(Res.Sch_InvalidBaseToEmpty), complexType); } break; case XmlSchemaContentType.Mixed: if (baseType.ContentType != XmlSchemaContentType.Mixed) { SendValidationEvent(Res.Sch_InvalidContentRestrictionDetailed, Res.GetString(Res.Sch_InvalidBaseToMixed), complexType); } break; } complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction); }
XmlSchemaAttribute FindAttribute(XmlSchemaComplexContentRestriction restriction, string name) { XmlSchemaAttribute matchedAttribute = FindAttribute(restriction.Attributes, name); if (matchedAttribute == null) { XmlSchemaComplexType complexType = FindNamedType(schema, restriction.BaseTypeName); if (complexType != null) { return FindAttribute(complexType, name); } } return matchedAttribute; }
void Write56_XmlSchemaComplexContentRestriction(XmlSchemaComplexContentRestriction 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); if (o.@Particle is XmlSchemaSequence) { Write54_XmlSchemaSequence((XmlSchemaSequence)o.@Particle); } else if (o.@Particle is XmlSchemaGroupRef) { Write55_XmlSchemaGroupRef((XmlSchemaGroupRef)o.@Particle); } else if (o.@Particle is XmlSchemaChoice) { Write52_XmlSchemaChoice((XmlSchemaChoice)o.@Particle); } else if (o.@Particle is XmlSchemaAll) { Write43_XmlSchemaAll((XmlSchemaAll)o.@Particle); } WriteSortedItems(o.Attributes); Write33_XmlSchemaAnyAttribute((XmlSchemaAnyAttribute)o.@AnyAttribute); WriteEndElement(); }
XmlCompletionItemCollection GetAttributeCompletion(XmlSchemaComplexContentRestriction restriction, XmlNamespaceCollection namespacesInScope) { XmlCompletionItemCollection completionItems = new XmlCompletionItemCollection(); completionItems.AddRange(GetAttributeCompletion(restriction.Attributes, namespacesInScope)); completionItems.AddRange(GetBaseComplexTypeAttributeCompletion(restriction.BaseTypeName, namespacesInScope)); return completionItems; }
private void Write57_Item(string n, string ns, XmlSchemaComplexContentRestriction o, bool isNullable, bool needType) { if (o == null) { if (isNullable) { base.WriteNullTagLiteral(n, ns); } } else { if (!needType && !(o.GetType() == typeof(XmlSchemaComplexContentRestriction))) { throw base.CreateUnknownTypeException(o); } base.EscapeName = false; base.WriteStartElement(n, ns, o, false, o.Namespaces); if (needType) { base.WriteXsiType("XmlSchemaComplexContentRestriction", "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); if (o.Particle is XmlSchemaAll) { this.Write55_XmlSchemaAll("all", "http://www.w3.org/2001/XMLSchema", (XmlSchemaAll) o.Particle, false, false); } else if (o.Particle is XmlSchemaSequence) { this.Write53_XmlSchemaSequence("sequence", "http://www.w3.org/2001/XMLSchema", (XmlSchemaSequence) o.Particle, false, false); } else if (o.Particle is XmlSchemaChoice) { this.Write54_XmlSchemaChoice("choice", "http://www.w3.org/2001/XMLSchema", (XmlSchemaChoice) o.Particle, false, false); } else if (o.Particle is XmlSchemaGroupRef) { this.Write44_XmlSchemaGroupRef("group", "http://www.w3.org/2001/XMLSchema", (XmlSchemaGroupRef) o.Particle, false, false); } else if (o.Particle != null) { throw base.CreateUnknownTypeException(o.Particle); } XmlSchemaObjectCollection attributes = o.Attributes; if (attributes != null) { for (int j = 0; j < attributes.Count; j++) { XmlSchemaObject obj2 = attributes[j]; if (obj2 is XmlSchemaAttribute) { this.Write36_XmlSchemaAttribute("attribute", "http://www.w3.org/2001/XMLSchema", (XmlSchemaAttribute) obj2, false, false); } else if (obj2 is XmlSchemaAttributeGroupRef) { this.Write37_XmlSchemaAttributeGroupRef("attributeGroup", "http://www.w3.org/2001/XMLSchema", (XmlSchemaAttributeGroupRef) obj2, false, false); } else if (obj2 != null) { throw base.CreateUnknownTypeException(obj2); } } } this.Write39_XmlSchemaAnyAttribute("anyAttribute", "http://www.w3.org/2001/XMLSchema", o.AnyAttribute, false, false); base.WriteEndElement(o); } }
XmlCompletionDataCollection GetAttributeCompletionData(XmlSchemaComplexContentRestriction restriction) { XmlCompletionDataCollection data = new XmlCompletionDataCollection(); data.AddRange(GetAttributeCompletionData(restriction.Attributes)); XmlSchemaComplexType baseComplexType = FindNamedType(schema, restriction.BaseTypeName); if (baseComplexType != null) { data.AddRange(GetAttributeCompletionData(baseComplexType)); } return data; }
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; }
private void CompileComplexContentRestriction(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaComplexContentRestriction complexRestriction) { XmlSchemaComplexType redefined = null; if ((complexType.Redefined != null) && (complexRestriction.BaseTypeName == complexType.Redefined.QualifiedName)) { redefined = (XmlSchemaComplexType) complexType.Redefined; this.CompileComplexType(redefined); } else { redefined = this.GetComplexType(complexRestriction.BaseTypeName); if (redefined == null) { base.SendValidationEvent("Sch_UndefBaseRestriction", complexRestriction.BaseTypeName.ToString(), complexRestriction); return; } } complexType.SetBaseSchemaType(redefined); if ((redefined.FinalResolved & XmlSchemaDerivationMethod.Restriction) != XmlSchemaDerivationMethod.Empty) { base.SendValidationEvent("Sch_BaseFinalRestriction", complexType); } this.CompileLocalAttributes(redefined, complexType, complexRestriction.Attributes, complexRestriction.AnyAttribute, XmlSchemaDerivationMethod.Restriction); complexType.SetContentTypeParticle(this.CompileContentTypeParticle(complexRestriction.Particle)); XmlSchemaContentType type2 = this.GetSchemaContentType(complexType, complexContent, complexType.ContentTypeParticle); complexType.SetContentType(type2); switch (type2) { case XmlSchemaContentType.Empty: if ((redefined.ElementDecl != null) && !redefined.ElementDecl.ContentValidator.IsEmptiable) { base.SendValidationEvent("Sch_InvalidContentRestrictionDetailed", Res.GetString("Sch_InvalidBaseToEmpty"), complexType); } break; case XmlSchemaContentType.Mixed: if (redefined.ContentType != XmlSchemaContentType.Mixed) { base.SendValidationEvent("Sch_InvalidContentRestrictionDetailed", Res.GetString("Sch_InvalidBaseToMixed"), complexType); } break; } complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction); }
protected override void Visit(XmlSchemaComplexContentRestriction restriction) { ProcessRestriction(restriction.BaseTypeName, restriction.Attributes, restriction.AnyAttribute); }
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(XmlSchemaComplexContentRestriction restriction) { // Does not have text. }
private void CompileComplexContentRestriction(XmlSchemaComplexType complexType, XmlSchemaComplexContent complexContent, XmlSchemaComplexContentRestriction complexRestriction) { XmlSchemaComplexType redefined = null; if ((complexType.Redefined != null) && (complexRestriction.BaseTypeName == complexType.Redefined.QualifiedName)) { redefined = (XmlSchemaComplexType) complexType.Redefined; this.CompileComplexType(redefined); } else { redefined = this.GetComplexType(complexRestriction.BaseTypeName); if (redefined == null) { base.SendValidationEvent("Sch_UndefBaseRestriction", complexRestriction.BaseTypeName.ToString(), complexRestriction); return; } } if (((redefined != null) && (redefined.ElementDecl != null)) && (redefined.ContentType == XmlSchemaContentType.TextOnly)) { base.SendValidationEvent("Sch_NotComplexContent", complexType); } else { complexType.SetBaseSchemaType(redefined); if ((redefined.FinalResolved & XmlSchemaDerivationMethod.Restriction) != XmlSchemaDerivationMethod.Empty) { base.SendValidationEvent("Sch_BaseFinalRestriction", complexType); } this.CompileLocalAttributes(redefined, complexType, complexRestriction.Attributes, complexRestriction.AnyAttribute, XmlSchemaDerivationMethod.Restriction); complexType.SetContentTypeParticle(this.CompileContentTypeParticle(complexRestriction.Particle, true)); complexType.SetContentType(this.GetSchemaContentType(complexType, complexContent, complexType.ContentTypeParticle)); if (complexType.ContentType == XmlSchemaContentType.Empty) { SchemaElementDecl elementDecl = redefined.ElementDecl; if ((redefined.ElementDecl != null) && !redefined.ElementDecl.ContentValidator.IsEmptiable) { base.SendValidationEvent("Sch_InvalidContentRestriction", complexType); } } complexType.SetDerivedBy(XmlSchemaDerivationMethod.Restriction); } }
private void NavigateComplexContentRestriction(XmlSchemaComplexContentRestriction complexContentRestriction) { handler.BeginComplexContentRestriction(complexContentRestriction); NavigateParticle(complexContentRestriction.Particle); handler.EndComplexContentRestriction(); }