/
toolspecific.go
33 lines (30 loc) · 918 Bytes
/
toolspecific.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 pnml
import (
"encoding/xml"
"errors"
"fmt"
)
type ToolSpecific struct {
XMLName xml.Name `xml:"toolspecific"`
Tool *string `xml:"tool,attr"`
Version *string `xml:"version,attr"`
// Zero or more anyElement
}
func (t *ToolSpecific) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
type toolSpecific ToolSpecific
var tt toolSpecific
if err := d.DecodeElement(&tt, &start); err != nil {
return err
}
line, col := d.InputPos()
if tt.Tool == nil || *tt.Tool == "" {
msg := fmt.Sprint(modelPath, " at line ", line, ", col ", col, ", toolspecific element without tool attribute (or with empty tool)")
return errors.New(msg)
}
if tt.Version == nil || *tt.Version == "" {
msg := fmt.Sprint(modelPath, " at line ", line, ", col ", col, ", toolspecific element without version attribute (or with empty version)")
return errors.New(msg)
}
*t = ToolSpecific(tt)
return nil
}