Пример #1
0
func TransformPresence(el element.Element) (Presence, error) {
	if el.Tag != "presence" {
		return Presence{}, ErrNotPresence
	}
	presence := Presence{}
	presence.To = el.SelectAttrValue("to", "")
	presence.From = el.SelectAttrValue("from", "")
	presence.ID = el.SelectAttrValue("id", "")
	presence.Type = el.SelectAttrValue("type", "")
	presence.Lang = el.SelectAttrValue("xml:lang", "")
	presence.Data = el.Text()

	presence.Children = el.ChildElements()
	presence.Tag, presence.Space = el.Tag, el.Space

	return presence, nil
}
Пример #2
0
func TransformIQ(el element.Element) IQ {
	if el.Tag != "iq" {
		return IQEmpty
	}
	iq := IQ{}
	iq.To = el.SelectAttrValue("to", "")
	iq.From = el.SelectAttrValue("from", "")
	iq.ID = el.SelectAttrValue("id", "")
	iq.Type = el.SelectAttrValue("type", "")
	iq.Lang = el.SelectAttrValue("xml:lang", "")
	iq.Data = el.Text()

	iq.Children = el.ChildElements()
	iq.Tag, iq.Space = el.Tag, el.Space

	return iq
}
Пример #3
0
func TransformMessage(el element.Element) (Message, error) {
	if el.Tag != "message" {
		return Message{}, ErrNotMessage
	}
	message := Message{}
	message.To = el.SelectAttrValue("to", "")
	message.From = el.SelectAttrValue("from", "")
	message.ID = el.SelectAttrValue("id", "")
	message.Type = el.SelectAttrValue("type", "")
	message.Lang = el.SelectAttrValue("xml:lang", "")
	message.Data = el.Text()

	message.Children = el.ChildElements()
	message.Tag, message.Space = el.Tag, el.Space

	return message, nil
}
Пример #4
0
// HandleElement handles the stream:features element. It finds the
// FeatureHandler to call for the given feature children elements invokes it.
func (fm FeaturesMux) HandleElement(el element.Element, p Properties) ([]element.Element, Properties) {
	children := el.ChildElements()
	h, elem := fm.Handler(children)
	return h.HandleFeature(elem, p)
}