Exemple #1
0
func (a *Argument) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	var err error
	startElt := xml.StartElement{Name: xml.Name{Local: "argument"}}
	var opt string
	if a.Optional {
		opt = "yes"
	} else {
		opt = "no"
	}
	startElt.Attr = append(startElt.Attr, xml.Attr{Name: xml.Name{Local: "name"}, Value: a.Name})
	startElt.Attr = append(startElt.Attr, xml.Attr{Name: xml.Name{Local: "optional"}, Value: opt})
	startElt.Attr = append(startElt.Attr, xml.Attr{Name: xml.Name{Local: "type"}, Value: argumentTypeReveseMap[a.Type]})

	err = e.EncodeToken(startElt)
	if err != nil {
		return err
	}

	err = e.EncodeToken(xml.EndElement{Name: startElt.Name})
	if err != nil {
		return err
	}

	return nil
}
Exemple #2
0
func setAttr(n *xml.StartElement, key, val string) {
	n.Attr = append([]xml.Attr{}, n.Attr...)

	for i := range n.Attr {
		attr := &n.Attr[i]
		if attr.Name.Local == key {
			if val == "" {
				n.Attr = append(n.Attr[:i], n.Attr[i+1:]...)
			} else {
				attr.Value = val
			}
			return
		}
	}

	if val == "" {
		return
	}

	n.Attr = append(n.Attr, xml.Attr{
		Name:  xml.Name{Local: key},
		Value: val,
	})
	sort.Sort(attrByName(n.Attr))
}
Exemple #3
0
func (node *Packageoption) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	var err error
	startElt := xml.StartElement{Name: xml.Name{Local: "packageoption"}}

	var dflt string
	if node.Default {
		dflt = "yes"
	} else {
		dflt = "no"
	}
	startElt.Attr = []xml.Attr{
		xml.Attr{Name: xml.Name{Local: "name"}, Value: node.Name},
		xml.Attr{Name: xml.Name{Local: "default"}, Value: dflt},
	}

	err = e.EncodeToken(startElt)
	if err != nil {
		return err
	}

	err = marshalShortDescription("shortdescription", e, node.ShortDescription)
	if err != nil {
		return err
	}
	err = e.EncodeToken(xml.EndElement{Name: startElt.Name})
	if err != nil {
		return err
	}

	return nil
}
Exemple #4
0
func marshalDescription(eltname string, e *xml.Encoder, desc map[string]template.HTML) error {
	var err error
	for lang, text := range desc {
		startElt := xml.StartElement{Name: xml.Name{Local: eltname}}

		startElt.Attr = []xml.Attr{
			xml.Attr{Name: xml.Name{Local: "lang"}, Value: lang},
		}

		err = e.EncodeToken(startElt)
		if err != nil {
			return err
		}

		err = e.EncodeToken(xml.CharData(string(text)))
		if err != nil {
			return err
		}

		err = e.EncodeToken(xml.EndElement{Name: startElt.Name})
		if err != nil {
			return err
		}

	}
	return nil
}
Exemple #5
0
// MarshalXML implements the xml.Marshaller method to allow for the
// correct wrapper/start element case and attr data.
func (c Change) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	start.Name.Local = "osmChange"
	start.Attr = []xml.Attr{
		{Name: xml.Name{Local: "version"}, Value: "0.6"},
		{Name: xml.Name{Local: "generator"}, Value: "go.osm"},
	}

	if err := e.EncodeToken(start); err != nil {
		return err
	}

	if err := marshalInnerChange(e, "create", c.Create); err != nil {
		return err
	}

	if err := marshalInnerChange(e, "modify", c.Modify); err != nil {
		return err
	}

	if err := marshalInnerChange(e, "delete", c.Delete); err != nil {
		return err
	}

	if err := e.EncodeToken(start.End()); err != nil {
		return err
	}

	return nil
}
func (bagc BiddableAdGroupCriterion) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	start.Attr = append(
		start.Attr,
		xml.Attr{
			xml.Name{"http://www.w3.org/2001/XMLSchema-instance", "type"},
			"BiddableAdGroupCriterion",
		},
	)
	e.EncodeToken(start)
	e.EncodeElement(&bagc.AdGroupId, xml.StartElement{Name: xml.Name{"", "adGroupId"}})
	criterionMarshalXML(bagc.Criterion, e)

	if bagc.UserStatus != "" {
		e.EncodeElement(&bagc.UserStatus, xml.StartElement{Name: xml.Name{"", "userStatus"}})
	}
	if bagc.DestinationUrl != "" {
		e.EncodeElement(&bagc.DestinationUrl, xml.StartElement{Name: xml.Name{"", "destinationUrl"}})
	}
	e.EncodeElement(&bagc.BiddingStrategyConfiguration, xml.StartElement{Name: xml.Name{"", "biddingStrategyConfiguration"}})
	if bagc.BidModifier != 0 {
		e.EncodeElement(&bagc.BidModifier, xml.StartElement{Name: xml.Name{"", "bidModifier"}})
	}
	e.EncodeToken(start.End())
	return nil
}
Exemple #7
0
Fichier : st.go Projet : kpmy/lomo
func (u *extern) attr(start *xml.StartElement, name string, value interface{}) {
	str := func(value string) {
		assert.For(value != "", 20)
		a := xml.Attr{}
		a.Name.Local = name
		a.Value = value
		start.Attr = append(start.Attr, a)
	}
	switch v := value.(type) {
	case string:
		str(v)
	case bool:
		if v {
			str("true")
		} else {
			str("false")
		}
	case int:
		str(strconv.Itoa(v))
	case types.Type:
		str(v.String())
	default:
		halt.As(100, reflect.TypeOf(v), v)
	}
}
Exemple #8
0
func encEle(n tree.Elem, e *xml.Encoder) error {
	ele := xml.StartElement{
		Name: n.GetToken().(xml.StartElement).Name,
	}

	attrs := n.GetAttrs()
	ele.Attr = make([]xml.Attr, len(attrs))
	for i := range attrs {
		ele.Attr[i] = attrs[i].GetToken().(xml.Attr)
	}

	err := e.EncodeToken(ele)
	if err != nil {
		return err
	}

	if x, ok := n.(tree.Elem); ok {
		for _, i := range x.GetChildren() {
			err := encTok(i, e)
			if err != nil {
				return err
			}
		}
	}

	return e.EncodeToken(ele.End())
}
Exemple #9
0
func (c *Command) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	var err error
	if c.Level == "" {
		c.Level = "beginner"
	}
	cmdstartelt := xml.StartElement{Name: xml.Name{Local: "command"}}
	cmdstartelt.Attr = []xml.Attr{
		xml.Attr{Name: xml.Name{Local: "name"}, Value: c.Name},
		xml.Attr{Name: xml.Name{Local: "label"}, Value: strings.Join(c.Label, ",")},
		xml.Attr{Name: xml.Name{Local: "level"}, Value: c.Level},
	}
	err = e.EncodeToken(cmdstartelt)
	if err != nil {
		return err
	}
	err = marshalShortDescription("shortdescription", e, c.ShortDescription)
	if err != nil {
		return err
	}

	err = marshalDescription("description", e, c.Description)
	if err != nil {
		return err
	}

	err = e.Encode(c.Variant)
	if err != nil {
		return err
	}

	return e.EncodeToken(xml.EndElement{Name: cmdstartelt.Name})
}
Exemple #10
0
// MarshalXML is a custom marshaller for Duration.
func (dur *Duration) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	start.Attr = []xml.Attr{xml.Attr{Name: xml.Name{Local: "duration"}, Value: dur.Duration.String()},
		xml.Attr{Name: xml.Name{Local: "state"}, Value: dur.State},
	}
	e.EncodeToken(start)
	e.EncodeToken(xml.EndElement{Name: start.Name})
	return nil
}
Exemple #11
0
func (a JobCommandJobRefArguments) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	start.Attr = []xml.Attr{
		xml.Attr{xml.Name{Local: "line"}, string(a)},
	}
	e.EncodeToken(start)
	e.EncodeToken(xml.EndElement{start.Name})
	return nil
}
Exemple #12
0
func (p PList) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	start.Name = xml.Name{Local: "plist"}
	start.Attr = []xml.Attr{xml.Attr{Name: xml.Name{Local: "version"}, Value: "1.0"}}
	e.EncodeToken(start)
	PDict(p).MarshalXML(e, xml.StartElement{})
	e.EncodeToken(start.End())
	return nil
}
Exemple #13
0
// SetAttribute is XML helper that allows to set attribute on a node
func SetAttribute(e xml.StartElement, name, value string) xml.StartElement {
	for i := range e.Attr {
		if e.Attr[i].Name.Local == name {
			e.Attr[i].Value = value
			return e
		}
	}
	e.Attr = append(e.Attr, xml.Attr{Name: xml.Name{Local: name}, Value: value})
	return e
}
func makeStartXml(root *XlsObjNode, enc *xml.Encoder) {
	valueList := root.value.([]*XlsObjNode)
	token := xml.StartElement{xml.Name{"", root.key}, make([]xml.Attr, 0)}

	for _, key := range valueList {
		if key.nodeType == ATTR_TYPE {
			attr := xml.Attr{xml.Name{"", key.key}, key.value.(string)}
			token.Attr = append(token.Attr, attr)
		}
	}
	enc.EncodeToken(token)
}
func (nagc NegativeAdGroupCriterion) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	start.Attr = append(
		start.Attr,
		xml.Attr{
			xml.Name{"http://www.w3.org/2001/XMLSchema-instance", "type"},
			"NegativeAdGroupCriterion",
		},
	)
	e.EncodeToken(start)
	e.EncodeElement(&nagc.AdGroupId, xml.StartElement{Name: xml.Name{"", "adGroupId"}})
	criterionMarshalXML(nagc.Criterion, e)
	e.EncodeToken(start.End())
	return nil
}
Exemple #16
0
func (node *Package) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	var err error
	startElt := xml.StartElement{Name: xml.Name{Local: "package"}}

	if node.Level == "" {
		node.Level = "beginner"
	}

	startElt.Attr = []xml.Attr{
		xml.Attr{Name: xml.Name{Local: "name"}, Value: node.Name},
		xml.Attr{Name: xml.Name{Local: "level"}, Value: node.Level},
		xml.Attr{Name: xml.Name{Local: "label"}, Value: strings.Join(node.Label, ",")},
		xml.Attr{Name: xml.Name{Local: "loadspackages"}, Value: strings.Join(node.LoadsPackages, ",")},
	}

	err = e.EncodeToken(startElt)
	if err != nil {
		return err
	}

	err = marshalShortDescription("shortdescription", e, node.ShortDescription)
	if err != nil {
		return err
	}

	err = marshalDescription("description", e, node.Description)
	if err != nil {
		return err
	}

	err = e.Encode(node.Options)
	if err != nil {
		return err
	}

	err = e.Encode(node.Commands)
	if err != nil {
		return err
	}

	err = e.EncodeToken(xml.EndElement{Name: startElt.Name})
	if err != nil {
		return err
	}

	return nil
}
Exemple #17
0
func (v *Variant) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	variantStartElt := xml.StartElement{Name: xml.Name{Local: "variant"}}
	variantStartElt.Attr = append(variantStartElt.Attr, xml.Attr{Name: xml.Name{Local: "name"}, Value: v.Name})
	err := e.EncodeToken(variantStartElt)
	if err != nil {
		return err
	}
	e.Encode(v.Arguments)
	marshalDescription("description", e, v.Description)

	err = e.EncodeToken(xml.EndElement{Name: variantStartElt.Name})
	if err != nil {
		return err
	}

	return nil
}
Exemple #18
0
func (s *serverStream) writeOpen() error {
	var start xml.StartElement
	start.Name = xml.Name{Local: "stream:stream", Space: "jabber:client"}
	start.Attr = append(start.Attr,
		xml.Attr{Name: xml.Name{Local: "xmlns:stream"}, Value: "http://etherx.jabber.org/streams"},
		xml.Attr{Name: xml.Name{Local: "xmlns:xml"}, Value: "http://www.w3.org/XML/1998/namespace"},
		xml.Attr{Name: xml.Name{Local: "from"}, Value: s.from},
		xml.Attr{Name: xml.Name{Local: "version"}, Value: s.version},
	)
	if err := s.streamEncoder.EncodeToken(start); err != nil {
		return err
	}

	// xml.Encoder doesn't flush until it generated end tag
	// so we flush here to make it send stream's open tag
	return s.streamEncoder.Flush()
}
func (ncc NegativeCampaignCriterion) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	isNegative := true
	//fmt.Printf("processing -> %#v\n",ncc)
	start.Attr = append(
		start.Attr,
		xml.Attr{
			xml.Name{"http://www.w3.org/2001/XMLSchema-instance", "type"},
			"NegativeCampaignCriterion",
		},
	)
	e.EncodeToken(start)
	e.EncodeElement(&ncc.CampaignId, xml.StartElement{Name: xml.Name{"", "campaignId"}})
	e.EncodeElement(&isNegative, xml.StartElement{Name: xml.Name{"", "isNegative"}})
	criterionMarshalXML(ncc.Criterion, e)
	e.EncodeToken(start.End())
	return nil
}
Exemple #20
0
func (t *Tag) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	start.Name = t.Name
	start.Attr = t.Attr
	e.EncodeToken(start)
	for _, v := range t.Children {
		switch v.(type) {
		case *Tag:
			child := v.(*Tag)
			if err := e.Encode(child); err != nil {
				return err
			}
		case xml.CharData:
			e.EncodeToken(v.(xml.CharData))
		case xml.Comment:
			e.EncodeToken(v.(xml.Comment))
		}
	}
	e.EncodeToken(start.End())
	return nil
}
Exemple #21
0
// MarshalXML implements the xml.Marshaller method to allow for the
// correct wrapper/start element case and attr data.
func (o OSM) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	start.Name.Local = "osm"
	start.Attr = []xml.Attr{
		{Name: xml.Name{Local: "version"}, Value: "0.6"},
		{Name: xml.Name{Local: "generator"}, Value: "go.osm"},
	}

	if err := e.EncodeToken(start); err != nil {
		return err
	}

	if err := o.marshalInnerXML(e); err != nil {
		return err
	}

	if err := e.EncodeToken(start.End()); err != nil {
		return err
	}

	return nil
}
Exemple #22
0
func (x *domm) MarshalXML(e *xml.Encoder, start xml.StartElement) (err error) {
	start.Name.Local = x.model.Name()
	for k, v := range x.model.AttrAsMap() {
		start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: k}, Value: v})
	}
	e.EncodeToken(start)
	for _, _l := range x.model.Children() {
		switch l := _l.(type) {
		case dom.Element:
			child := &domm{}
			child.model = l
			e.Encode(child)
		case dom.Text:
			e.EncodeToken(xml.CharData(l.Data()))
		default:
			halt.As(100, reflect.TypeOf(l))
		}
	}
	e.EncodeToken(start.End())
	return
}
Exemple #23
0
func (cc CampaignCriterion) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	isNegative := false
	//fmt.Printf("processing -> %#v\n",ncc)
	start.Attr = append(
		start.Attr,
		xml.Attr{
			xml.Name{"http://www.w3.org/2001/XMLSchema-instance", "type"},
			"CampaignCriterion",
		},
	)
	e.EncodeToken(start)
	e.EncodeElement(&cc.CampaignId, xml.StartElement{Name: xml.Name{"", "campaignId"}})
	e.EncodeElement(&isNegative, xml.StartElement{Name: xml.Name{"", "isNegative"}})
	if err := criterionMarshalXML(cc.Criterion, e); err != nil {
		return err
	}
	if cc.BidModifier != nil {
		e.EncodeElement(&cc.BidModifier, xml.StartElement{Name: xml.Name{"", "bidModifier"}})
	}
	e.EncodeToken(start.End())
	return nil
}
Exemple #24
0
func (l *Ltxref) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	eltname := xml.Name{Local: "ltxref", Space: "urn:speedata.de:2015:latexref"}
	startelt := xml.StartElement{Name: eltname}
	startelt.Attr = append(startelt.Attr, xml.Attr{Name: xml.Name{Local: "version"}, Value: l.Version})

	e.Indent("", "  ")
	err := e.EncodeToken(startelt)
	if err != nil {
		return err
	}
	err = e.Encode(l.Commands)
	if err != nil {
		return err
	}
	err = e.Encode(l.Environments)
	if err != nil {
		return err
	}
	err = e.Encode(l.DocumentClasses)
	if err != nil {
		return err
	}

	err = e.Encode(l.Packages)
	if err != nil {
		return err
	}

	err = e.EncodeToken(xml.EndElement{Name: eltname})
	if err != nil {
		return err
	}

	if false {

		return errors.New("dummy error")
	}
	return nil
}
Exemple #25
0
func renderHtml(o otm.Object, log *testing.T) {
	buf := bytes.NewBufferString("<!DOCTYPE HTML>")
	e := xml.NewEncoder(buf)
	var obj func(otm.Object)
	obj = func(o otm.Object) {
		clazz := o.InstanceOf().Qualident()
		if clazz.Template == "html" {
			start := xml.StartElement{}
			start.Name.Local = clazz.Class
			if id := o.Qualident().Identifier; id != "" {
				attr := xml.Attr{}
				attr.Name.Local = "id"
				attr.Value = id
				start.Attr = append(start.Attr, attr)
			}
			e.EncodeToken(start)
			for _x := range o.Children() {
				switch x := _x.(type) {
				case otm.Object:
					obj(x)
				case string:
					e.EncodeToken(xml.CharData([]byte(x)))
				default:
					halt.As(100, reflect.TypeOf(x))
				}
			}
			e.EncodeToken(start.End())
		}
	}

	for x := range o.ChildrenObjects() {
		if x.InstanceOf().Qualident().Template == "html" && x.InstanceOf().Qualident().Class == "html" {
			obj(x)
		}
	}
	e.Flush()
	log.Log(buf.String())
}
func (s *MetaData) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
	var attributes []xml.Attr = make([]xml.Attr, 0)
	if s.Class != "" {
		attributes = append(attributes, xml.Attr{
			Name: xml.Name{
				Local: "class",
			},
			Value: s.Class,
		})
	}
	start.Attr = attributes
	tokens := []xml.Token{start}

	for key, value := range s.Map {
		t := xml.StartElement{Name: xml.Name{"", key}}
		tokens = append(tokens, t, xml.CharData(value), xml.EndElement{t.Name})
	}

	tokens = append(tokens, xml.EndElement{
		Name: start.Name,
	})

	for _, t := range tokens {
		err := e.EncodeToken(t)
		if err != nil {
			return err
		}
	}

	// flush to ensure tokens are written
	err := e.Flush()
	if err != nil {
		return err
	}

	return nil
}
Exemple #27
0
func setAttr(start *xml.StartElement, name, value string) {
	a := xml.Attr{}
	a.Name.Local = name
	a.Value = value
	start.Attr = append(start.Attr, a)
}
Exemple #28
0
func genSchema(commands *commandsxml.CommandsXML, lang string) ([]byte, error) {
	var outbuf bytes.Buffer

	enc := xml.NewEncoder(&outbuf)
	enc.Indent("", "   ")

	namespace := fmt.Sprintf("urn:speedata.de:2009/publisher/%s", lang)
	grammar := xml.StartElement{Name: xml.Name{Local: "grammar", Space: RELAXNG}}
	grammar.Attr = []xml.Attr{
		{Name: xml.Name{Local: "xmlns:a"}, Value: "http://relaxng.org/ns/compatibility/annotations/1.0"},
		{Name: xml.Name{Local: "xmlns:sch"}, Value: "http://purl.oclc.org/dsdl/schematron"},
		{Name: xml.Name{Local: "ns"}, Value: namespace},
		{Name: xml.Name{Local: "datatypeLibrary"}, Value: "http://www.w3.org/2001/XMLSchema-datatypes"},
	}

	enc.EncodeToken(xml.Comment("Do not edit this file. Auto generated from commands.xml with sphelper."))
	enc.EncodeToken(xml.CharData("\n"))
	enc.EncodeToken(grammar)
	sch := xml.StartElement{Name: xml.Name{Local: "sch:ns"}}
	sch.Attr = []xml.Attr{
		{Name: xml.Name{Local: "prefix"}, Value: "t"},
		{Name: xml.Name{Local: "uri"}, Value: namespace},
	}
	enc.EncodeToken(sch)
	enc.EncodeToken(sch.End())

	start := xml.StartElement{Name: xml.Name{Local: "start"}}
	enc.EncodeToken(start)

	choice := xml.StartElement{Name: xml.Name{Local: "choice"}}
	enc.EncodeToken(choice)

	refLayout := xml.StartElement{Name: xml.Name{Local: "ref"}}
	refLayout.Attr = []xml.Attr{{Name: xml.Name{Local: "name"}, Value: "e_Layout"}}
	refInclude := xml.StartElement{Name: xml.Name{Local: "ref"}}
	refInclude.Attr = []xml.Attr{{Name: xml.Name{Local: "name"}, Value: "e_Include"}}

	enc.EncodeToken(refLayout)
	enc.EncodeToken(refLayout.End())
	enc.EncodeToken(refInclude)
	enc.EncodeToken(refInclude.End())
	enc.EncodeToken(choice.End())
	enc.EncodeToken(start.End())

	attributeElement := xml.StartElement{Name: xml.Name{Local: "attribute"}}

	for _, cmd := range commands.Commands {
		enc.Flush()
		for _, r := range cmd.Rules {
			if r.Lang == lang {
				outbuf.WriteString(r.Rules)
			}
		}
		def := xml.StartElement{Name: xml.Name{Local: "define"}}
		def.Attr = []xml.Attr{{Name: xml.Name{Local: "name"}, Value: "e_" + cmd.En}}
		enc.EncodeToken(def)

		elt := xml.StartElement{Name: xml.Name{Local: "element"}}
		elt.Attr = []xml.Attr{{Name: xml.Name{Local: "name"}, Value: commands.TranslateCommand("en", lang, cmd.En)}}
		enc.EncodeToken(elt)

		doc := xml.StartElement{Name: xml.Name{Local: "a:documentation"}}
		enc.EncodeToken(doc)
		enc.EncodeToken(xml.CharData(cmd.GetCommandDescription(lang)))
		enc.EncodeToken(doc.End())
		for _, attr := range cmd.Attributes {
			if attr.Optional == "yes" {
				enc.EncodeToken(optionalElement.Copy())
			}

			attname, _ := commands.TranslateAttribute("en", lang, cmd.En, attr.En, "-")
			attelt := attributeElement.Copy()
			attelt.Attr = []xml.Attr{{Name: xml.Name{Local: "name"}, Value: attname}}
			enc.EncodeToken(attelt)

			doc := xml.StartElement{Name: xml.Name{Local: "a:documentation"}}
			enc.EncodeToken(doc)
			enc.EncodeToken(xml.CharData(attr.GetDescription(lang)))
			enc.EncodeToken(doc.End())

			if len(attr.Choice) > 0 {
				enc.EncodeToken(choiceElement.Copy())
				for _, choice := range attr.Choice {
					enc.EncodeToken(valueElement.Copy())
					enc.EncodeToken(xml.CharData(choice.GetValue(lang)))
					enc.EncodeToken(valueElement.End())

					doc := xml.StartElement{Name: xml.Name{Local: "a:documentation"}}
					enc.EncodeToken(doc)
					enc.EncodeToken(xml.CharData(choice.GetDescription(lang)))
					enc.EncodeToken(doc.End())

				}
				if attr.AllowXPath == "yes" {
					data := xml.StartElement{Name: xml.Name{Local: "data"}}
					data.Attr = []xml.Attr{{Name: xml.Name{Local: "type"}, Value: "string"}}
					enc.EncodeToken(data)
					param := xml.StartElement{Name: xml.Name{Local: "param"}}
					param.Attr = []xml.Attr{{Name: xml.Name{Local: "name"}, Value: "pattern"}}
					enc.EncodeToken(param)
					enc.EncodeToken(xml.CharData(`\{.+\}`))
					enc.EncodeToken(param.End())
					enc.EncodeToken(data.End())
				}

				enc.EncodeToken(choiceElement.End())
			}

			if attr.Reference.Name != "" {
				d := commands.DefineAttrs
				for _, attrdefinition := range d {
					if attr.Reference.Name == attrdefinition.Name {
						enc.EncodeToken(choiceElement.Copy())
						for _, choice := range attrdefinition.Choices {
							enc.EncodeToken(valueElement.Copy())
							enc.EncodeToken(xml.CharData(choice.GetValue(lang)))
							enc.EncodeToken(valueElement.End())

							doc := xml.StartElement{Name: xml.Name{Local: "a:documentation"}}
							enc.EncodeToken(doc)
							enc.EncodeToken(xml.CharData(choice.GetDescription(lang)))
							enc.EncodeToken(doc.End())

						}
						enc.EncodeToken(choiceElement.End())
					}
				}
				// 	attrsec := commands.GetDefineAttributes(attr.Reference.Name)
				// 	b := bytes.NewBuffer(attrsec)
				// 	d := xml.NewDecoder(b)
				// 	d.DecodeElement(cmd, start)

			}

			enc.EncodeToken(attelt.End())
			if attr.Optional == "yes" {
				enc.EncodeToken(optionalElement.Copy().End())
			}
		}
		getChildElements(commands, enc, cmd.Childelements.Text, lang)
		enc.EncodeToken(elt.End())
		enc.EncodeToken(def.End())
	}

	enc.EncodeToken(grammar.End())
	enc.EncodeToken(xml.CharData("\n"))
	enc.Flush()
	return outbuf.Bytes(), nil
}