-
Notifications
You must be signed in to change notification settings - Fork 0
/
stem.go
33 lines (26 loc) · 887 Bytes
/
stem.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
package mxml
import (
"encoding/xml"
"strings"
)
// Stem is the structure for stem MusicXML element.
type Stem struct {
XMLName xml.Name `xml:"stem"`
ColorAttr string `xml:"color,attr,omitempty"`
DefaultXAttr string `xml:"default-x,attr,omitempty"`
DefaultYAttr string `xml:"default-y,attr,omitempty"`
RelativeXAttr string `xml:"relative-x,attr,omitempty"`
RelativeYAttr string `xml:"relative-y,attr,omitempty"`
IValue string `xml:",chardata"`
}
// ToMXML creates a MXML.
func (r *Stem) ToMXML() *MXML {
attributes := make(map[string]string)
children := make(map[string][]*MXML)
attributes["color"] = r.ColorAttr
attributes["default-x"] = r.DefaultXAttr
attributes["default-y"] = r.DefaultYAttr
attributes["relative-x"] = r.RelativeXAttr
attributes["relative-y"] = r.RelativeYAttr
return newMXML("stem", strings.TrimSpace(r.IValue), attributes, children)
}