private void ImportGroupMembers(XmlSchemaParticle particle, CodeIdentifiers members, string ns) { XmlQualifiedName parentName = XmlSchemas.GetParentName(particle); if (particle is XmlSchemaGroupRef) { throw new InvalidOperationException(Res.GetString("XmlSoapUnsupportedGroupRef", new object[] { parentName.Name, parentName.Namespace })); } if (particle is XmlSchemaGroupBase) { XmlSchemaGroupBase base2 = (XmlSchemaGroupBase)particle; if (base2.IsMultipleOccurrence) { throw new InvalidOperationException(Res.GetString("XmlSoapUnsupportedGroupRepeat", new object[] { parentName.Name, parentName.Namespace })); } for (int i = 0; i < base2.Items.Count; i++) { object obj2 = base2.Items[i]; if ((obj2 is XmlSchemaGroupBase) || (obj2 is XmlSchemaGroupRef)) { throw new InvalidOperationException(Res.GetString("XmlSoapUnsupportedGroupNested", new object[] { parentName.Name, parentName.Namespace })); } if (obj2 is XmlSchemaElement) { this.ImportElementMember((XmlSchemaElement)obj2, members, ns); } else if (obj2 is XmlSchemaAny) { throw new InvalidOperationException(Res.GetString("XmlSoapUnsupportedGroupAny", new object[] { parentName.Name, parentName.Namespace })); } } } }
private void roopItem(XmlSchemaGroupBase xgb) { bool choice = false; if (xgb is XmlSchemaChoice) { choice = true; } foreach (XmlSchemaObject item in xgb.Items) { if (item is XmlSchemaElement) { XmlSchemaElement itemCast = item as XmlSchemaElement; if (itemCast.RefName.IsEmpty) { m_MemberVariable.Add(new Variable(itemCast.SchemaTypeName.Name, itemCast.Name, choice)); } else { // 처리 } } else if (item is XmlSchemaGroupBase) { XmlSchemaGroupBase xgbSub = item as XmlSchemaGroupBase; roopItem(xgbSub); } } }
private XmlSchemaGroupBase AddSequence(XmlSchemaGroupBase schema, string name, bool required, XmlSchemaComplexType type = null) { var element = new XmlSchemaElement(); if (!required) { element.MinOccurs = 0; element.MaxOccurs = 1; } XmlSchemaComplexType currentType = type == null ? new XmlSchemaComplexType() : type; var all = new XmlSchemaSequence(); element.Name = name; if (type == null) { element.SchemaType = currentType; } else { element.SchemaTypeName = new XmlQualifiedName(currentType.Name); } currentType.Particle = all; schema.Items.Add(element); return(all); }
public static IEnumerable <XmlSchemaElement> LocalXsdElements(this XmlSchemaParticle pa) { if (pa != null) { XmlSchemaGroupBase xmlSchemaGroupBase = pa as XmlSchemaGroupBase; if (xmlSchemaGroupBase == null) { XmlSchemaElement xmlSchemaElement = pa as XmlSchemaElement; if (xmlSchemaElement != null) { yield return(xmlSchemaElement); foreach (XmlSchemaElement xmlSchemaElement1 in xmlSchemaElement.SchemaType.LocalXsdElements()) { yield return(xmlSchemaElement1); } } } else { foreach (XmlSchemaParticle item in xmlSchemaGroupBase.Items) { foreach (XmlSchemaElement xmlSchemaElement2 in item.LocalXsdElements()) { yield return(xmlSchemaElement2); } } } } }
Shape ProcessParticleGroup(XmlSchemaGroupBase xsg, BindingType bt) { Shape s = new Shape(null, bt); StringBuilder sb = new StringBuilder(); foreach (XmlSchemaParticle xsp in xsg.Items) { Shape sub = ProcessParticle(xsp, s); if (sub != null) //sub can be null if the child particle is xs:any { if (sb.Length > 0) { sb.Append('_'); } sb.Append(sub.Name); } } // need to also test if paretn != null for this to work //if (s.IsGroup && s.SubShapes.Count == 1) { // Shape sub = (Shape)s.SubShapes[0]; // s.Clear(); // return sub; //} s.Name = sb.ToString(); return(s); }
private void GenerateGroupBase(XmlSchemaGroupBase gBase, InstanceGroup grp) { foreach (XmlSchemaParticle particle1 in gBase.Items) { GenerateParticle(particle1, false, grp); } }
/// <summary> /// Traverses a complex element. /// </summary> /// <param name="element">The current element.</param> /// <param name="type">The current element type.</param> /// <param name="name">The element name.</param> /// <param name="typeName">The element type name, that is, name + typeNaming.</param> /// <param name="parent">The parent of the element received.</param> /// <returns>The IVisitableComponent to add to the composite parent.</returns> private IVisitableComponent RecurseElement(XmlSchemaElement element, XmlSchemaComplexType type, string name, string typeName, BaseSchemaTypedElement parent) { VisitableElementComplexType result = new VisitableElementComplexType(element, type, name, typeName, parent); // Traverse all the attributes of the complex type. foreach (XmlSchemaObject obj in type.Attributes) { if (obj is XmlSchemaAttribute) { result.Add(Build(obj as XmlSchemaAttribute, result)); } } // We only take into account the Choice and Sequence subgroups. if (type.Particle is XmlSchemaGroupBase && !(type.Particle is XmlSchemaAll)) { XmlSchemaGroupBase group = type.Particle as XmlSchemaGroupBase; foreach (XmlSchemaObject item in group.Items) { if (item is XmlSchemaElement) { result.Add(Build(item as XmlSchemaElement, result)); } } } return(result); }
RelaxngPattern CreatePatternFromParticleCore(XmlSchemaParticle xsdp) { XmlSchemaGroupBase gb = xsdp as XmlSchemaGroupBase; if (xsdp is XmlSchemaAny) { RelaxngRef r = new RelaxngRef(); r.Name = "anyType"; return(r); } if (gb is XmlSchemaSequence) { RelaxngGroup grp = new RelaxngGroup(); foreach (XmlSchemaParticle xsdc in gb.Items) { grp.Patterns.Add(CreatePatternFromParticle(xsdc)); } return(grp); } if (gb is XmlSchemaChoice) { RelaxngChoice rc = new RelaxngChoice(); foreach (XmlSchemaParticle xsdc in gb.Items) { rc.Patterns.Add(CreatePatternFromParticle(xsdc)); } return(rc); } return(CreateElement((XmlSchemaElement)xsdp)); }
private static void TraverseParticle(XmlSchemaParticle particle, ArrayList elementDeclsInContentModel) { if (particle is XmlSchemaElement) { XmlSchemaElement value = particle as XmlSchemaElement; elementDeclsInContentModel.Add(value); } else if (particle is XmlSchemaGroupBase) { XmlSchemaGroupBase xmlSchemaGroupBase = particle as XmlSchemaGroupBase; XmlSchemaObjectEnumerator enumerator = xmlSchemaGroupBase.Items.GetEnumerator(); try { while (enumerator.MoveNext()) { XmlSchemaParticle particle2 = (XmlSchemaParticle)enumerator.Current; RDLValidatingReader.TraverseParticle(particle2, elementDeclsInContentModel); } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } } else if (particle is XmlSchemaAny) { XmlSchemaAny xmlSchemaAny = particle as XmlSchemaAny; RDLValidatingReader.m_processContent = xmlSchemaAny.ProcessContents; } }
void ExportElementAccessors(XmlSchemaGroupBase group, ElementAccessor[] accessors, bool repeats, bool valueTypeOptional, string ns) { if (accessors.Length == 0) { return; } if (accessors.Length == 1) { ExportElementAccessor(group, accessors[0], repeats, valueTypeOptional, ns); } else { XmlSchemaChoice choice = new XmlSchemaChoice(); choice.MaxOccurs = repeats ? decimal.MaxValue : 1; choice.MinOccurs = repeats ? 0 : 1; for (int i = 0; i < accessors.Length; i++) { ExportElementAccessor(choice, accessors[i], false, valueTypeOptional, ns); } if (choice.Items.Count > 0) { group.Items.Add(choice); } } }
/// <summary> /// Declares 'field' members for a type. /// That is, all fields that apply to this type, either directly or through inheritance. /// </summary> /// <param name="entityType">The type entity.</param> /// <param name="memberGroup">The XSD container that will hold the members.</param> private void AddTypeFields(EffectiveType entityType, XmlSchemaGroupBase memberGroup) { // Example: // <xs:element minOccurs="0" maxOccurs="1" ref="firstName" /> // Define fields applicable to type // This is defining that a given field can appear under a resource of a particular type var fields = from type in _schemaManager.GetAncestors(entityType.Type) from field in _schemaManager.GetDeclaredFields(type) select field; foreach (Entity field in fields) { if (field.Alias == null) { continue; } var fieldElem = new XmlSchemaElement(); fieldElem.RefName = NameUsed(field.Alias.ToQualifiedName()); fieldElem.MaxOccurs = 1; bool required = (_schemaManager.GetBoolFieldValue(field, Aliases2.IsRequired) && _schemaManager.GetStringFieldValue(field, Aliases2.DefaultValue) == null ) || field.Alias == Aliases.Alias; // special case: alias is required in config, but not at runtime fieldElem.MinOccurs = required ? 1 : 0; memberGroup.Items.Add(fieldElem); } }
/// <summary> /// Declares 'field' members for a type. /// That is, all fields that apply to this type, either directly or through inheritance. /// </summary> /// <param name="entityType">The type entity.</param> /// <param name="memberGroup">The XSD container that will hold the members.</param> private void AddRelationshipInstanceMember(EffectiveRelationship entityType, XmlSchemaGroupBase memberGroup, string elementName, Entity targetType, bool required) { // <xs:element name="fields"> // <xs:complexType mixed="true"> // <xs:group minOccurs="0" maxOccurs="unbounded" ref="is_field" /> // </xs:complexType> // </xs:element> XmlSchemaElement elem = new XmlSchemaElement(); elem.MinOccurs = required ? 1 : 0; elem.MaxOccurs = 1; elem.Name = elementName; elem.SchemaType = new XmlSchemaComplexType() { IsMixed = true, Particle = new XmlSchemaGroupRef() { MinOccurs = 0, // zero, since we might refer by alias text MaxOccurs = 1, RefName = targetType.Alias.ToQualifiedName(prefix: "is_") } }; memberGroup.Items.Add(elem); }
void ImportGroupMembers(XmlSchemaParticle particle, CodeIdentifiers members, string ns) { if (particle is XmlSchemaGroupRef) { throw new InvalidOperationException(Res.GetString(Res.XmlSoapUnsupportedGroupRef)); } else if (particle is XmlSchemaGroupBase) { XmlSchemaGroupBase group = (XmlSchemaGroupBase)particle; if (group.IsMultipleOccurrence) { throw new InvalidOperationException(Res.GetString(Res.XmlSoapUnsupportedGroupRepeat)); } for (int i = 0; i < group.Items.Count; i++) { object item = group.Items[i]; if (item is XmlSchemaGroupBase) { throw new InvalidOperationException(Res.GetString(Res.XmlSoapUnsupportedGroupNested)); } else if (item is XmlSchemaElement) { ImportElementMember((XmlSchemaElement)item, members, ns); } else if (item is XmlSchemaAny) { throw new InvalidOperationException(Res.GetString(Res.XmlSoapUnsupportedGroupAny)); } } } }
private void AddEnumElement(XmlSchemaGroupBase schema, string name, Quantumart.QP8.BLL.Field field, bool required) { var values = field.StringEnumItems.Select(itm => itm.Value).ToArray(); var element = new XmlSchemaElement(); var type = new XmlSchemaSimpleType(); var restriction = new XmlSchemaSimpleTypeRestriction(); element.Name = name; element.SchemaType = type; restriction.BaseTypeName = new XmlQualifiedName(StringType, XmlSchema.Namespace); type.Content = restriction; schema.Items.Add(element); if (!required) { element.MinOccurs = 0; element.MaxOccurs = 1; } foreach (var item in field.StringEnumItems) { var option = new XmlSchemaEnumerationFacet(); AddAnnotation(option, item.Alias); option.Value = item.Value; restriction.Facets.Add(option); } }
private void TraverseParticle(object particle) { if (particle is XmlSchemaElement) { XmlSchemaElement elem = particle as XmlSchemaElement; //Logger.Text += elem.Name + '=' + elem.SchemaTypeName + ' '; Logger.Text += elem.Name + '=' + elem.SchemaTypeName.Name + ' '; if (elem.RefName.IsEmpty) { XmlSchemaType type = (XmlSchemaType)elem.ElementSchemaType; XmlSchemaComplexType complexType = type as XmlSchemaComplexType; if (complexType != null && complexType.Name == null) { TraverseParticle(complexType.ContentTypeParticle); } } } else if (particle is XmlSchemaGroupBase) { //xs:all, xs:choice, xs:sequence XmlSchemaGroupBase baseParticle = particle as XmlSchemaGroupBase; foreach (XmlSchemaParticle subParticle in baseParticle.Items) { TraverseParticle(subParticle); } } }
private void ImportGroupMembers(XmlSchemaParticle particle, CodeIdentifiers members, string ns) { XmlQualifiedName parentType = XmlSchemas.GetParentName(particle); if (particle is XmlSchemaGroupRef) { throw new InvalidOperationException(SR.Format(SR.XmlSoapUnsupportedGroupRef, parentType.Name, parentType.Namespace)); } else if (particle is XmlSchemaGroupBase) { XmlSchemaGroupBase group = (XmlSchemaGroupBase)particle; if (group.IsMultipleOccurrence) { throw new InvalidOperationException(SR.Format(SR.XmlSoapUnsupportedGroupRepeat, parentType.Name, parentType.Namespace)); } for (int i = 0; i < group.Items.Count; i++) { object item = group.Items[i]; if (item is XmlSchemaGroupBase || item is XmlSchemaGroupRef) { throw new InvalidOperationException(SR.Format(SR.XmlSoapUnsupportedGroupNested, parentType.Name, parentType.Namespace)); } else if (item is XmlSchemaElement) { ImportElementMember((XmlSchemaElement)item, members, ns); } else if (item is XmlSchemaAny) { throw new InvalidOperationException(SR.Format(SR.XmlSoapUnsupportedGroupAny, parentType.Name, parentType.Namespace)); } } } }
public static bool ContainsName(this XmlSchemaParticle particle, XmlQualifiedName elementName) { XmlSchemaGroupBase groupBase = particle as XmlSchemaGroupBase; if (groupBase != null) { foreach (XmlSchemaParticle p in groupBase.Items) { XmlSchemaElement localElement = p as XmlSchemaElement; if (localElement != null) { if (localElement.QualifiedName == elementName) { return(true); } } else if (p.ContainsName(elementName)) { return(true); } } } return(false); }
XmlSchemaParticle CreateXsdParticleCore() { XmlSchemaParticle p = null; if (ElementName != null) { XmlSchemaElement el = new XmlSchemaElement(); SetLineInfo(el); el.RefName = new XmlQualifiedName(ElementName); return(el); } else if (ChildModels.Count == 0) { return(null); } else { XmlSchemaGroupBase gb = (OrderType == DTDContentOrderType.Seq) ? (XmlSchemaGroupBase) new XmlSchemaSequence() : new XmlSchemaChoice(); SetLineInfo(gb); foreach (DTDContentModel cm in ChildModels.Items) { XmlSchemaParticle c = cm.CreateXsdParticle(); if (c != null) { gb.Items.Add(c); } } p = gb; } return(p); }
void TraverseGroupBase(XmlSchemaGroupBase GroupBase, int level, I_PSMHasChildren Current, P_PSMDiagram diagram) { Print(GroupBaseName(GroupBase) + " Subitems: " + GroupBase.Items.Count + Environment.NewLine, level); if (GroupBase is XmlSchemaSequence) { P_PSMDummy D = new P_PSMDummy(); D.Parent = Current; Current.Children.Add(D); foreach (XmlSchemaParticle subParticle in GroupBase.Items) { //TODO: Vyresit sequence v choice TraverseParticle(subParticle, level + 1, D, diagram); } } else if (GroupBase is XmlSchemaChoice) { P_PSMContentChoice CC = new P_PSMContentChoice(); Current.Children.Add(CC); CC.Parent = Current; foreach (XmlSchemaParticle subParticle in GroupBase.Items) { TraverseParticle(subParticle, level + 1, CC, diagram); } } else { foreach (XmlSchemaParticle subParticle in GroupBase.Items) { TraverseParticle(subParticle, level + 1, Current, diagram); } } }
private void ExportElementAccessors(XmlSchemaGroupBase group, ElementAccessor[] accessors, bool repeats, bool valueTypeOptional, string ns) { if (accessors.Length != 0) { if (accessors.Length == 1) { this.ExportElementAccessor(group, accessors[0], repeats, valueTypeOptional, ns); } else { XmlSchemaChoice choice = new XmlSchemaChoice { MaxOccurs = repeats ? 79228162514264337593543950335M : 1M, MinOccurs = repeats ? 0 : 1 }; for (int i = 0; i < accessors.Length; i++) { this.ExportElementAccessor(choice, accessors[i], false, valueTypeOptional, ns); } if (choice.Items.Count > 0) { group.Items.Add(choice); } } } }
public static void ReplaceThisWith(this XmlSchemaElement that, XmlSchemaElement with) { XmlSchemaGroupBase gr = that.Parent as XmlSchemaGroupBase; int idx = gr.Items.IndexOf(that); gr.Items.Insert(idx, with); gr.Items.Remove(that); }
private DataSchemaNode MakeSchemaElement(XmlSchemaElement element) { string typeName = (string)null; Type type = (Type)null; if (element.ElementSchemaType != null && element.ElementSchemaType.Datatype != null) { type = element.ElementSchemaType.Datatype.ValueType; } else if (element.SchemaTypeName != (XmlQualifiedName)null && element.SchemaTypeName.Name != string.Empty) { typeName = element.SchemaTypeName.Name; } if (type != (Type)null) { type = this.ConvertType(type); typeName = type.Name; } string str = this.ProcessQualifiedName(element.QualifiedName); SchemaNodeTypes nodeType = element.MaxOccurs > new Decimal(1) ? SchemaNodeTypes.Collection : SchemaNodeTypes.Property; DataSchemaNode schemaNode = new DataSchemaNode(str, str, nodeType, typeName, type, (IDataSchemaNodeDelayLoader)null); XmlSchemaComplexType schemaComplexType = element.ElementSchemaType as XmlSchemaComplexType; if (schemaComplexType != null) { XmlSchemaObjectCollection objectCollection = (XmlSchemaObjectCollection)null; if (schemaComplexType.Attributes.Count > 0) { objectCollection = schemaComplexType.Attributes; } else { XmlSchemaSimpleContent schemaSimpleContent = schemaComplexType.ContentModel as XmlSchemaSimpleContent; if (schemaSimpleContent != null) { XmlSchemaSimpleContentExtension contentExtension = schemaSimpleContent.Content as XmlSchemaSimpleContentExtension; if (contentExtension != null) { objectCollection = contentExtension.Attributes; } } } if (objectCollection != null) { foreach (XmlSchemaAttribute attribute in objectCollection) { DataSchemaNode child = this.MakeSchemaAttribute(attribute); schemaNode.AddChild(child); } } XmlSchemaGroupBase xmlSchemaGroupBase = schemaComplexType.Particle as XmlSchemaGroupBase; if (xmlSchemaGroupBase != null) { this.ProcessSchemaItems(schemaNode, xmlSchemaGroupBase.Items); } } return(schemaNode); }
private bool LoadXmlSchemaGroupBase(XmlSchemaGroupBase groupBase) { if (groupBase == null) { return(false); } LoadXmlSchemaObjectCollection(groupBase.Items); return(true); }
private XSModelGroup() { _compositor = XSCompositor.Sequence; _group = new XmlSchemaSequence(); Components = new XSComponentFixedList(); Particles = new XSComponentList(); Particles.Inserted += Particles_Inserted; Particles.Cleared += Particles_Cleared; }
void ExportElementAccessor(XmlSchemaGroupBase group, ElementAccessor accessor, bool repeats, string ns) { XmlSchemaElement element = new XmlSchemaElement(); element.MinOccurs = repeats ? 0 : 1; element.MaxOccurs = repeats ? decimal.MaxValue : 1; element.Name = accessor.Name; element.SchemaTypeName = ExportTypeMapping((TypeMapping)accessor.Mapping, accessor.Namespace); group.Items.Add(element); }
public IEnumerable <Particle> GetElements(XmlSchemaGroupBase groupBase) { foreach (var item in groupBase.Items) { foreach (var element in GetElements(item)) { element.MaxOccurs = Math.Max(element.MaxOccurs, groupBase.MaxOccurs); element.MinOccurs = Math.Min(element.MinOccurs, groupBase.MinOccurs); yield return(element); } } }
static void WriteSequence(this SimpleClassFormatter formatter, XmlSchemaGroupBase sequence, CommandLineOptions options, Queue <XmlSchema> schemas, HashSet <XmlSchema> processedSchemas) { // Parse schema elements foreach (XmlSchemaElement sequenceItem in sequence.Items.OfType <XmlSchemaElement>().Where(p => p.ElementSchemaType != null)) { formatter.WriteMember(sequenceItem, options, schemas, processedSchemas); } foreach (XmlSchemaGroupBase item in sequence.Items.OfType <XmlSchemaGroupBase>()) { formatter.WriteSequence(item, options, schemas, processedSchemas); } }
private void ExportElementAccessor(XmlSchemaGroupBase group, ElementAccessor accessor, bool repeats, bool valueTypeOptional, string ns) { XmlSchemaElement item = new XmlSchemaElement { MinOccurs = (repeats || valueTypeOptional) ? 0 : 1, MaxOccurs = repeats ? 79228162514264337593543950335M : 1M, Name = accessor.Name, IsNillable = accessor.IsNullable || (accessor.Mapping is NullableMapping), Form = XmlSchemaForm.Unqualified, SchemaTypeName = this.ExportTypeMapping(accessor.Mapping, accessor.Namespace) }; group.Items.Add(item); }
void ExportElementAccessor(XmlSchemaGroupBase group, ElementAccessor accessor, bool repeats, bool valueTypeOptional, string ns) { XmlSchemaElement element = new XmlSchemaElement(); element.MinOccurs = repeats || valueTypeOptional ? 0 : 1; element.MaxOccurs = repeats ? decimal.MaxValue : 1; element.Name = accessor.Name; element.IsNillable = accessor.IsNullable || accessor.Mapping is NullableMapping; element.Form = XmlSchemaForm.Unqualified; element.SchemaTypeName = ExportTypeMapping(accessor.Mapping, accessor.Namespace); group.Items.Add(element); }
private void UpdateRegionsTags(XmlSchemaGroupBase schema) { var regionsTags = AddSequence(schema, "RegionsTags", false); var tag = AddElement(regionsTags, "Tag", true, true); AddElement(tag, "Title", StringType); var regionsValues = AddSequence(tag, "RegionsValues", true); var regionsValue = AddElement(regionsValues, "RegionsValue", true, true); AddElement(regionsValue, "Value", StringType, true); var regions = AddSequence(regionsValue, "Regions", true); AddElement(regions, "Region", IntegerType, true, true); }
public void DumpGroupBase (XmlSchemaGroupBase gb) { depth++; IndentLine ("**GroupBase**"); IndentLine ("Type: " + gb); IndentLine ("MinOccurs: " + gb.MinOccurs); IndentLine ("MaxOccurs: " + gb.MaxOccurs); IndentLine ("Items: "); foreach (XmlSchemaParticle p in gb.Items) DumpParticle (p); depth--; }