54 lines
1.3 KiB
Go
Raw Normal View History

2017-08-28 20:56:18 -05:00
// Copyright 2017 Baliance. All rights reserved.
//
// Use of this source code is governed by the terms of the Affero GNU General
// Public License version 3.0 as published by the Free Software Foundation and
// appearing in the file LICENSE included in the packaging of this file. A
// commercial license can be purchased by contacting sales@baliance.com.
package elements
import (
"encoding/xml"
"fmt"
)
2017-08-29 16:55:03 -05:00
type Any struct {
2017-08-28 20:56:18 -05:00
SimpleLiteral
}
2017-08-29 16:55:03 -05:00
func NewAny() *Any {
ret := &Any{}
2017-08-28 20:56:18 -05:00
ret.SimpleLiteral = *NewSimpleLiteral()
return ret
}
2017-08-29 16:55:03 -05:00
func (m *Any) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
2017-08-28 20:56:18 -05:00
if m == nil {
return nil
}
return m.SimpleLiteral.MarshalXML(e, start)
}
2017-08-29 16:55:03 -05:00
func (m *Any) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
2017-08-28 20:56:18 -05:00
// initialize to default
m.SimpleLiteral = *NewSimpleLiteral()
// skip any extensions we may find, but don't support
for {
tok, err := d.Token()
if err != nil {
2017-08-29 16:55:03 -05:00
return fmt.Errorf("parsing Any: %s", err)
2017-08-28 20:56:18 -05:00
}
if el, ok := tok.(xml.EndElement); ok && el.Name == start.Name {
break
}
}
return nil
}
2017-08-29 16:55:03 -05:00
func (m *Any) Validate() error {
return m.ValidateWithPath("Any")
2017-08-28 20:56:18 -05:00
}
2017-08-29 16:55:03 -05:00
func (m *Any) ValidateWithPath(path string) error {
2017-08-28 20:56:18 -05:00
if err := m.SimpleLiteral.ValidateWithPath(path); err != nil {
return err
}
return nil
}