Documentation
¶
Overview ¶
Package sdmxml reads sdm.xml, external <dao-class> files and settings.xml.
The schemas (sdm.xsd, dao.xsd, settings.xsd) are not checked here: XML is written in an IDE, where XSD gives completion and highlighting. Here is what the output would be wrong without: attribute defaults from XSD, the order of DAO elements (the order of methods depends on it) and unknown DAO elements as an error, not a silent skip.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenamedGoDB ¶
RenamedGoDB is the error of a settings.xml with <go-db>, the former name of <db>.
Types ¶
type CrudMethod ¶
type CrudMethod struct {
Method string `xml:"method,attr"`
}
type DB ¶
type DB struct {
URL string `xml:"url,attr"`
User string `xml:"user,attr"`
Pwd string `xml:"pwd,attr"`
}
DB is <db> and <jdbc>; <jdbc> needs no jar and class: the driver is built into the binary.
type DaoClass ¶
DaoClass is a <dao-class> in sdm.xml: either a reference to an external file (Ref) or the elements themselves.
func (*DaoClass) UnmarshalXML ¶
type DaoItem ¶
type DaoItem struct {
XMLName xml.Name
Method string `xml:"method,attr"`
Ref string `xml:"ref,attr"`
Dto string `xml:"dto,attr"`
ExternalSQL bool `xml:"external-sql,attr"`
ReturnType string `xml:"return-type,attr"`
Table string `xml:"table,attr"` // crud, default "*"
FetchGenerated bool `xml:"fetch-generated,attr"` // crud, default true
Create *CrudMethod `xml:"create"`
ReadAll *CrudMethod `xml:"read-all"`
Read *CrudMethod `xml:"read"`
Update *CrudMethod `xml:"update"`
Delete *CrudMethod `xml:"delete"`
}
DaoItem is one of crud, query, query-list, query-dto, query-dto-list, exec-dml.
func (*DaoItem) UnmarshalXML ¶
type DtoClass ¶
type DtoClass struct {
Name string `xml:"name,attr"`
Ref string `xml:"ref,attr"`
PK string `xml:"pk,attr"` // default "*"
Auto string `xml:"auto,attr"` // default "*"
Header *string `xml:"header"` // nil: no element (these are different cases in the template)
Custom string `xml:"custom"`
Fields []Field `xml:"field"`
}
func (*DtoClass) UnmarshalXML ¶
type Macro ¶
type Macro struct {
Name string `xml:"name,attr"`
Value *string `xml:"value,attr"` // nil: no attribute
VM *string `xml:"vm"`
VMXML *struct {
Inner string `xml:",innerxml"`
} `xml:"vm-xml"`
}
Macro is either value (text substitution) or Velocity code in <vm>/<vm-xml>.
func (*Macro) IsVelocity ¶
IsVelocity reports a Velocity macro, which the Go version does not have.
type Sdm ¶
type Sdm struct {
DtoClasses []DtoClass
DaoClasses []DaoClass
Classes []Class // both kinds, in the order of declaration
}
func LoadSdm ¶
LoadSdm reads sdmDir/sdm.xml and pulls in the elements of external <dao-class ref="X.xml"> (the path is relative to sdmDir, as in the Java plug-in).
func (*Sdm) UnmarshalXML ¶
type Settings ¶
type Settings struct {
Folders Folders `xml:"folders"`
Dto Dto `xml:"dto"`
Dao Dao `xml:"dao"`
Jdbc DB `xml:"jdbc"` // IDE plug-ins; sdmc does not read it (cli/genharness does)
DB *DB `xml:"db"` // the database of sdmc
GoDB *DB `xml:"go-db"` // the former name of <db>: only for RenamedGoDB
TypeMap TypeMap `xml:"type-map"`
Macros []Macro `xml:"macros>macro"`
}