Exemplo n.º 1
0
    } //WriteXmlSchemaSimpleType()

    //XmlSchemaParticle
    public static void WriteXmlSchemaParticle(XmlSchemaParticle particle,
                                              XmlSchema myXmlSchema,
                                              XmlTextWriter myXmlTextWriter)
    {
        if (particle is XmlSchemaElement)
        {
            WriteXmlSchemaElement((XmlSchemaElement)particle, myXmlSchema, myXmlTextWriter);
        } //if
        else if (particle is XmlSchemaSequence)
        {
            myXmlTextWriter.WriteStartElement("sequence", XmlSchema.Namespace);
            foreach (XmlSchemaParticle particle1 in ((XmlSchemaSequence)particle).Items)
            {
                WriteXmlSchemaParticle(particle1, myXmlSchema, myXmlTextWriter);
            }

            myXmlTextWriter.WriteEndElement();
        } //else if
        else if (particle is XmlSchemaGroupRef)
        {
            XmlSchemaGroupRef xsgr  = (XmlSchemaGroupRef)particle;
            XmlSchemaGroup    group = (XmlSchemaGroup)myXmlSchema.Groups[xsgr.RefName];
            WriteXmlSchemaGroup(group, myXmlSchema, myXmlTextWriter, xsgr.RefName.Name);
        } //else if
        else
        {
            Console.WriteLine("Not Implemented for this type: {0}", particle.ToString());
        } //else
    }     //WriteXmlSchemaParticle()
Exemplo n.º 2
0
        protected override void Visit(XmlSchemaGroupRef groupRef)
        {
            var group = _schemaSet.ResolveGroup(groupRef);

            AddParent(group);
            Traverse(group);
        }
