forked from droyo/go-xml
-
Notifications
You must be signed in to change notification settings - Fork 1
/
builtin.go
65 lines (61 loc) · 2.65 KB
/
builtin.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package xsdgen
import (
"go/ast"
"aqwari.net/xml/xsd"
)
func builtinExpr(b xsd.Builtin) ast.Expr {
if int(b) > len(builtinTbl) || b < 0 {
return nil
}
return builtinTbl[b]
}
// The 45 built-in types of the XSD schema
var builtinTbl = []ast.Expr{
xsd.AnyType: &ast.Ident{Name: "string"},
xsd.ENTITIES: &ast.ArrayType{Elt: &ast.Ident{Name: "string"}},
xsd.ENTITY: &ast.Ident{Name: "string"},
xsd.ID: &ast.Ident{Name: "string"},
xsd.IDREF: &ast.Ident{Name: "string"},
xsd.IDREFS: &ast.ArrayType{Elt: &ast.Ident{Name: "string"}},
xsd.NCName: &ast.Ident{Name: "string"},
xsd.NMTOKEN: &ast.Ident{Name: "string"},
xsd.NMTOKENS: &ast.ArrayType{Elt: &ast.Ident{Name: "string"}},
xsd.NOTATION: &ast.ArrayType{Elt: &ast.Ident{Name: "string"}},
xsd.Name: &ast.Ident{Name: "string"},
xsd.QName: &ast.Ident{Name: "xml.Name"},
xsd.AnyURI: &ast.Ident{Name: "string"},
xsd.Base64Binary: &ast.ArrayType{Elt: &ast.Ident{Name: "byte"}},
xsd.Boolean: &ast.Ident{Name: "bool"},
xsd.Byte: &ast.Ident{Name: "byte"},
xsd.Date: &ast.Ident{Name: "xsdDate"},
xsd.DateTime: &ast.Ident{Name: "xsdDateTime"},
xsd.Decimal: &ast.Ident{Name: "float64"},
xsd.Double: &ast.Ident{Name: "float64"},
// the "duration" built-in is especially broken, so we
// don't parse it at all.
xsd.Duration: &ast.Ident{Name: "string"},
xsd.Float: &ast.Ident{Name: "float32"},
xsd.GDay: &ast.Ident{Name: "gDay"},
xsd.GMonth: &ast.Ident{Name: "gMonth"},
xsd.GMonthDay: &ast.Ident{Name: "gMonthDay"},
xsd.GYear: &ast.Ident{Name: "gYear"},
xsd.GYearMonth: &ast.Ident{Name: "gYearMonth"},
xsd.HexBinary: &ast.ArrayType{Elt: &ast.Ident{Name: "byte"}},
xsd.Int: &ast.Ident{Name: "int"},
xsd.Integer: &ast.Ident{Name: "int"},
xsd.Language: &ast.Ident{Name: "string"},
xsd.Long: &ast.Ident{Name: "int64"},
xsd.NegativeInteger: &ast.Ident{Name: "int"},
xsd.NonNegativeInteger: &ast.Ident{Name: "int"},
xsd.NormalizedString: &ast.Ident{Name: "string"},
xsd.NonPositiveInteger: &ast.Ident{Name: "int"},
xsd.PositiveInteger: &ast.Ident{Name: "int"},
xsd.Short: &ast.Ident{Name: "int"},
xsd.String: &ast.Ident{Name: "string"},
xsd.Time: &ast.Ident{Name: "xsdTime"},
xsd.Token: &ast.Ident{Name: "string"},
xsd.UnsignedByte: &ast.Ident{Name: "byte"},
xsd.UnsignedInt: &ast.Ident{Name: "uint"},
xsd.UnsignedLong: &ast.Ident{Name: "uint64"},
xsd.UnsignedShort: &ast.Ident{Name: "uint"},
}