Ejemplo n.º 1
0
        // Parses element fields
        private void ParseElementField(URTNamespace parsingNamespace,
                                       URTComplexType parsingComplexType,
                                       int fieldNum)
        {
            Util.Log("WsdlParser.ParseElementField NS "+parsingNamespace+" fieldNum "+fieldNum);            
            // Determine the field name
            String fieldTypeName, fieldTypeXmlNS;
            String fieldName = LookupAttribute(s_nameString, null, true);

            // Look for array bounds
            String minOccurs = LookupAttribute(s_minOccursString, null, false);
            String maxOccurs = LookupAttribute(s_maxOccursString, null, false);

            // Check if the field is optional
            bool bOptional = false;
            if (MatchingStrings(minOccurs, s_zeroString))
                bOptional = true;

            // Check if the field is an inline array
            bool bArray = false;
            String arraySize = null;
            if (!MatchingStrings(maxOccurs, s_emptyString) &&
                !MatchingStrings(maxOccurs, s_oneString))
            {
                if (MatchingStrings(maxOccurs, s_unboundedString))
                    arraySize = String.Empty;
                else
                    arraySize = maxOccurs;
                bArray = true;
            }

            // Handle anonymous types
            bool bEmbedded, bPrimitive;
            if (_XMLReader.IsEmptyElement == true)
            {
                // Non-anonymous type case
                fieldTypeName = LookupAttribute(s_typeString, null, false);

                // Handle the absense of type attribute (Object case)
                ResolveTypeAttribute(ref fieldTypeName, out fieldTypeXmlNS,
                                     out bEmbedded, out bPrimitive);

                // Read next element
                ReadNextXmlElement();
            }
            else
            {
                // Anonymous type case
                fieldTypeXmlNS = parsingNamespace.Namespace;
                fieldTypeName = parsingNamespace.GetNextAnonymousName();
                bPrimitive = false;
                bEmbedded = true;
                int curDepth = _XMLReader.Depth;
                ReadNextXmlElement();

                // Parse the type
                String elementName;
                while (_XMLReader.Depth > curDepth)
                {
                    elementName = _XMLReader.LocalName;
                    if (MatchingStrings(elementName, s_complexTypeString))
                    {
                        URTComplexType complexType = ParseComplexType(parsingNamespace, fieldTypeName);
                        if (complexType.IsEmittableFieldType)
                        {
                            fieldTypeXmlNS = complexType.FieldNamespace;
                            fieldTypeName = complexType.FieldName;
                            bPrimitive = complexType.PrimitiveField;
                            parsingNamespace.RemoveComplexType(complexType);
                        }
                    }
                    else if (MatchingStrings(elementName, s_simpleTypeString))
                    {
                        URTSimpleType simpleType = ParseSimpleType(parsingNamespace, fieldTypeName);
                        if (simpleType.IsEmittableFieldType)
                        {
                            fieldTypeXmlNS = simpleType.FieldNamespace;
                            fieldTypeName = simpleType.FieldName;
                            bPrimitive = simpleType.PrimitiveField;
                            parsingNamespace.RemoveSimpleType(simpleType);
                        }
                    }
                    else
                    {
                        // Ignore others elements such as annotations
                        SkipXmlElement();
                    }
                }
            }

            // Add field to the type being parsed
            parsingComplexType.AddField(new URTField(fieldName, fieldTypeName, fieldTypeXmlNS,
                                                     this, bPrimitive, bEmbedded, false,
                                                     bOptional, bArray, arraySize, parsingNamespace));
            return;
        }
 private void ParseElementField(URTNamespace parsingNamespace, URTComplexType parsingComplexType, int fieldNum)
 {
     string nextAnonymousName;
     string fieldNamespace;
     bool flag3;
     bool primitiveField;
     string name = this.LookupAttribute(s_nameString, null, true);
     string left = this.LookupAttribute(s_minOccursString, null, false);
     string str5 = this.LookupAttribute(s_maxOccursString, null, false);
     bool bOptional = false;
     if (MatchingStrings(left, s_zeroString))
     {
         bOptional = true;
     }
     bool bArray = false;
     string arraySize = null;
     if (!MatchingStrings(str5, s_emptyString) && !MatchingStrings(str5, s_oneString))
     {
         if (MatchingStrings(str5, s_unboundedString))
         {
             arraySize = string.Empty;
         }
         else
         {
             arraySize = str5;
         }
         bArray = true;
     }
     if (this._XMLReader.IsEmptyElement)
     {
         nextAnonymousName = this.LookupAttribute(s_typeString, null, false);
         this.ResolveTypeAttribute(ref nextAnonymousName, out fieldNamespace, out flag3, out primitiveField);
         this.ReadNextXmlElement();
     }
     else
     {
         fieldNamespace = parsingNamespace.Namespace;
         nextAnonymousName = parsingNamespace.GetNextAnonymousName();
         primitiveField = false;
         flag3 = true;
         int depth = this._XMLReader.Depth;
         this.ReadNextXmlElement();
         while (this._XMLReader.Depth > depth)
         {
             string localName = this._XMLReader.LocalName;
             if (MatchingStrings(localName, s_complexTypeString))
             {
                 URTComplexType type = this.ParseComplexType(parsingNamespace, nextAnonymousName);
                 if (type.IsEmittableFieldType)
                 {
                     fieldNamespace = type.FieldNamespace;
                     nextAnonymousName = type.FieldName;
                     primitiveField = type.PrimitiveField;
                     parsingNamespace.RemoveComplexType(type);
                 }
             }
             else
             {
                 if (MatchingStrings(localName, s_simpleTypeString))
                 {
                     URTSimpleType type2 = this.ParseSimpleType(parsingNamespace, nextAnonymousName);
                     if (type2.IsEmittableFieldType)
                     {
                         fieldNamespace = type2.FieldNamespace;
                         nextAnonymousName = type2.FieldName;
                         primitiveField = type2.PrimitiveField;
                         parsingNamespace.RemoveSimpleType(type2);
                     }
                     continue;
                 }
                 this.SkipXmlElement();
             }
         }
     }
     parsingComplexType.AddField(new URTField(name, nextAnonymousName, fieldNamespace, this, primitiveField, flag3, false, bOptional, bArray, arraySize, parsingNamespace));
 }