Exemplo n.º 3
0
 private void GenerateParticleField(XmlSchemaParticle particle)
 {
     if (particle is XmlSchemaAny)
     {
         GenerateParticleAnyField(particle
                                  as XmlSchemaAny);
     }
     else if (particle is XmlSchemaElement)
     {
         GenerateElementField(particle
                              as XmlSchemaElement);
     }
     else if (particle is XmlSchemaAll)
     {
         GenerateParticleAllField(particle
                                  as XmlSchemaAll);
     }
     else if (particle is XmlSchemaChoice)
     {
         GenerateParticleChoiceField(particle
                                     as XmlSchemaChoice);
     }
     else if (particle is XmlSchemaSequence)
     {
         GenerateParticleSequenceField(particle
                                       as XmlSchemaSequence);
     }
     else if (particle is XmlSchemaGroupRef)
     {
         XmlSchemaGroupRef gRef = particle
                                  as XmlSchemaGroupRef;
         GenerateGroupField(FindGroup(gRef.RefName));
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Parses xs:group ref="..." elements in the schema
 /// </summary>
 /// <param name="groupRef"></param>
 /// <returns></returns>
 private RecursiveChildren ParseGoupRef(XmlSchemaGroupRef groupRef)
 {
     log.WriteLine("Parsing groupRef {0}", groupRef.RefName);
     using (log.Indent())
     {
         return(ParseGroupBase(groupRef.Particle));
     }
 }
        public void IterateThrough(XmlSchemaGroupRef obj)
        {
            if (_functionalVisitor.StartProcessing(obj))
            {
                var group = XmlSchemaExtensions.GetGroup(_schemaSet, obj.RefName);

                @group?.Accept(this);
            }

            _functionalVisitor.EndProcessing(obj);
        }
Exemplo n.º 6
0
        protected override void Visit(XmlSchemaGroupRef groupRef)
        {
            if (groupRef.MaxOccurs == 0)
            {
                return;
            }

            var group = _schemaSetManager.SchemaSet.ResolveGroup(groupRef);

            Traverse(group.Particle);
        }
Exemplo n.º 7
0
        public static XmlSchemaGroup ResolveGroup(this XmlSchemaSet schemaSet, XmlSchemaGroupRef groupRef)
        {
            foreach (var schema in schemaSet.GetAllSchemas())
            {
                var group = (XmlSchemaGroup)schema.Groups[groupRef.RefName];
                if (group != null)
                {
                    return(group);
                }
            }

            return(null);
        }
        /// <summary>Determines whether the specified <paramref name="element"/> is expected.</summary>
        /// <param name="element">Element to check.</param>
        /// <param name="elementName">
        /// <see cref="XmlQualifiedName"/> of the <paramref name="element"/> (passed to avoid recreation).
        /// </param>
        /// <param name="expected">Expected schema particle.</param>
        /// <returns>true if the element is expected; false otherwise.</returns>
        private static bool IsElementExpected(XElement element, XmlQualifiedName elementName, XmlSchemaParticle expected)
        {
            Debug.Assert(element != null, "element != null");
            Debug.Assert(elementName != null, "elementName != null");
            Debug.Assert(expected != null, "expected != null");
            Debug.Assert(
                ToQualifiedName(element.Name) == elementName,
                "ToQualifiedName(element.Name) == elementName -- otherwise the caller get the 'caching' wrong");

            // These are all possibilities for a particle.
            XmlSchemaGroupRef schemaGroupRef = expected as XmlSchemaGroupRef;
            XmlSchemaAny      schemaAny      = expected as XmlSchemaAny;
            XmlSchemaElement  schemaElement  = expected as XmlSchemaElement;
            XmlSchemaAll      schemaAll      = expected as XmlSchemaAll;
            XmlSchemaChoice   schemaChoice   = expected as XmlSchemaChoice;
            XmlSchemaSequence schemaSequence = expected as XmlSchemaSequence;

            Debug.Assert(schemaGroupRef == null, "schemaGroupRef == null -- the validator flattens this out as options.");
            Debug.Assert(schemaSequence == null, "schemaSequence == null -- the validator flattens this out and picks the right one in seq.");
            Debug.Assert(schemaAll == null, "schemaAll == null -- the validator flattens this out as options.");
            Debug.Assert(schemaChoice == null, "schemaChoice == null -- the validator flattens this out as options.");

            if (schemaAny != null)
            {
                Debug.Assert(
                    schemaAny.Namespace == "##other" || schemaAny.Namespace == "##any",
                    "schemaAny.Namespace == '##other' || '##any' -- otherwise CSDL XSD resource was changed");
                if (schemaAny.Namespace == "##any")
                {
                    return(true);
                }
                else if (schemaAny.Namespace == "##other")
                {
                    string realElementNamespace = element.Name.NamespaceName;
                    if (realElementNamespace != GetTargetNamespace(expected))
                    {
                        return(true);
                    }
                }
            }

            if (schemaElement != null)
            {
                if (schemaElement.QualifiedName == elementName)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 9
0
        internal XSModelGroupDefinition(XmlSchemaGroupRef xmlGroupRef)
        {
            _group = xmlGroupRef;

            if (_group.Annotation is XmlSchemaAnnotation annotation)
            {
                _annotation = XMLSchemaSerializer.CreateXSAnnotation(annotation);
                _annotation.BindToContainer(RootContainer, this);
            }

            if (xmlGroupRef.RefName is XmlQualifiedName qualifiedName)
            {
                _reference = XMLSchemaSerializer.CreateXMLExpandedName(qualifiedName);
            }
        }
Exemplo n.º 10
0
 private void Write55_XmlSchemaGroupRef(XmlSchemaGroupRef o)
 {
     if (o != null)
     {
         this.WriteStartElement("group");
         this.WriteAttribute("id", "", o.Id);
         this.WriteAttribute("minOccurs", "", XmlConvert.ToString(o.MinOccurs));
         this.WriteAttribute("maxOccurs", "", (o.MaxOccurs == 79228162514264337593543950335M) ? "unbounded" : XmlConvert.ToString(o.MaxOccurs));
         if (!o.RefName.IsEmpty)
         {
             this.WriteAttribute("ref", "", o.RefName);
         }
         this.WriteAttributes(o.UnhandledAttributes, o);
         this.Write5_XmlSchemaAnnotation(o.Annotation);
         this.WriteEndElement();
     }
 }
Exemplo n.º 11
0
        void Write55_XmlSchemaGroupRef(XmlSchemaGroupRef o)
        {
            if ((object)o == null)
            {
                return;
            }
            WriteStartElement("group");

            WriteAttribute(@"id", @"", ((System.String)o.@Id));
            WriteAttribute("minOccurs", "", XmlConvert.ToString(o.MinOccurs));
            WriteAttribute(@"maxOccurs", @"", o.MaxOccurs == decimal.MaxValue ? "unbounded" : XmlConvert.ToString(o.MaxOccurs));

            if (!o.RefName.IsEmpty)
            {
                WriteAttribute("ref", "", o.RefName);
            }
            WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);
            Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
            WriteEndElement();
        }
Exemplo n.º 12
0
        void CollectSubElements(XmlSchemaParticle particle)
        {
            // choice | sequence
            XmlSchemaGroupBase sgb = particle as XmlSchemaGroupBase;

            if (sgb != null)
            {
                foreach (XmlSchemaObject xso in sgb.Items)
                {
                    XmlSchemaElement xse = xso as XmlSchemaElement;
                    if (xse != null)
                    {
                        // If it's a ref, xse.QualifiedName.Name is the name of the element
                        ElementWrapper elw = new ElementWrapper(xse, false);
                        if (elw.IsComplexType)
                        {
                            Add(this.complexSubElements, xse);
                        }
                        else
                        {
                            Add(this.simpleSubElements, xse);
                        }

                        continue;
                    }
                    XmlSchemaParticle subParticle = xso as XmlSchemaParticle;
                    if (subParticle != null)
                    {
                        CollectSubElements(subParticle);
                        continue;
                    }
                }
            }
            // group
            XmlSchemaGroupRef groupRef = particle as XmlSchemaGroupRef;

            if (groupRef != null)
            {
                CollectSubElements(groupRef.Particle);
            }
        }
Exemplo n.º 13
0
    } //WriteExampleAttribute()

    // Write example particles
    public static void WriteExampleParticle(XmlSchemaParticle particle,
                                            XmlSchema myXmlSchema,
                                            XmlTextWriter myXmlTextWriter)
    {
        Decimal max;

        if (particle.MaxOccurs == -1 || particle.MaxOccurs > 10000)
        {
            max = 5;
        } //if
        else
        {
            max = particle.MaxOccurs;
        } //else

        for (int i = 0; i < max; i++)
        {
            if (particle is XmlSchemaElement)
            {
                WriteExampleElement((XmlSchemaElement)particle, myXmlSchema, myXmlTextWriter);
            } //if
            else if (particle is XmlSchemaSequence)
            {
                foreach (XmlSchemaParticle particle1 in ((XmlSchemaSequence)particle).Items)
                {
                    WriteExampleParticle(particle1, myXmlSchema, myXmlTextWriter);
                }
            } //else if
            else if (particle is XmlSchemaGroupRef)
            {
                XmlSchemaGroupRef xsgr  = (XmlSchemaGroupRef)particle;
                XmlSchemaGroup    group = (XmlSchemaGroup)myXmlSchema.Groups[xsgr.RefName];
                WriteExampleParticle(group.Particle, myXmlSchema, myXmlTextWriter);
            } //else if
            else
            {
                Console.WriteLine("Not Implemented for this type: {0}", particle.ToString());
            } //else
        }     //for
    }         //WriteExampleParticle()
        void GetChildElementCompletionData(XmlCompletionDataList data, XmlSchemaGroupRef groupRef, string prefix)
        {
            var group = FindGroup(groupRef.RefName.Name);

            if (group == null)
            {
                return;
            }
            var sequence = group.Particle as XmlSchemaSequence;

            if (sequence != null)
            {
                GetChildElementCompletionData(data, sequence.Items, prefix);
                return;
            }
            var choice = group.Particle as XmlSchemaChoice;

            if (choice != null)
            {
                GetChildElementCompletionData(data, choice.Items, prefix);
                return;
            }
        }
        XmlSchemaElement FindElement(XmlSchemaGroupRef groupRef, QualifiedName name)
        {
            var group = FindGroup(groupRef.RefName.Name);

            if (group == null)
            {
                return(null);
            }

            var sequence = group.Particle as XmlSchemaSequence;

            if (sequence != null)
            {
                return(FindElement(sequence.Items, name));
            }
            var choice = group.Particle as XmlSchemaChoice;

            if (choice != null)
            {
                return(FindElement(choice.Items, name));
            }

            return(null);
        }
Exemplo n.º 16
0
 private bool LoadXmlSchemaGroupRef(XmlSchemaGroupRef groupRef)
 {
     if (groupRef == null)
     {
         return(false);
     }
     if (groupRef.RefName != null)
     {
         XmlSchemaParticle part      = null;
         string            groupName = groupRef.RefName.Name;
         if (xcontoler._complexTypes.ContainsKey(groupName))
         {
             XmlSchemaComplexType cct = xcontoler._complexTypes[groupName];
             part = cct.Particle;
         }
         else if (xcontoler._groups.ContainsKey(groupName))
         {
             XmlSchemaGroup group = xcontoler._groups[groupName];
             part = group.Particle;
         }
         LoadXmlSchemaObject(part);
     }
     return(true);
 }
Exemplo n.º 17
0
        internal void Depends(XmlSchemaObject item, ArrayList refs)
        {
            if (item == null || scope[item] != null)
            {
                return;
            }

            Type t = item.GetType();

            if (typeof(XmlSchemaType).IsAssignableFrom(t))
            {
                XmlQualifiedName          baseName   = XmlQualifiedName.Empty;
                XmlSchemaType             baseType   = null;
                XmlSchemaParticle         particle   = null;
                XmlSchemaObjectCollection attributes = null;

                if (item is XmlSchemaComplexType)
                {
                    XmlSchemaComplexType ct = (XmlSchemaComplexType)item;
                    if (ct.ContentModel != null)
                    {
                        XmlSchemaContent content = ct.ContentModel.Content;
                        if (content is XmlSchemaComplexContentRestriction)
                        {
                            baseName   = ((XmlSchemaComplexContentRestriction)content).BaseTypeName;
                            attributes = ((XmlSchemaComplexContentRestriction)content).Attributes;
                        }
                        else if (content is XmlSchemaSimpleContentRestriction)
                        {
                            XmlSchemaSimpleContentRestriction restriction = (XmlSchemaSimpleContentRestriction)content;
                            if (restriction.BaseType != null)
                            {
                                baseType = restriction.BaseType;
                            }
                            else
                            {
                                baseName = restriction.BaseTypeName;
                            }
                            attributes = restriction.Attributes;
                        }
                        else if (content is XmlSchemaComplexContentExtension)
                        {
                            XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension)content;
                            attributes = extension.Attributes;
                            particle   = extension.Particle;
                            baseName   = extension.BaseTypeName;
                        }
                        else if (content is XmlSchemaSimpleContentExtension)
                        {
                            XmlSchemaSimpleContentExtension extension = (XmlSchemaSimpleContentExtension)content;
                            attributes = extension.Attributes;
                            baseName   = extension.BaseTypeName;
                        }
                    }
                    else
                    {
                        attributes = ct.Attributes;
                        particle   = ct.Particle;
                    }
                    if (particle is XmlSchemaGroupRef)
                    {
                        XmlSchemaGroupRef refGroup = (XmlSchemaGroupRef)particle;
                        particle = ((XmlSchemaGroup)schemas.Find(refGroup.RefName, typeof(XmlSchemaGroup), false)).Particle;
                    }
                    else if (particle is XmlSchemaGroupBase)
                    {
                        particle = (XmlSchemaGroupBase)particle;
                    }
                }
                else if (item is XmlSchemaSimpleType)
                {
                    XmlSchemaSimpleType        simpleType = (XmlSchemaSimpleType)item;
                    XmlSchemaSimpleTypeContent content    = simpleType.Content;
                    if (content is XmlSchemaSimpleTypeRestriction)
                    {
                        baseType = ((XmlSchemaSimpleTypeRestriction)content).BaseType;
                        baseName = ((XmlSchemaSimpleTypeRestriction)content).BaseTypeName;
                    }
                    else if (content is XmlSchemaSimpleTypeList)
                    {
                        XmlSchemaSimpleTypeList list = (XmlSchemaSimpleTypeList)content;
                        if (list.ItemTypeName != null && !list.ItemTypeName.IsEmpty)
                        {
                            baseName = list.ItemTypeName;
                        }
                        if (list.ItemType != null)
                        {
                            baseType = list.ItemType;
                        }
                    }
                    else if (content is XmlSchemaSimpleTypeRestriction)
                    {
                        baseName = ((XmlSchemaSimpleTypeRestriction)content).BaseTypeName;
                    }
                    else if (t == typeof(XmlSchemaSimpleTypeUnion))
                    {
                        XmlQualifiedName[] memberTypes = ((XmlSchemaSimpleTypeUnion)item).MemberTypes;

                        if (memberTypes != null)
                        {
                            for (int i = 0; i < memberTypes.Length; i++)
                            {
                                XmlSchemaType type = (XmlSchemaType)schemas.Find(memberTypes[i], typeof(XmlSchemaType), false);
                                AddRef(refs, type);
                            }
                        }
                    }
                }
                if (baseType == null && !baseName.IsEmpty && baseName.Namespace != XmlSchema.Namespace)
                {
                    baseType = (XmlSchemaType)schemas.Find(baseName, typeof(XmlSchemaType), false);
                }

                if (baseType != null)
                {
                    AddRef(refs, baseType);
                }
                if (particle != null)
                {
                    Depends(particle, refs);
                }
                if (attributes != null)
                {
                    for (int i = 0; i < attributes.Count; i++)
                    {
                        Depends(attributes[i], refs);
                    }
                }
            }
            else if (t == typeof(XmlSchemaElement))
            {
                XmlSchemaElement el = (XmlSchemaElement)item;
                if (!el.SubstitutionGroup.IsEmpty)
                {
                    if (el.SubstitutionGroup.Namespace != XmlSchema.Namespace)
                    {
                        XmlSchemaElement head = (XmlSchemaElement)schemas.Find(el.SubstitutionGroup, typeof(XmlSchemaElement), false);
                        AddRef(refs, head);
                    }
                }
                if (!el.RefName.IsEmpty)
                {
                    el = (XmlSchemaElement)schemas.Find(el.RefName, typeof(XmlSchemaElement), false);
                    AddRef(refs, el);
                }
                else if (!el.SchemaTypeName.IsEmpty)
                {
                    XmlSchemaType type = (XmlSchemaType)schemas.Find(el.SchemaTypeName, typeof(XmlSchemaType), false);
                    AddRef(refs, type);
                }
                else
                {
                    Depends(el.SchemaType, refs);
                }
            }
            else if (t == typeof(XmlSchemaGroup))
            {
                Depends(((XmlSchemaGroup)item).Particle);
            }
            else if (t == typeof(XmlSchemaGroupRef))
            {
                XmlSchemaGroup group = (XmlSchemaGroup)schemas.Find(((XmlSchemaGroupRef)item).RefName, typeof(XmlSchemaGroup), false);
                AddRef(refs, group);
            }
            else if (typeof(XmlSchemaGroupBase).IsAssignableFrom(t))
            {
                foreach (XmlSchemaObject o in ((XmlSchemaGroupBase)item).Items)
                {
                    Depends(o, refs);
                }
            }
            else if (t == typeof(XmlSchemaAttributeGroupRef))
            {
                XmlSchemaAttributeGroup group = (XmlSchemaAttributeGroup)schemas.Find(((XmlSchemaAttributeGroupRef)item).RefName, typeof(XmlSchemaAttributeGroup), false);
                AddRef(refs, group);
            }
            else if (t == typeof(XmlSchemaAttributeGroup))
            {
                foreach (XmlSchemaObject o in ((XmlSchemaAttributeGroup)item).Attributes)
                {
                    Depends(o, refs);
                }
            }
            else if (t == typeof(XmlSchemaAttribute))
            {
                XmlSchemaAttribute at = (XmlSchemaAttribute)item;
                if (!at.RefName.IsEmpty)
                {
                    at = (XmlSchemaAttribute)schemas.Find(at.RefName, typeof(XmlSchemaAttribute), false);
                    AddRef(refs, at);
                }
                else if (!at.SchemaTypeName.IsEmpty)
                {
                    XmlSchemaType type = (XmlSchemaType)schemas.Find(at.SchemaTypeName, typeof(XmlSchemaType), false);
                    AddRef(refs, type);
                }
                else
                {
                    Depends(at.SchemaType, refs);
                }
            }
            if (typeof(XmlSchemaAnnotated).IsAssignableFrom(t))
            {
                XmlAttribute[] attrs = (XmlAttribute[])((XmlSchemaAnnotated)item).UnhandledAttributes;

                if (attrs != null)
                {
                    for (int i = 0; i < attrs.Length; i++)
                    {
                        XmlAttribute attribute = attrs[i];
                        if (attribute.LocalName == Wsdl.ArrayType && attribute.NamespaceURI == Wsdl.Namespace)
                        {
                            string           dims;
                            XmlQualifiedName qname = TypeScope.ParseWsdlArrayType(attribute.Value, out dims, item);
                            XmlSchemaType    type  = (XmlSchemaType)schemas.Find(qname, typeof(XmlSchemaType), false);
                            AddRef(refs, type);
                        }
                    }
                }
            }
        }
 internal void Depends(XmlSchemaObject item, ArrayList refs)
 {
     if ((item != null) && (this.scope[item] == null))
     {
         Type c = item.GetType();
         if (typeof(XmlSchemaType).IsAssignableFrom(c))
         {
             XmlQualifiedName          empty      = XmlQualifiedName.Empty;
             XmlSchemaType             o          = null;
             XmlSchemaParticle         particle   = null;
             XmlSchemaObjectCollection attributes = null;
             if (item is XmlSchemaComplexType)
             {
                 XmlSchemaComplexType type3 = (XmlSchemaComplexType)item;
                 if (type3.ContentModel != null)
                 {
                     XmlSchemaContent content = type3.ContentModel.Content;
                     if (content is XmlSchemaComplexContentRestriction)
                     {
                         empty      = ((XmlSchemaComplexContentRestriction)content).BaseTypeName;
                         attributes = ((XmlSchemaComplexContentRestriction)content).Attributes;
                     }
                     else if (content is XmlSchemaSimpleContentRestriction)
                     {
                         XmlSchemaSimpleContentRestriction restriction = (XmlSchemaSimpleContentRestriction)content;
                         if (restriction.BaseType != null)
                         {
                             o = restriction.BaseType;
                         }
                         else
                         {
                             empty = restriction.BaseTypeName;
                         }
                         attributes = restriction.Attributes;
                     }
                     else if (content is XmlSchemaComplexContentExtension)
                     {
                         XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension)content;
                         attributes = extension.Attributes;
                         particle   = extension.Particle;
                         empty      = extension.BaseTypeName;
                     }
                     else if (content is XmlSchemaSimpleContentExtension)
                     {
                         XmlSchemaSimpleContentExtension extension2 = (XmlSchemaSimpleContentExtension)content;
                         attributes = extension2.Attributes;
                         empty      = extension2.BaseTypeName;
                     }
                 }
                 else
                 {
                     attributes = type3.Attributes;
                     particle   = type3.Particle;
                 }
                 if (particle is XmlSchemaGroupRef)
                 {
                     XmlSchemaGroupRef ref2 = (XmlSchemaGroupRef)particle;
                     particle = ((XmlSchemaGroup)this.schemas.Find(ref2.RefName, typeof(XmlSchemaGroup), false)).Particle;
                 }
                 else if (particle is XmlSchemaGroupBase)
                 {
                     particle = (XmlSchemaGroupBase)particle;
                 }
             }
             else if (item is XmlSchemaSimpleType)
             {
                 XmlSchemaSimpleType        type4    = (XmlSchemaSimpleType)item;
                 XmlSchemaSimpleTypeContent content2 = type4.Content;
                 if (content2 is XmlSchemaSimpleTypeRestriction)
                 {
                     o     = ((XmlSchemaSimpleTypeRestriction)content2).BaseType;
                     empty = ((XmlSchemaSimpleTypeRestriction)content2).BaseTypeName;
                 }
                 else if (content2 is XmlSchemaSimpleTypeList)
                 {
                     XmlSchemaSimpleTypeList list = (XmlSchemaSimpleTypeList)content2;
                     if ((list.ItemTypeName != null) && !list.ItemTypeName.IsEmpty)
                     {
                         empty = list.ItemTypeName;
                     }
                     if (list.ItemType != null)
                     {
                         o = list.ItemType;
                     }
                 }
                 else if (content2 is XmlSchemaSimpleTypeRestriction)
                 {
                     empty = ((XmlSchemaSimpleTypeRestriction)content2).BaseTypeName;
                 }
                 else if (c == typeof(XmlSchemaSimpleTypeUnion))
                 {
                     XmlQualifiedName[] memberTypes = ((XmlSchemaSimpleTypeUnion)item).MemberTypes;
                     if (memberTypes != null)
                     {
                         for (int i = 0; i < memberTypes.Length; i++)
                         {
                             XmlSchemaType type5 = (XmlSchemaType)this.schemas.Find(memberTypes[i], typeof(XmlSchemaType), false);
                             this.AddRef(refs, type5);
                         }
                     }
                 }
             }
             if (((o == null) && !empty.IsEmpty) && (empty.Namespace != "http://www.w3.org/2001/XMLSchema"))
             {
                 o = (XmlSchemaType)this.schemas.Find(empty, typeof(XmlSchemaType), false);
             }
             if (o != null)
             {
                 this.AddRef(refs, o);
             }
             if (particle != null)
             {
                 this.Depends(particle, refs);
             }
             if (attributes != null)
             {
                 for (int j = 0; j < attributes.Count; j++)
                 {
                     this.Depends(attributes[j], refs);
                 }
             }
         }
         else if (c == typeof(XmlSchemaElement))
         {
             XmlSchemaElement element = (XmlSchemaElement)item;
             if (!element.SubstitutionGroup.IsEmpty && (element.SubstitutionGroup.Namespace != "http://www.w3.org/2001/XMLSchema"))
             {
                 XmlSchemaElement element2 = (XmlSchemaElement)this.schemas.Find(element.SubstitutionGroup, typeof(XmlSchemaElement), false);
                 this.AddRef(refs, element2);
             }
             if (!element.RefName.IsEmpty)
             {
                 element = (XmlSchemaElement)this.schemas.Find(element.RefName, typeof(XmlSchemaElement), false);
                 this.AddRef(refs, element);
             }
             else if (!element.SchemaTypeName.IsEmpty)
             {
                 XmlSchemaType type6 = (XmlSchemaType)this.schemas.Find(element.SchemaTypeName, typeof(XmlSchemaType), false);
                 this.AddRef(refs, type6);
             }
             else
             {
                 this.Depends(element.SchemaType, refs);
             }
         }
         else if (c == typeof(XmlSchemaGroup))
         {
             this.Depends(((XmlSchemaGroup)item).Particle);
         }
         else if (c == typeof(XmlSchemaGroupRef))
         {
             XmlSchemaGroup group = (XmlSchemaGroup)this.schemas.Find(((XmlSchemaGroupRef)item).RefName, typeof(XmlSchemaGroup), false);
             this.AddRef(refs, group);
         }
         else if (typeof(XmlSchemaGroupBase).IsAssignableFrom(c))
         {
             foreach (XmlSchemaObject obj2 in ((XmlSchemaGroupBase)item).Items)
             {
                 this.Depends(obj2, refs);
             }
         }
         else if (c == typeof(XmlSchemaAttributeGroupRef))
         {
             XmlSchemaAttributeGroup group2 = (XmlSchemaAttributeGroup)this.schemas.Find(((XmlSchemaAttributeGroupRef)item).RefName, typeof(XmlSchemaAttributeGroup), false);
             this.AddRef(refs, group2);
         }
         else if (c == typeof(XmlSchemaAttributeGroup))
         {
             foreach (XmlSchemaObject obj3 in ((XmlSchemaAttributeGroup)item).Attributes)
             {
                 this.Depends(obj3, refs);
             }
         }
         else if (c == typeof(XmlSchemaAttribute))
         {
             XmlSchemaAttribute attribute = (XmlSchemaAttribute)item;
             if (!attribute.RefName.IsEmpty)
             {
                 attribute = (XmlSchemaAttribute)this.schemas.Find(attribute.RefName, typeof(XmlSchemaAttribute), false);
                 this.AddRef(refs, attribute);
             }
             else if (!attribute.SchemaTypeName.IsEmpty)
             {
                 XmlSchemaType type7 = (XmlSchemaType)this.schemas.Find(attribute.SchemaTypeName, typeof(XmlSchemaType), false);
                 this.AddRef(refs, type7);
             }
             else
             {
                 this.Depends(attribute.SchemaType, refs);
             }
         }
         if (typeof(XmlSchemaAnnotated).IsAssignableFrom(c))
         {
             XmlAttribute[] unhandledAttributes = ((XmlSchemaAnnotated)item).UnhandledAttributes;
             if (unhandledAttributes != null)
             {
                 for (int k = 0; k < unhandledAttributes.Length; k++)
                 {
                     XmlAttribute attribute2 = unhandledAttributes[k];
                     if ((attribute2.LocalName == "arrayType") && (attribute2.NamespaceURI == "http://schemas.xmlsoap.org/wsdl/"))
                     {
                         string           str;
                         XmlQualifiedName name  = TypeScope.ParseWsdlArrayType(attribute2.Value, out str, item);
                         XmlSchemaType    type8 = (XmlSchemaType)this.schemas.Find(name, typeof(XmlSchemaType), false);
                         this.AddRef(refs, type8);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 19
0
    private void method_4(XmlSchemaGroupBase A_0, XmlNode A_1, bool A_2)
    {
        int num = 8;
        XmlSchemaComplexType item = new XmlSchemaComplexType {
            Name = A_1.Attributes[BookmarkStart.b("䀭儯弱儳", 8)].Value
        };

        if (A_2)
        {
            string            name = item.Name + BookmarkStart.b("椭䈯崱䄳䘵", num);
            XmlSchemaGroupRef ref2 = new XmlSchemaGroupRef {
                RefName = new XmlQualifiedName(name)
            };
            item.Particle = ref2;
            XmlSchemaGroup group = new XmlSchemaGroup {
                Name     = name,
                Particle = A_0
            };
            this.xmlSchema_0.Items.Add(group);
        }
        else
        {
            item.Particle = A_0;
            item.Particle.MaxOccursString = BookmarkStart.b("嬭帯倱嬳䌵嘷帹夻娽", num);
            item.Particle.MinOccurs       = 0M;
        }
        this.xmlSchema_0.Items.Add(item);
        foreach (XmlNode node4 in A_1.SelectNodes(BookmarkStart.b("䌭ਯ圱堳匵唷弹刻䨽", num), this.xmlNamespaceManager_0))
        {
            this.method_5(node4, A_0);
        }
        foreach (XmlNode node in A_1.SelectNodes(BookmarkStart.b("䌭ਯ唱䘳夵䴷䨹", num), this.xmlNamespaceManager_0))
        {
            XmlAttribute attribute = node.Attributes[BookmarkStart.b("尭唯吱", num)];
            if (attribute != null)
            {
                XmlNode node2 = this.xmlElement_0.SelectSingleNode(BookmarkStart.b("䌭ਯ唱䘳夵䴷䨹朻總⸿⍁⥃⍅畇浉", num) + attribute.Value + BookmarkStart.b("भ洯", num), this.xmlNamespaceManager_0);
                this.method_6(node2, A_0);
            }
            else
            {
                this.method_6(node, A_0);
            }
        }
        XmlSchemaObjectCollection attributes = item.Attributes;

        if (A_2)
        {
            string str2 = item.Name + BookmarkStart.b("漭䐯䘱䘳焵䨷唹䤻丽", num);
            XmlSchemaAttributeGroupRef ref3 = new XmlSchemaAttributeGroupRef {
                RefName = new XmlQualifiedName(str2)
            };
            item.Attributes.Add(ref3);
            XmlSchemaAttributeGroup group2 = new XmlSchemaAttributeGroup {
                Name = str2
            };
            this.xmlSchema_0.Items.Add(group2);
            attributes = group2.Attributes;
        }
        foreach (XmlNode node3 in A_1.SelectNodes(BookmarkStart.b("䌭ਯ匱䀳䈵䨷匹帻䬽㐿❁", num), this.xmlNamespaceManager_0))
        {
            this.method_7(node3, attributes);
        }
        XmlSchemaAttribute attribute2 = new XmlSchemaAttribute {
            Name           = BookmarkStart.b("䜭启", num),
            SchemaTypeName = new XmlQualifiedName(BookmarkStart.b("䜭帯䘱", num), BookmarkStart.b("䘭䐯䘱䐳వ᜷ᔹ䬻䤽㜿汁㍃畅晇╉㹋⥍罏恑摓晕楗留ћ፝ⱟㅡݣ๥൧ݩ൫", num))
        };

        item.Attributes.Add(attribute2);
    }
Exemplo n.º 20
0
        private static XmlSchema CreateFakeSoapEncodingSchema(string ns, string name)
        {
            var schema = new XmlSchema();

            schema.TargetNamespace = ns;
            var item = new XmlSchemaGroup();

            item.Name = "Array";
            var sequence = new XmlSchemaSequence();
            var any      = new XmlSchemaAny();

            any.MinOccurs = 0M;
            any.MaxOccurs = 79228162514264337593543950335M;
            sequence.Items.Add(any);
            any.Namespace       = "##any";
            any.ProcessContents = XmlSchemaContentProcessing.Lax;
            item.Particle       = sequence;
            schema.Items.Add(item);
            var type = new XmlSchemaComplexType();

            type.Name = name;
            var ref2 = new XmlSchemaGroupRef();

            ref2.RefName  = new XmlQualifiedName("Array", ns);
            type.Particle = ref2;
            var attribute = new XmlSchemaAttribute();

            attribute.RefName = new XmlQualifiedName("arrayType", ns);
            type.Attributes.Add(attribute);
            schema.Items.Add(type);
            attribute      = new XmlSchemaAttribute();
            attribute.Use  = XmlSchemaUse.None;
            attribute.Name = "arrayType";
            schema.Items.Add(attribute);
            AddSimpleType(schema, "base64", "base64Binary");
            AddElementAndType(schema, "anyURI", ns);
            AddElementAndType(schema, "base64Binary", ns);
            AddElementAndType(schema, "boolean", ns);
            AddElementAndType(schema, "byte", ns);
            AddElementAndType(schema, "date", ns);
            AddElementAndType(schema, "dateTime", ns);
            AddElementAndType(schema, "decimal", ns);
            AddElementAndType(schema, "double", ns);
            AddElementAndType(schema, "duration", ns);
            AddElementAndType(schema, "ENTITIES", ns);
            AddElementAndType(schema, "ENTITY", ns);
            AddElementAndType(schema, "float", ns);
            AddElementAndType(schema, "gDay", ns);
            AddElementAndType(schema, "gMonth", ns);
            AddElementAndType(schema, "gMonthDay", ns);
            AddElementAndType(schema, "gYear", ns);
            AddElementAndType(schema, "gYearMonth", ns);
            AddElementAndType(schema, "hexBinary", ns);
            AddElementAndType(schema, "ID", ns);
            AddElementAndType(schema, "IDREF", ns);
            AddElementAndType(schema, "IDREFS", ns);
            AddElementAndType(schema, "int", ns);
            AddElementAndType(schema, "integer", ns);
            AddElementAndType(schema, "language", ns);
            AddElementAndType(schema, "long", ns);
            AddElementAndType(schema, "Name", ns);
            AddElementAndType(schema, "NCName", ns);
            AddElementAndType(schema, "negativeInteger", ns);
            AddElementAndType(schema, "NMTOKEN", ns);
            AddElementAndType(schema, "NMTOKENS", ns);
            AddElementAndType(schema, "nonNegativeInteger", ns);
            AddElementAndType(schema, "nonPositiveInteger", ns);
            AddElementAndType(schema, "normalizedString", ns);
            AddElementAndType(schema, "positiveInteger", ns);
            AddElementAndType(schema, "QName", ns);
            AddElementAndType(schema, "short", ns);
            AddElementAndType(schema, "string", ns);
            AddElementAndType(schema, "time", ns);
            AddElementAndType(schema, "token", ns);
            AddElementAndType(schema, "unsignedByte", ns);
            AddElementAndType(schema, "unsignedInt", ns);
            AddElementAndType(schema, "unsignedLong", ns);
            AddElementAndType(schema, "unsignedShort", ns);
            return(schema);
        }
 public override void Check(ConformanceCheckContext ctx, XmlSchemaGroupRef value)
 {
     CheckSchemaQName(ctx, value, value.RefName);
 }
        private void roopItem(XmlSchemaGroupBase xgb, bool tf, string choiceStr)
        {
            bool   choice   = tf;
            bool   isVector = false;
            string includePathStr;
            string cStr = choiceStr;

            if (xgb is XmlSchemaChoice)
            {
                choice = true;
                if (xgb.Id == null)
                {
                    choiceStr = "choiceStr_" + m_ClassGen.ChoiceStr.Count;
                }
                else
                {
                    choiceStr = "choiceStr_" + xgb.Id;
                }

                m_ClassGen.ChoiceStr.Add(choiceStr);
                m_ClassGen.ChoiceStrMember.Add(choiceStr, new List <string>());
            }

            foreach (XmlSchemaObject item in xgb.Items)
            {
                isVector = false;


                if (item is XmlSchemaElement)
                {
                    XmlSchemaElement itemCast = item as XmlSchemaElement;

                    if (itemCast.RefName.IsEmpty)
                    {
                        #region directDef
                        if (choice)
                        {
                            m_ClassGen.ChoiceStrMember[choiceStr].Add(itemCast.Name);
                        }

                        if (itemCast.SchemaTypeName.IsEmpty)
                        {
                            includePathStr = includePath["boolean"];

                            m_MemberVariable.Add(new Variable("boolean",
                                                              itemCast.Name,
                                                              includePathStr,
                                                              isVector,
                                                              choice));
                        }
                        else
                        {
                            decimal aa = itemCast.MaxOccurs;
                            if (itemCast.MaxOccurs > 1)
                            {
                                isVector = true;
                            }

                            includePathStr = includePath[itemCast.SchemaTypeName.Name];

                            m_MemberVariable.Add(new Variable(itemCast.SchemaTypeName.Name,
                                                              itemCast.Name,
                                                              includePathStr,
                                                              isVector,
                                                              choice));
                        }
                        #endregion
                    }

                    else
                    {
                        #region refDef

                        string type = elementRef[itemCast.RefName.Name];
                        if (choice)
                        {
                            m_ClassGen.ChoiceStrMember[choiceStr].Add(itemCast.RefName.Name);
                        }

                        includePathStr = includePath[type];

                        m_MemberVariable.Add(new Variable(type,
                                                          itemCast.RefName.Name,
                                                          includePathStr,
                                                          isVector,
                                                          choice));

                        foreach (KeyValuePair <string, string> substiItem in elementSubstitutionRef)
                        {
                            if (substiItem.Key == itemCast.RefName.Name)
                            {
                                choice = false;
                                bool   substi    = true; // 주석을 위한 것
                                string substiStr = elementRef[substiItem.Value];
                                includePathStr = includePath[substiStr];

                                Variable substiVariable = new Variable(substiStr,
                                                                       substiItem.Value,
                                                                       includePathStr,
                                                                       isVector,
                                                                       choice,
                                                                       substi);

                                //substiVariable.SubstitudeStr = itemCast.RefName.Name;  주석에 들어갈건데 먼저 생성자에서 코드가 생성되서리 적용이 안댐 그냥 우선은 패스

                                m_MemberVariable.Add(substiVariable);
                            }
                        }
                        #endregion
                    }
                }
                else if (item is XmlSchemaGroupRef)
                {
                    #region groupRefDef

                    XmlSchemaGroupRef xsgr = item as XmlSchemaGroupRef;

                    XmlSchemaGroup xsg = elementGroupRef[xsgr.RefName.Name];

                    roopItem(xsg.Particle, choice, choiceStr);

                    #endregion
                }
                else if (item is XmlSchemaGroupBase)
                {
                    XmlSchemaGroupBase xgbSub = item as XmlSchemaGroupBase;
                    roopItem(xgbSub, choice, choiceStr);
                }
            }
        }
Exemplo n.º 23
0
 public virtual void Check(ConformanceCheckContext ctx, XmlSchemaGroupRef value)
 {
 }
Exemplo n.º 24
0
        XmlSchemaParticle GetRefGroupParticle(XmlSchemaGroupRef refGroup)
        {
            XmlSchemaGroup grp = (XmlSchemaGroup)schemas.Find(refGroup.RefName, typeof(XmlSchemaGroup));

            return(grp.Particle);
        }
Exemplo n.º 25
0
        static void Check(ConformanceCheckContext ctx, ConformanceChecker checker, Hashtable visitedObjects, XmlSchemaObject value)
        {
            if (value == null)
            {
                return;
            }

            if (visitedObjects.Contains(value))
            {
                return;
            }
            visitedObjects.Add(value, value);

            if (value is XmlSchemaImport)
            {
                XmlSchemaImport so = (XmlSchemaImport)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaAll)
            {
                XmlSchemaAll so = (XmlSchemaAll)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Items);
            }
            else if (value is XmlSchemaAnnotation)
            {
                XmlSchemaAnnotation so = (XmlSchemaAnnotation)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Items);
            }
            else if (value is XmlSchemaAttribute)
            {
                XmlSchemaAttribute so = (XmlSchemaAttribute)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaAttributeGroup)
            {
                XmlSchemaAttributeGroup so = (XmlSchemaAttributeGroup)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
                Check(ctx, checker, visitedObjects, so.RedefinedAttributeGroup);
            }
            else if (value is XmlSchemaAttributeGroupRef)
            {
                XmlSchemaAttributeGroupRef so = (XmlSchemaAttributeGroupRef)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaChoice)
            {
                XmlSchemaChoice so = (XmlSchemaChoice)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Items);
            }
            else if (value is XmlSchemaComplexContent)
            {
                XmlSchemaComplexContent so = (XmlSchemaComplexContent)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Content);
            }
            else if (value is XmlSchemaComplexContentExtension)
            {
                XmlSchemaComplexContentExtension so = (XmlSchemaComplexContentExtension)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Particle);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
            }
            else if (value is XmlSchemaComplexContentRestriction)
            {
                XmlSchemaComplexContentRestriction so = (XmlSchemaComplexContentRestriction)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Particle);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
            }
            else if (value is XmlSchemaComplexType)
            {
                XmlSchemaComplexType so = (XmlSchemaComplexType)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.ContentModel);
                Check(ctx, checker, visitedObjects, so.Particle);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
                Check(ctx, checker, visitedObjects, so.ContentTypeParticle);
                Check(ctx, checker, visitedObjects, so.AttributeWildcard);
            }
            else if (value is XmlSchemaElement)
            {
                XmlSchemaElement so = (XmlSchemaElement)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.SchemaType);
                CheckObjects(ctx, checker, visitedObjects, so.Constraints);
            }
            else if (value is XmlSchemaGroup)
            {
                XmlSchemaGroup so = (XmlSchemaGroup)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Particle);
            }
            else if (value is XmlSchemaGroupRef)
            {
                XmlSchemaGroupRef so = (XmlSchemaGroupRef)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaIdentityConstraint)
            {
                XmlSchemaIdentityConstraint so = (XmlSchemaIdentityConstraint)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Fields);
                Check(ctx, checker, visitedObjects, so.Selector);
            }
            else if (value is XmlSchemaKeyref)
            {
                XmlSchemaKeyref so = (XmlSchemaKeyref)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaRedefine)
            {
                XmlSchemaRedefine so = (XmlSchemaRedefine)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Items);
            }
            else if (value is XmlSchemaSequence)
            {
                XmlSchemaSequence so = (XmlSchemaSequence)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Items);
            }
            else if (value is XmlSchemaSimpleContent)
            {
                XmlSchemaSimpleContent so = (XmlSchemaSimpleContent)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Content);
            }
            else if (value is XmlSchemaSimpleContentExtension)
            {
                XmlSchemaSimpleContentExtension so = (XmlSchemaSimpleContentExtension)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
            }
            else if (value is XmlSchemaSimpleContentRestriction)
            {
                XmlSchemaSimpleContentRestriction so = (XmlSchemaSimpleContentRestriction)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Attributes);
                Check(ctx, checker, visitedObjects, so.AnyAttribute);
                CheckObjects(ctx, checker, visitedObjects, so.Facets);
            }
            else if (value is XmlSchemaSimpleType)
            {
                XmlSchemaSimpleType so = (XmlSchemaSimpleType)value;
                checker.Check(ctx, so);
                Check(ctx, checker, visitedObjects, so.Content);
            }
            else if (value is XmlSchemaSimpleTypeList)
            {
                XmlSchemaSimpleTypeList so = (XmlSchemaSimpleTypeList)value;
                checker.Check(ctx, so);
            }
            else if (value is XmlSchemaSimpleTypeRestriction)
            {
                XmlSchemaSimpleTypeRestriction so = (XmlSchemaSimpleTypeRestriction)value;
                checker.Check(ctx, so);
                CheckObjects(ctx, checker, visitedObjects, so.Facets);
            }
            else if (value is XmlSchemaSimpleTypeUnion)
            {
                XmlSchemaSimpleTypeUnion so = (XmlSchemaSimpleTypeUnion)value;
                checker.Check(ctx, so);
            }
        }
