// SOAP arrays are declared as follows (unimportant fields ellided): // // <xs:complexType name="Array"> // <xs:attribute name="arrayType" type="xs:string" /> // <xs:any namespace="##any" minOccurs="0" maxOccurs="unbounded" /> // </xs:complexType> // // Then schemas that want to declare a fixed-type soap array do so like this: // // <xs:complexType name="IntArray"> // <xs:complexContent> // <xs:restriction base="soapenc:Array> // <xs:attribute ref="soapenc:arrayType" wsdl:arrayType="xs:int[]" /> // </xs:restriction> // </xs:complexContent> // </xs:complexType> // // XML Schema is wonderful, aint it? func (cfg *Config) parseSOAPArrayType(s xsd.Schema, t xsd.Type) xsd.Type { const soapenc = "http://schemas.xmlsoap.org/soap/encoding/" const wsdl = "http://schemas.xmlsoap.org/wsdl/" var itemType xml.Name c, ok := t.(*xsd.ComplexType) if !ok { return t } var attr []xsd.Attribute for _, v := range c.Attributes { if v.Name.Local != "arrayType" { attr = append(attr, v) continue } for _, a := range v.Attr { if (a.Name != xml.Name{wsdl, "arrayType"}) { continue } itemType = v.Resolve(a.Value) break } break } if itemType.Local == "" { return c } itemType.Local = strings.TrimSpace(itemType.Local) itemType.Local = strings.TrimSuffix(itemType.Local, "[]") if b := s.FindType(itemType); b != nil { c = cfg.overrideWildcardType(c, b) } else { cfg.logf("could not lookup item type %q in namespace %q", itemType.Local, itemType.Space) } // Have to remove arrayType from the "base" type, without affecting // others inheriting from this type. basep, ok := c.Base.(*xsd.ComplexType) if !ok { cfg.logf("type %s derives from non-complexType %s", c.Name.Local, xsd.XMLName(c.Base).Local) return c } base := *basep base.Attributes = make([]xsd.Attribute, 0, len(basep.Attributes)-1) for _, v := range basep.Attributes { if v.Name.Local != "arrayType" { base.Attributes = append(base.Attributes, v) } } c.Base = &base c.Attributes = attr return c }