structs.go
changeset 2 4dabfef08c8c
parent 1 a01e06faf0db
child 3 6121aa2f21b1
equal deleted inserted replaced
1:a01e06faf0db 2:4dabfef08c8c
    42 }
    42 }
    43 var _ xml.Marshaler = &Stream{}
    43 var _ xml.Marshaler = &Stream{}
    44 
    44 
    45 type StreamError struct {
    45 type StreamError struct {
    46 	cond definedCondition
    46 	cond definedCondition
    47 	text errText
    47 	text *errText
    48 }
    48 }
    49 var _ xml.Marshaler = &StreamError{}
    49 var _ xml.Marshaler = &StreamError{}
    50 
    50 
    51 type definedCondition struct {
    51 type definedCondition struct {
    52 	// Must always be in namespace nsStreams
    52 	// Must always be in namespace nsStreams
    53 	XMLName xml.Name
    53 	XMLName xml.Name
    54 }
    54 }
    55 
    55 
    56 type errText struct {
    56 type errText struct {
    57 	XMLName xml.Name
       
    58 	Lang string
    57 	Lang string
    59 	text string `xml:"chardata"`
    58 	text string `xml:"chardata"`
    60 }
    59 }
    61 var _ xml.Marshaler = &errText{}
    60 var _ xml.Marshaler = &errText{}
    62 
    61 
    86 
    85 
    87 func (s *StreamError) MarshalXML() ([]byte, os.Error) {
    86 func (s *StreamError) MarshalXML() ([]byte, os.Error) {
    88 	buf := bytes.NewBuffer(nil)
    87 	buf := bytes.NewBuffer(nil)
    89 	buf.WriteString("<stream:error>")
    88 	buf.WriteString("<stream:error>")
    90 	xml.Marshal(buf, s.cond)
    89 	xml.Marshal(buf, s.cond)
    91 	xml.Marshal(buf, s.text)
    90 	if s.text != nil {
       
    91 		xml.Marshal(buf, s.text)
       
    92 	}
    92 	buf.WriteString("</stream:error>")
    93 	buf.WriteString("</stream:error>")
    93 	return buf.Bytes(), nil
    94 	return buf.Bytes(), nil
    94 }
    95 }
    95 
    96 
    96 func (e *errText) MarshalXML() ([]byte, os.Error) {
    97 func (e *errText) MarshalXML() ([]byte, os.Error) {