Exemplo n.º 26
0
 protected override void Visit(XmlSchemaGroupRef groupRef)
 {
     // Don't visit children.
 }
Exemplo n.º 27
0
    public static void Main()
    {
        XmlSchema schema = new XmlSchema();

        // <xs:element name="thing1" type="xs:string"/>
        XmlSchemaElement elementThing1 = new XmlSchemaElement();

        schema.Items.Add(elementThing1);
        elementThing1.Name           = "thing1";
        elementThing1.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");

        // <xs:element name="thing2" type="xs:string"/>
        XmlSchemaElement elementThing2 = new XmlSchemaElement();

        schema.Items.Add(elementThing2);
        elementThing2.Name           = "thing2";
        elementThing2.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");

        // <xs:element name="thing3" type="xs:string"/>
        XmlSchemaElement elementThing3 = new XmlSchemaElement();

        schema.Items.Add(elementThing3);
        elementThing3.Name           = "thing3";
        elementThing3.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");

        // <xs:attribute name="myAttribute" type="xs:decimal"/>
        XmlSchemaAttribute myAttribute = new XmlSchemaAttribute();

        schema.Items.Add(myAttribute);
        myAttribute.Name           = "myAttribute";
        myAttribute.SchemaTypeName = new XmlQualifiedName("decimal", "http://www.w3.org/2001/XMLSchema");

        // <xs:group name="myGroupOfThings">
        XmlSchemaGroup myGroupOfThings = new XmlSchemaGroup();

        schema.Items.Add(myGroupOfThings);
        myGroupOfThings.Name = "myGroupOfThings";

        // <xs:sequence>
        XmlSchemaSequence sequence = new XmlSchemaSequence();

        myGroupOfThings.Particle = sequence;

        // <xs:element ref="thing1"/>
        XmlSchemaElement elementThing1Ref = new XmlSchemaElement();

        sequence.Items.Add(elementThing1Ref);
        elementThing1Ref.RefName = new XmlQualifiedName("thing1");

        // <xs:element ref="thing2"/>
        XmlSchemaElement elementThing2Ref = new XmlSchemaElement();

        sequence.Items.Add(elementThing2Ref);
        elementThing2Ref.RefName = new XmlQualifiedName("thing2");

        // <xs:element ref="thing3"/>
        XmlSchemaElement elementThing3Ref = new XmlSchemaElement();

        sequence.Items.Add(elementThing3Ref);
        elementThing3Ref.RefName = new XmlQualifiedName("thing3");

        // <xs:complexType name="myComplexType">
        XmlSchemaComplexType myComplexType = new XmlSchemaComplexType();

        schema.Items.Add(myComplexType);
        myComplexType.Name = "myComplexType";

        // <xs:group ref="myGroupOfThings"/>
        XmlSchemaGroupRef myGroupOfThingsRef = new XmlSchemaGroupRef();

        myComplexType.Particle     = myGroupOfThingsRef;
        myGroupOfThingsRef.RefName = new XmlQualifiedName("myGroupOfThings");

        // <xs:attribute ref="myAttribute"/>
        XmlSchemaAttribute myAttributeRef = new XmlSchemaAttribute();

        myComplexType.Attributes.Add(myAttributeRef);
        myAttributeRef.RefName = new XmlQualifiedName("myAttribute");

        XmlSchemaSet schemaSet = new XmlSchemaSet();

        schemaSet.ValidationEventHandler += new ValidationEventHandler(ValidationCallbackOne);
        schemaSet.Add(schema);
        schemaSet.Compile();

        XmlSchema compiledSchema = null;

        foreach (XmlSchema schema1 in schemaSet.Schemas())
        {
            compiledSchema = schema1;
        }

        XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable());

        nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema");
        compiledSchema.Write(Console.Out, nsmgr);
    }
