diff --git a/gowsdl.go b/gowsdl.go index dbd139b..f341098 100644 --- a/gowsdl.go +++ b/gowsdl.go @@ -456,6 +456,11 @@ var reservedWordsInAttr = map[string]string{ "string": "astring", } +var specialCharacterMapping = map[string]string{ + "+": "Plus", + "@": "At", +} + // Replaces Go reserved keywords to avoid compilation issues func replaceReservedWords(identifier string) string { value := reservedWords[identifier] @@ -476,8 +481,12 @@ func replaceAttrReservedWords(identifier string) string { // Normalizes value to be used as a valid Go identifier, avoiding compilation issues func normalize(value string) string { + for k, v := range specialCharacterMapping { + value = strings.ReplaceAll(value, k, v) + } + mapping := func(r rune) rune { - if r == '.' { + if r == '.' || r == '-' { return '_' } if unicode.IsLetter(r) || unicode.IsDigit(r) || r == '_' { @@ -490,7 +499,7 @@ func normalize(value string) string { } func goString(s string) string { - return strings.Replace(s, "\"", "\\\"", -1) + return strings.ReplaceAll(s, "\"", "\\\"") } var xsd2GoTypes = map[string]string{