sdmxml

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: ISC Imports: 5 Imported by: 0

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

func RenamedGoDB(sdmDir string) error

RenamedGoDB is the error of a settings.xml with <go-db>, the former name of <db>.

Types

type Class

type Class struct {
	Name string
	Dao  bool
}

Class is a <dto-class> or <dao-class> in the common order of sdm.xml.

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 Dao

type Dao struct {
	Scope           string `xml:"scope,attr"`
	FieldAssignMode int    `xml:"field-assign-mode,attr"`
	Macro           string `xml:"macro,attr"`
}

type DaoClass

type DaoClass struct {
	Name  string
	Ref   string
	Items []DaoItem // in document order
}

DaoClass is a <dao-class> in sdm.xml: either a reference to an external file (Ref) or the elements themselves.

func (*DaoClass) UnmarshalXML

func (c *DaoClass) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

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) Kind

func (it *DaoItem) Kind() string

Kind is the element name: "crud", "query", ...

func (*DaoItem) UnmarshalXML

func (it *DaoItem) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type Dto

type Dto struct {
	Scope          string `xml:"scope,attr"`
	Inheritance    string `xml:"inheritance,attr"`
	FieldNamesMode int    `xml:"field-names-mode,attr"` // IDE plug-ins; sdmc ignores it: Go naming only
	Macro          string `xml:"macro,attr"`
}

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

func (c *DtoClass) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

type Field

type Field struct {
	Column string `xml:"column,attr"`
	Type   string `xml:"type,attr"`
}

type Folders

type Folders struct {
	Target string `xml:"target,attr"` // for Go: module of go.mod
	SQL    string `xml:"sql,attr"`
}

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

func (m *Macro) IsVelocity() bool

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

func LoadSdm(sdmDir string) (*Sdm, error)

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

func (s *Sdm) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error

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"`
}

func LoadSettings

func LoadSettings(sdmDir string) (*Settings, error)

type Type

type Type struct {
	Detected string `xml:"detected,attr"`
	Target   string `xml:"target,attr"`
}

type TypeMap

type TypeMap struct {
	Default string `xml:"default,attr"`
	Types   []Type `xml:"type"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL