示例#1
0
        /// <summary>
        /// Register an XS:Choice
        /// </summary>
        /// <param name="c">The XS:Choice to register</param>
        protected void RegisterChoice(System.Xml.Schema.XmlSchemaChoice c)
        {
            XmlSchemaChoice chce = new XmlSchemaChoice(Schema, this);

            chce.Load(c);
            content = chce;
        }
示例#2
0
        /// <summary>
        /// Load this schema choice from the .net schema choice
        /// </summary>
        public void Load(System.Xml.Schema.XmlSchemaChoice c)
        {
            // Iterate through all
            foreach (System.Xml.Schema.XmlSchemaObject o in c.Items)
            {
                if (o is System.Xml.Schema.XmlSchemaElement)
                {
                    RegisterElement(o as System.Xml.Schema.XmlSchemaElement);
                }
                else if (o is System.Xml.Schema.XmlSchemaChoice)
                {
                    RegisterChoice(o as System.Xml.Schema.XmlSchemaChoice);
                }
                else if (o is System.Xml.Schema.XmlSchemaSequence)
                {
                    RegisterSequence(o as System.Xml.Schema.XmlSchemaSequence);
                }
                else if (o is System.Xml.Schema.XmlSchemaAny)
                {
                    RegisterAny(o as System.Xml.Schema.XmlSchemaAny);
                }
            }

            this.MinOccurs = c.MinOccursString;
            this.MaxOccurs = c.MaxOccursString;
        }
示例#3
0
        /// <summary>
        /// Register a choice
        /// </summary>
        /// <param name="c"></param>
        protected void RegisterChoice(System.Xml.Schema.XmlSchemaChoice c)
        {
            if (content == null)
            {
                content = new List <XmlSchemaObject>();
            }

            XmlSchemaChoice chce = new XmlSchemaChoice(Schema, this);

            chce.Load(c);
            content.Add(chce);
        }
        /// <summary>
        /// Register a choice
        /// </summary>
        /// <param name="c"></param>
        protected void RegisterChoice(System.Xml.Schema.XmlSchemaChoice c)
        {
            if (content == null)
            {
                content = new List <XmlSchemaObject>();
            }

            XmlSchemaChoice chce = new XmlSchemaChoice(Schema, this);

            chce.Load(c);

            // If the choice only has one element, get rid of the choice
            if (chce.Content.Count == 1)
            {
                content.Add(chce.Content[0]);
            }
            else
            {
                content.Add(chce);
            }
        }
 /// <summary> Convert the elements in the Collection to an ArrayList </summary>
 public static System.Collections.ArrayList GetElements(System.Xml.Schema.XmlSchemaObjectCollection seqItems, System.Xml.Schema.XmlSchemaObjectCollection schemaItems)
 {
     System.Collections.ArrayList elements = new System.Collections.ArrayList();
     foreach (System.Xml.Schema.XmlSchemaObject obj in seqItems)
     {
         if (obj is System.Xml.Schema.XmlSchemaElement)
         {
             elements.Add(obj);
         }
         else if (obj is System.Xml.Schema.XmlSchemaChoice)
         {
             System.Xml.Schema.XmlSchemaChoice choice = obj as System.Xml.Schema.XmlSchemaChoice;
             // Add each element of the choice
             foreach (System.Xml.Schema.XmlSchemaObject item in choice.Items)
             {
                 if (item is System.Xml.Schema.XmlSchemaElement)
                 {
                     elements.Add(item);
                 }
                 else if (item is System.Xml.Schema.XmlSchemaGroupRef)
                 {
                     // Find the Group
                     string groupName = (obj as System.Xml.Schema.XmlSchemaGroupRef).RefName.Name;
                     System.Xml.Schema.XmlSchemaGroup group = null;
                     foreach (System.Xml.Schema.XmlSchemaObject schemaItem in schemaItems)
                     {
                         if (schemaItem is System.Xml.Schema.XmlSchemaGroup && groupName == (schemaItem as System.Xml.Schema.XmlSchemaGroup).Name)
                         {
                             group = schemaItem as System.Xml.Schema.XmlSchemaGroup;                                     // Found
                             break;
                         }
                     }
                     if (group == null)                          // Not found
                     {
                         throw new System.Exception("Unknown xs:group " + groupName + string.Format(", nh-mapping.xsd({0})", obj.LineNumber));
                     }
                     elements.AddRange(GetElements(group.Particle.Items, schemaItems));
                 }
                 else if (item is System.Xml.Schema.XmlSchemaSequence)
                 {
                     System.Xml.Schema.XmlSchemaSequence subSeq = item as System.Xml.Schema.XmlSchemaSequence;
                     elements.AddRange(GetElements(subSeq.Items, schemaItems));
                 }
                 else
                 {
                     log.Warn("Unknown Object: " + item.ToString() + string.Format(", nh-mapping.xsd({0})", item.LineNumber));
                 }
             }
         }
         else if (obj is System.Xml.Schema.XmlSchemaGroupRef)
         {
             // Find the Group
             string groupName = (obj as System.Xml.Schema.XmlSchemaGroupRef).RefName.Name;
             System.Xml.Schema.XmlSchemaGroup group = null;
             foreach (System.Xml.Schema.XmlSchemaObject schemaItem in schemaItems)
             {
                 if (schemaItem is System.Xml.Schema.XmlSchemaGroup && groupName == (schemaItem as System.Xml.Schema.XmlSchemaGroup).Name)
                 {
                     group = schemaItem as System.Xml.Schema.XmlSchemaGroup;                             // Found
                     break;
                 }
             }
             if (group == null)                  // Not found
             {
                 throw new System.Exception("Unknown xs:group " + groupName + string.Format(", nh-mapping.xsd({0})", obj.LineNumber));
             }
             elements.AddRange(GetElements(group.Particle.Items, schemaItems));
         }
         else if (obj is System.Xml.Schema.XmlSchemaSequence)
         {
             System.Xml.Schema.XmlSchemaSequence subSeq = obj as System.Xml.Schema.XmlSchemaSequence;
             elements.AddRange(GetElements(subSeq.Items, schemaItems));
         }
         else
         {
             log.Warn("Unknown Object: " + obj.ToString() + string.Format(", nh-mapping.xsd({0})", obj.LineNumber));
         }
     }
     return(elements);
 }