func (me *PkgBag) AnonName(n string) (an xsdt.NCName) { var c uint64 an = xsdt.NCName(n) if c = me.anonCounts[n]; c > 0 { an += xsdt.NCName(fmt.Sprintf("%v", c)) } me.anonCounts[n] = c + 1 return }
func (me *SimpleType) makePkg(bag *PkgBag) { var typeName = me.Name var baseType, safeName = "", "" var resolve = true var isPt bool if len(typeName) == 0 { typeName = bag.AnonName(me.longSafeName(bag)) me.Name = typeName } else { me.Name = typeName } typeName = xsdt.NCName(ustr.PrependIf(typeName.String(), "T")) me.elemBase.beforeMakePkg(bag) bag.Stacks.SimpleType.Push(me) safeName = bag.safeName(typeName.String()) if me.RestrictionSimpleType != nil { if baseType = me.RestrictionSimpleType.Base.String(); (len(baseType) == 0) && (len(me.RestrictionSimpleType.SimpleTypes) > 0) { resolve, baseType = false, me.RestrictionSimpleType.SimpleTypes[0].Name.String() } } if len(baseType) == 0 { baseType = bag.xsdStringTypeRef() } if resolve { baseType = bag.resolveQnameRef(baseType, "T", nil) } bag.simpleBaseTypes[safeName] = baseType if isPt = bag.isParseType(baseType); isPt { bag.parseTypes[safeName] = true } var td = bag.addType(me, safeName, baseType, me.Annotation) var doc string if isPt { doc = sfmt("Since %v is a non-string scalar type (either boolean or numeric), sets the current value obtained from parsing the specified string.", safeName) } else { doc = sfmt("Since %v is just a simple String type, this merely sets the current value from the specified string.", safeName) } td.addMethod(nil, "*"+safeName, "Set (s string)", "", sfmt("(*%v)(me).Set(s)", baseType), doc) if isPt { doc = sfmt("Returns a string representation of this %v's current non-string scalar value.", safeName) } else { doc = sfmt("Since %v is just a simple String type, this merely returns the current string value.", safeName) } td.addMethod(nil, safeName, "String", "string", sfmt("return %v(me).String()", baseType), doc) doc = sfmt("This convenience method just performs a simple type conversion to %v's alias type %v.", safeName, baseType) td.addMethod(nil, safeName, "To"+bag.safeName(baseType), baseType, sfmt("return %v(me)", baseType), doc) me.hasElemRestrictionSimpleType.makePkg(bag) me.hasElemList.makePkg(bag) me.hasElemUnion.makePkg(bag) bag.Stacks.SimpleType.Pop() me.elemBase.afterMakePkg(bag) }
// This convenience method just performs a simple type conversion to TxsdSpace's alias type xsdt.NCName. func (me TxsdSpace) ToXsdtNCName() xsdt.NCName { return xsdt.NCName(me) }
// Since TxsdSpace is just a simple String type, this merely returns the current string value. func (me TxsdSpace) String() string { return xsdt.NCName(me).String() }