(definitions: DefinitionsElement, xmlns?: IXmlNs)
| 211 | public $lookupTypes?: any[]; |
| 212 | |
| 213 | public description(definitions: DefinitionsElement, xmlns?: IXmlNs) { |
| 214 | let element = {}; |
| 215 | let name = this.$name; |
| 216 | |
| 217 | // Check minOccurs / maxOccurs attributes to see if this element is a list |
| 218 | // These are default values for an element |
| 219 | let minOccurs = 1; |
| 220 | let maxOccurs = 1; |
| 221 | |
| 222 | if (this.$maxOccurs === 'unbounded') { |
| 223 | maxOccurs = Infinity; |
| 224 | } else if (this.$maxOccurs) { |
| 225 | maxOccurs = parseInt(this.$maxOccurs, 10); |
| 226 | } |
| 227 | |
| 228 | if (this.$minOccurs) { |
| 229 | //eslint-disable-next-line @typescript-eslint/no-unused-vars |
| 230 | minOccurs = parseInt(this.$minOccurs, 10); |
| 231 | } |
| 232 | |
| 233 | const isMany = maxOccurs > 1; |
| 234 | |
| 235 | if (isMany && name) { |
| 236 | name += '[]'; |
| 237 | } |
| 238 | |
| 239 | if (xmlns && xmlns[TNS_PREFIX]) { |
| 240 | this.$targetNamespace = xmlns[TNS_PREFIX]; |
| 241 | } |
| 242 | let type: any = this.$type || this.$ref; |
| 243 | if (type) { |
| 244 | type = splitQName(type); |
| 245 | const typeName: string = type.name; |
| 246 | const useSchemaXmlns = !!findNs(type.prefix, this.definitionsXmlns, definitions.xmlns) || !!findNs(this.targetNSAlias, this.definitionsXmlns, definitions.xmlns) || this.forceUseSchemaXmlns; |
| 247 | const ns = findNs(type.prefix, xmlns, this.xmlns, useSchemaXmlns ? this.schemaXmlns : undefined, this.definitionsXmlns, definitions.xmlns); |
| 248 | const schema = definitions.schemas[ns]; |
| 249 | const typeElement = schema && (this.$type ? schema.complexTypes[typeName] || schema.types[typeName] : schema.elements[typeName]); |
| 250 | const typeStorage = this.$type ? definitions.descriptions.types : definitions.descriptions.elements; |
| 251 | |
| 252 | // Use namespace + typeName as cache key to avoid conflicts between schemas |
| 253 | const cacheKey = ns ? `${ns}::${typeName}` : typeName; |
| 254 | |
| 255 | if (ns && definitions.schemas[ns]) { |
| 256 | xmlns = definitions.schemas[ns].xmlns; |
| 257 | } |
| 258 | |
| 259 | if (typeElement && !(typeName in Primitives)) { |
| 260 | if (!(cacheKey in typeStorage)) { |
| 261 | let elem: any = {}; |
| 262 | typeStorage[cacheKey] = elem; |
| 263 | |
| 264 | if (isMany && 'maxOccurs' in typeElement) { |
| 265 | typeElement.maxOccurs = this.$maxOccurs; |
| 266 | } |
| 267 | if (Boolean(this.$minOccurs) && 'minOccurs' in typeElement) { |
| 268 | typeElement.minOccurs = this.$minOccurs; |
| 269 | } |
| 270 |
nothing calls this directly
no test coverage detected