Example #1
0
func (e *Encoder) encodeCharData(el xml.CharData) error {
	if e.currentElement != nil {
		if strings.Trim(fmt.Sprintf("%s", el), " \n\r\t") != "" {
			e.currentElement.AddContent(el.Copy())
		}
	}
	return nil
}
Example #2
0
// ReplaceCDATAIf replaces CDATA value of the matched node
// if the parent node name matches the name
func ReplaceCDATAIf(val xml.CharData, cond ConditionFunc) TransformFunc {
	return func(parents *NodeList, in xml.Token) []xml.Token {
		switch in.(type) {
		case xml.CharData:
			if cond(parents, in) {
				return []xml.Token{val.Copy()}
			}
		}
		return []xml.Token{in}
	}
}
Example #3
0
func newText(token xml.CharData) *_text {
	n := newNode(TEXT_NODE)
	t := &_text{_cdata{n, token.Copy()}}
	n.self = Node(t)
	return t
}
Example #4
0
func newCData(token xml.CharData) *_cdata {
	n := newNode(CDATA_SECTION_NODE)
	cd := &_cdata{n, token.Copy()}
	n.self = Node(cd)
	return cd
}