Skip to content

Commit f6c28e9

Browse files
authored
Merge pull request #30 from nicoflink/bugfix/Usage-SimpleTypes
Use SimpleTypes in elements
2 parents 1ff4e8b + a7cf97c commit f6c28e9

File tree

5 files changed

+22
-18
lines changed

5 files changed

+22
-18
lines changed

pkg/template/pkged.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/template/types.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import (
5252

5353
// XSD SimpleType declarations
5454
{{range .ExportableSimpleTypes }}
55-
type {{ .GoName }} string
55+
type {{ .GoName }} {{ .GoTypeName }}
5656

5757
{{ $simpleType := . }}
5858
{{ range .Enums }}

pkg/xsd/element.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func (e *Element) GoMemLayout() string {
7070

7171
func (e *Element) GoTypeName() string {
7272
if e.Type != "" {
73-
return e.typ.GoTypeName()
73+
return e.typ.GoName()
7474
} else if e.Ref != "" {
7575
return e.refElm.GoTypeName()
7676
} else if e.isPlainString() {

pkg/xsd/types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@ func (st *SimpleType) compile(sch *Schema, parentElement *Element) {
174174
if st.schema == nil {
175175
st.schema = sch
176176
}
177+
178+
if st.Restriction != nil {
179+
st.Restriction.compile(sch, parentElement)
180+
}
177181
}
178182

179183
func (st *SimpleType) Attributes() []Attribute {

tests/xsd-examples/valid/xmldsig-core-schema.xsd.out

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ type SignatureMethod struct {
5656

5757
Algorithm string `xml:"Algorithm,attr"`
5858

59-
HMACOutputLength string `xml:",any"`
59+
HMACOutputLength *HMACOutputLengthType `xml:",any"`
6060
}
6161

6262
// Element
@@ -73,7 +73,7 @@ type Reference struct {
7373

7474
DigestMethod DigestMethodType `xml:"DigestMethod"`
7575

76-
DigestValue string `xml:"DigestValue"`
76+
DigestValue DigestValueType `xml:"DigestValue"`
7777
}
7878

7979
// Element
@@ -234,20 +234,20 @@ type SignatureProperty struct {
234234
type DSAKeyValue struct {
235235
XMLName xml.Name `xml:"DSAKeyValue"`
236236

237-
G string `xml:"G"`
237+
G *CryptoBinary `xml:"G"`
238238

239-
Y string `xml:"Y"`
239+
Y CryptoBinary `xml:"Y"`
240240

241-
J string `xml:"J"`
241+
J *CryptoBinary `xml:"J"`
242242
}
243243

244244
// Element
245245
type RSAKeyValue struct {
246246
XMLName xml.Name `xml:"RSAKeyValue"`
247247

248-
Modulus string `xml:"Modulus"`
248+
Modulus CryptoBinary `xml:"Modulus"`
249249

250-
Exponent string `xml:"Exponent"`
250+
Exponent CryptoBinary `xml:"Exponent"`
251251
}
252252

253253
// XSD ComplexType declarations
@@ -304,7 +304,7 @@ type SignatureMethodType struct {
304304

305305
Algorithm string `xml:"Algorithm,attr"`
306306

307-
HMACOutputLength string `xml:",any"`
307+
HMACOutputLength *HMACOutputLengthType `xml:",any"`
308308

309309
InnerXml string `xml:",innerxml"`
310310
}
@@ -322,7 +322,7 @@ type ReferenceType struct {
322322

323323
DigestMethod DigestMethodType `xml:"DigestMethod"`
324324

325-
DigestValue string `xml:"DigestValue"`
325+
DigestValue DigestValueType `xml:"DigestValue"`
326326

327327
InnerXml string `xml:",innerxml"`
328328
}
@@ -486,21 +486,21 @@ type SignaturePropertyType struct {
486486
type DSAKeyValueType struct {
487487
XMLName xml.Name
488488

489-
G string `xml:"G"`
489+
G *CryptoBinary `xml:"G"`
490490

491-
Y string `xml:"Y"`
491+
Y CryptoBinary `xml:"Y"`
492492

493-
J string `xml:"J"`
493+
J *CryptoBinary `xml:"J"`
494494

495495
InnerXml string `xml:",innerxml"`
496496
}
497497

498498
type RSAKeyValueType struct {
499499
XMLName xml.Name
500500

501-
Modulus string `xml:"Modulus"`
501+
Modulus CryptoBinary `xml:"Modulus"`
502502

503-
Exponent string `xml:"Exponent"`
503+
Exponent CryptoBinary `xml:"Exponent"`
504504

505505
InnerXml string `xml:",innerxml"`
506506
}
@@ -511,4 +511,4 @@ type CryptoBinary string
511511

512512
type DigestValueType string
513513

514-
type HMACOutputLengthType string
514+
type HMACOutputLengthType int64

0 commit comments

Comments
 (0)