Ejemplo n.º 1
0
 private XmlSchemaChoice GetSubstitutionChoice(XmlSchemaElement element)
 {
     if (substitutionGroupsTable == null)
     {
         BuildSubstitutionGroups();
     }
     if (substitutionGroupsTable != null)
     {
         SubstitutionGroupWrapper substitutionGroup = (SubstitutionGroupWrapper)substitutionGroupsTable[element.QualifiedName];
         if (substitutionGroup != null)   //Element is head of a substitutionGroup
         {
             XmlSchemaChoice choice = new XmlSchemaChoice();
             foreach (XmlSchemaElement elem in substitutionGroup.Members)
             {
                 choice.Items.Add(elem);
             }
             XmlSchemaElement headElement = (XmlSchemaElement)schemaSet.GlobalElements[element.QualifiedName];
             if (headElement.IsAbstract)   //Should not generate the abstract element
             {
                 choice.Items.Remove(headElement);
             }
             choice.MinOccurs = element.MinOccurs;
             choice.MaxOccurs = element.MaxOccurs;
             return(choice);
         }
     }
     return(null);
 }
Ejemplo n.º 2
0
 private void BuildSubstitutionGroups()
 {
     foreach (XmlSchemaElement element in schemaSet.GlobalElements.Values)
     {
         XmlQualifiedName head = element.SubstitutionGroup;
         if (!head.IsEmpty)
         {
             if (substitutionGroupsTable == null)
             {
                 substitutionGroupsTable = new Hashtable();
             }
             SubstitutionGroupWrapper substitutionGroup = (SubstitutionGroupWrapper)substitutionGroupsTable[head];
             if (substitutionGroup == null)
             {
                 substitutionGroup      = new SubstitutionGroupWrapper();
                 substitutionGroup.Head = head;
                 substitutionGroupsTable.Add(head, substitutionGroup);
             }
             ArrayList members = substitutionGroup.Members;
             if (!members.Contains(element))   //Members might contain element if the same schema is included and imported through different paths. Imp, hence will be added to set directly
             {
                 members.Add(element);
             }
         }
     }
     if (substitutionGroupsTable != null)   //There were subst grps in the schema
     {
         foreach (SubstitutionGroupWrapper substGroup in substitutionGroupsTable.Values)
         {
             ResolveSubstitutionGroup(substGroup);
         }
     }
 }
Ejemplo n.º 3
0
        private void ResolveSubstitutionGroup(SubstitutionGroupWrapper substitutionGroup)
        {
            ArrayList        newMembers  = null;
            XmlSchemaElement headElement = (XmlSchemaElement)schemaSet.GlobalElements[substitutionGroup.Head];

            if (substitutionGroup.Members.Contains(headElement))  // already checked
            {
                return;
            }
            foreach (XmlSchemaElement element in substitutionGroup.Members)
            {
                //Chain to other head's that are members of this head's substGroup
                SubstitutionGroupWrapper g = (SubstitutionGroupWrapper)substitutionGroupsTable[element.QualifiedName];
                if (g != null)
                {
                    ResolveSubstitutionGroup(g);
                    foreach (XmlSchemaElement element1 in g.Members)
                    {
                        if (element1 != element)   //Exclude the head
                        {
                            if (newMembers == null)
                            {
                                newMembers = new ArrayList();
                            }
                            newMembers.Add(element1);
                        }
                    }
                }
            }
            if (newMembers != null)
            {
                foreach (XmlSchemaElement newMember in newMembers)
                {
                    substitutionGroup.Members.Add(newMember);
                }
            }
            substitutionGroup.Members.Add(headElement);
        }
Ejemplo n.º 4
0
 private void ResolveSubstitutionGroup(SubstitutionGroupWrapper substitutionGroup)
 {
     ArrayList newMembers = null;
     XmlSchemaElement headElement = (XmlSchemaElement)schemaSet.GlobalElements[substitutionGroup.Head];
     if (substitutionGroup.Members.Contains(headElement)) {// already checked
         return;
     }
     foreach (XmlSchemaElement element in substitutionGroup.Members) {
         //Chain to other head's that are members of this head's substGroup
         SubstitutionGroupWrapper g = (SubstitutionGroupWrapper)substitutionGroupsTable[element.QualifiedName];
         if (g != null) {
             ResolveSubstitutionGroup(g);
             foreach (XmlSchemaElement element1 in g.Members) {
                 if (element1 != element) { //Exclude the head
                     if (newMembers == null) {
                         newMembers = new ArrayList();
                     }
                     newMembers.Add(element1);
                 }
             }
         }
     }
     if (newMembers != null) {
         foreach (XmlSchemaElement newMember in newMembers) {
             substitutionGroup.Members.Add(newMember);
         }
     }
     substitutionGroup.Members.Add(headElement);
 }
Ejemplo n.º 5
0
 private void BuildSubstitutionGroups()
 {
     foreach (XmlSchemaElement element in schemaSet.GlobalElements.Values) {
         XmlQualifiedName head = element.SubstitutionGroup;
         if (!head.IsEmpty) {
             if (substitutionGroupsTable == null) {
                 substitutionGroupsTable = new Hashtable();
             }
             SubstitutionGroupWrapper substitutionGroup = (SubstitutionGroupWrapper)substitutionGroupsTable[head];
             if (substitutionGroup == null) {
                 substitutionGroup = new SubstitutionGroupWrapper();
                 substitutionGroup.Head = head;
                 substitutionGroupsTable.Add(head, substitutionGroup);
             }
             ArrayList members = substitutionGroup.Members;
             if (!members.Contains(element)) { //Members might contain element if the same schema is included and imported through different paths. Imp, hence will be added to set directly
                 members.Add(element);
             }
         }
     }
     if (substitutionGroupsTable != null) { //There were subst grps in the schema
         foreach(SubstitutionGroupWrapper substGroup in substitutionGroupsTable.Values) {
             ResolveSubstitutionGroup(substGroup);
         }
     }
 }