Example #1
0
 private void BuildSubstitutionGroups()
 {
     foreach (XmlSchemaElement element in schemaSet.GlobalElements.Values)
     {
         var head = element.SubstitutionGroup;
         if (!head.IsEmpty)
         {
             if (substitutionGroupsTable == null)
             {
                 substitutionGroupsTable = new Hashtable();
             }
             var substitutionGroup = (SubstitutionGroupWrapper)substitutionGroupsTable[head];
             if (substitutionGroup == null)
             {
                 substitutionGroup      = new SubstitutionGroupWrapper();
                 substitutionGroup.Head = head;
                 substitutionGroupsTable.Add(head, substitutionGroup);
             }
             var 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);
         }
     }
 }
Example #2
0
        private void ResolveSubstitutionGroup(SubstitutionGroupWrapper substitutionGroup)
        {
            ArrayList newMembers  = null;
            var       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
                var 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);
        }
Example #3
0
 private void ResolveSubstitutionGroup(SubstitutionGroupWrapper substitutionGroup)
 {
     ArrayList newMembers = null;
     var 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
         var 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);
 }
Example #4
0
 private void BuildSubstitutionGroups()
 {
     foreach ( XmlSchemaElement element in schemaSet.GlobalElements.Values )
     {
         var head = element.SubstitutionGroup;
         if ( !head.IsEmpty )
         {
             if ( substitutionGroupsTable == null )
             {
                 substitutionGroupsTable = new Hashtable();
             }
             var substitutionGroup = (SubstitutionGroupWrapper)substitutionGroupsTable[head];
             if ( substitutionGroup == null )
             {
                 substitutionGroup = new SubstitutionGroupWrapper();
                 substitutionGroup.Head = head;
                 substitutionGroupsTable.Add(head, substitutionGroup);
             }
             var 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);
         }
     }
 }