From 6d9a5be285ae7a5aa8a5fc6cbeb8a2cf9db785f2 Mon Sep 17 00:00:00 2001 From: Jens Gersdorf Date: Fri, 16 Jun 2023 10:51:34 +0200 Subject: [PATCH 1/3] normalization now replaces '+' with "Plus" --- gowsdl.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gowsdl.go b/gowsdl.go index 32aee6b7..d261137b 100644 --- a/gowsdl.go +++ b/gowsdl.go @@ -486,6 +486,8 @@ func normalize(value string) string { return -1 } + value = strings.ReplaceAll(value, "+", "Plus") + return strings.Map(mapping, value) } From f362b3299181d9a4431af2ed0553f0583ffe338a Mon Sep 17 00:00:00 2001 From: Jens Gersdorf Date: Fri, 16 Jun 2023 14:24:24 +0200 Subject: [PATCH 2/3] specialCharacterMapping in normalize --- gowsdl.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/gowsdl.go b/gowsdl.go index d261137b..cc340c4c 100644 --- a/gowsdl.go +++ b/gowsdl.go @@ -456,6 +456,14 @@ var reservedWordsInAttr = map[string]string{ "string": "astring", } +var specialCharacterMapping = map[string]string{ + "+": "Plus", + "-": "Minus", + "@": "At", + "/": "Slash", + "$": "Dollar", +} + // Replaces Go reserved keywords to avoid compilation issues func replaceReservedWords(identifier string) string { value := reservedWords[identifier] @@ -486,7 +494,9 @@ func normalize(value string) string { return -1 } - value = strings.ReplaceAll(value, "+", "Plus") + for k, v := range specialCharacterMapping { + value = strings.ReplaceAll(value, k, v) + } return strings.Map(mapping, value) } From 2072e3f88a190e3d74deb365f6ec2866964d181e Mon Sep 17 00:00:00 2001 From: Jens Gersdorf Date: Mon, 19 Jun 2023 09:24:50 +0200 Subject: [PATCH 3/3] [ENUMERATION] remove special character Minus => - should be mapped as _ --- gowsdl.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/gowsdl.go b/gowsdl.go index cc340c4c..8d8c77af 100644 --- a/gowsdl.go +++ b/gowsdl.go @@ -458,10 +458,7 @@ var reservedWordsInAttr = map[string]string{ var specialCharacterMapping = map[string]string{ "+": "Plus", - "-": "Minus", "@": "At", - "/": "Slash", - "$": "Dollar", } // Replaces Go reserved keywords to avoid compilation issues @@ -484,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 == '_' { @@ -494,15 +495,11 @@ func normalize(value string) string { return -1 } - for k, v := range specialCharacterMapping { - value = strings.ReplaceAll(value, k, v) - } - return strings.Map(mapping, value) } func goString(s string) string { - return strings.Replace(s, "\"", "\\\"", -1) + return strings.ReplaceAll(s, "\"", "\\\"") } var xsd2GoTypes = map[string]string{