Documentation ¶
Overview ¶
Copyright 2015 Gravitational, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- func GetAttribute(e xml.StartElement, name xml.Name) string
- func HasAttribute(e xml.StartElement, name xml.Name) bool
- func Name(name string) xml.Name
- func NameEquals(a, b xml.Name) bool
- func SetAttribute(e xml.StartElement, name, value string) xml.StartElement
- func TransformXML(decoder *xml.Decoder, encoder *xml.Encoder, fn TransformFunc) error
- func TrimSpace(parents *NodeList, in xml.Token) []xml.Token
- type ConditionFunc
- type NodeList
- type TransformFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAttribute ¶
func GetAttribute(e xml.StartElement, name xml.Name) string
GetAttribute returns attribute value if it's present, otherwise it returns an empty string
func HasAttribute ¶
func HasAttribute(e xml.StartElement, name xml.Name) bool
HasAttribute returns true if element has an attribute with given name, false otherwise
func NameEquals ¶
NameEquals return true if both namespaces and local names of nodes match, and false otherwise
func SetAttribute ¶
func SetAttribute(e xml.StartElement, name, value string) xml.StartElement
SetAttribute is XML helper that allows to set attribute on a node
func TransformXML ¶
TransformXML parses the XML tree, traverses it and calls TransformFunc on each XML token, writing the output to the writer, resulting in a transformed XML tree
Types ¶
type ConditionFunc ¶
ConditionFunc is accepted by some transform function generators so they could be applied conditionally
func ParentIs ¶
func ParentIs(name xml.Name) ConditionFunc
ParentIs is a functon that returns ConditionFunc checking if immediate parent's name matches name
type NodeList ¶
type NodeList struct {
// contains filtered or unexported fields
}
func (*NodeList) ParentIs ¶
ParentIs returns true if last element exists and it's name equals to this name
func (*NodeList) Push ¶
func (n *NodeList) Push(node xml.StartElement)
type TransformFunc ¶
TransofrmFunc is a function that can transform incoming token into a series of outgoing tokens when traversing XML tree
func Combine ¶
func Combine(funcs ...TransformFunc) TransformFunc
Combine takes a list of TransformFuncs and converts them into a single transform function applying all functions one by one
func InjectNodesIf ¶
func InjectNodesIf(nodes []xml.Token, cond ConditionFunc) TransformFunc
InjectNodes injects nodes at the end of the tag that matches name
func ReplaceAttributeIf ¶
func ReplaceAttributeIf(attrName, attrValue string, cond ConditionFunc) TransformFunc
ReplaceAttribute replaces the attribute of the first node that matches the name
func ReplaceCDATAIf ¶
func ReplaceCDATAIf(val xml.CharData, cond ConditionFunc) TransformFunc
ReplaceCDATAIf replaces CDATA value of the matched node if the parent node name matches the name