Exemplo n.º 28
0
        private static XmlSchema CreateFakeSoapEncodingSchema(string ns, string name)
        {
            XmlSchema schema1 = new XmlSchema();

            schema1.TargetNamespace = ns;
            XmlSchemaGroup group1 = new XmlSchemaGroup();

            group1.Name = "Array";
            XmlSchemaSequence sequence1 = new XmlSchemaSequence();
            XmlSchemaAny      any1      = new XmlSchemaAny();

            any1.MinOccurs = new decimal(0);
            any1.MaxOccurs = new decimal(-1, -1, -1, false, 0);
            sequence1.Items.Add(any1);
            any1.Namespace       = "##any";
            any1.ProcessContents = XmlSchemaContentProcessing.Lax;
            group1.Particle      = sequence1;
            schema1.Items.Add(group1);
            XmlSchemaComplexType type1 = new XmlSchemaComplexType();

            type1.Name = name;
            XmlSchemaGroupRef ref1 = new XmlSchemaGroupRef();

            ref1.RefName   = new XmlQualifiedName("Array", ns);
            type1.Particle = ref1;
            XmlSchemaAttribute attribute1 = new XmlSchemaAttribute();

            attribute1.RefName = new XmlQualifiedName("arrayType", ns);
            type1.Attributes.Add(attribute1);
            schema1.Items.Add(type1);
            attribute1      = new XmlSchemaAttribute();
            attribute1.Use  = XmlSchemaUse.None;
            attribute1.Name = "arrayType";
            schema1.Items.Add(attribute1);
            AddSimpleType(schema1, "base64", "base64Binary");
            AddElementAndType(schema1, "anyURI", ns);
            AddElementAndType(schema1, "base64Binary", ns);
            AddElementAndType(schema1, "boolean", ns);
            AddElementAndType(schema1, "byte", ns);
            AddElementAndType(schema1, "date", ns);
            AddElementAndType(schema1, "dateTime", ns);
            AddElementAndType(schema1, "decimal", ns);
            AddElementAndType(schema1, "double", ns);
            AddElementAndType(schema1, "duration", ns);
            AddElementAndType(schema1, "ENTITIES", ns);
            AddElementAndType(schema1, "ENTITY", ns);
            AddElementAndType(schema1, "float", ns);
            AddElementAndType(schema1, "gDay", ns);
            AddElementAndType(schema1, "gMonth", ns);
            AddElementAndType(schema1, "gMonthDay", ns);
            AddElementAndType(schema1, "gYear", ns);
            AddElementAndType(schema1, "gYearMonth", ns);
            AddElementAndType(schema1, "hexBinary", ns);
            AddElementAndType(schema1, "ID", ns);
            AddElementAndType(schema1, "IDREF", ns);
            AddElementAndType(schema1, "IDREFS", ns);
            AddElementAndType(schema1, "int", ns);
            AddElementAndType(schema1, "integer", ns);
            AddElementAndType(schema1, "language", ns);
            AddElementAndType(schema1, "long", ns);
            AddElementAndType(schema1, "Name", ns);
            AddElementAndType(schema1, "NCName", ns);
            AddElementAndType(schema1, "negativeInteger", ns);
            AddElementAndType(schema1, "NMTOKEN", ns);
            AddElementAndType(schema1, "NMTOKENS", ns);
            AddElementAndType(schema1, "nonNegativeInteger", ns);
            AddElementAndType(schema1, "nonPositiveInteger", ns);
            AddElementAndType(schema1, "normalizedString", ns);
            AddElementAndType(schema1, "positiveInteger", ns);
            AddElementAndType(schema1, "QName", ns);
            AddElementAndType(schema1, "short", ns);
            AddElementAndType(schema1, "string", ns);
            AddElementAndType(schema1, "time", ns);
            AddElementAndType(schema1, "token", ns);
            AddElementAndType(schema1, "unsignedByte", ns);
            AddElementAndType(schema1, "unsignedInt", ns);
            AddElementAndType(schema1, "unsignedLong", ns);
            AddElementAndType(schema1, "unsignedShort", ns);
            return(schema1);
        }
Exemplo n.º 29
0
 private static void Equal(XmlSchemaGroupRef expected, XmlSchemaGroupRef actual)
 {
     ParticleEqual(expected, actual);
     Assert.Equal(expected.RefName, actual.RefName);
 }
Exemplo n.º 30
0
 protected virtual void Visit(XmlSchemaGroupRef groupRef)
 {
 }