Documentation ¶
Index ¶
- Constants
- Variables
- func NSDetatch(ctx NSContext, el *etree.Element) (*etree.Element, error)
- func NSFindIterate(el *etree.Element, namespace, tag string, handle NSIterHandler) error
- func NSFindIterateCtx(ctx NSContext, el *etree.Element, namespace, tag string, handle NSIterHandler) error
- func NSFindOne(el *etree.Element, namespace, tag string) (*etree.Element, error)
- func NSFindOneCtx(ctx NSContext, el *etree.Element, namespace, tag string) (*etree.Element, error)
- func NSSelectOne(el *etree.Element, namespace, tag string) (*etree.Element, error)
- func NSSelectOneCtx(ctx NSContext, el *etree.Element, namespace, tag string) (*etree.Element, error)
- func NSTraverse(ctx NSContext, el *etree.Element, handle NSIterHandler) error
- func NSUnmarshalElement(ctx NSContext, el *etree.Element, v interface{}) error
- func TransformExcC14n(el *etree.Element, inclusiveNamespacesPrefixList string) error
- type ElementKeeper
- type ErrUndeclaredNSPrefix
- type NSContext
- type NSIterHandler
- type SortedAttrs
Constants ¶
const ( XMLNamespace = "http://www.w3.org/XML/1998/namespace" XMLNSNamespace = "http://www.w3.org/2000/xmlns/" )
Variables ¶
var ( DefaultNSContext = NSContext{ // contains filtered or unexported fields } EmptyNSContext = NSContext{} ErrReservedNamespace = errors.New("disallowed declaration of reserved namespace") ErrInvalidDefaultNamespace = errors.New("invalid default namespace declaration") ErrTraversalHalted = errors.New("traversal halted") )
Functions ¶
func NSDetatch ¶
NSDetatch makes a copy of the passed element, and declares any namespaces in the passed context onto the new element before returning it.
func NSFindIterate ¶
func NSFindIterate(el *etree.Element, namespace, tag string, handle NSIterHandler) error
NSFindIterate behaves identically to NSFindIterateCtx, but uses DefaultNSContext as the surrounding context.
func NSFindIterateCtx ¶
func NSFindIterateCtx(ctx NSContext, el *etree.Element, namespace, tag string, handle NSIterHandler) error
NSFindIterateCtx conducts a depth-first traversal searching for elements with the specified tag in the specified namespace. It uses the passed NSContext for prefix lookups. For each such element, the passed handler function is invoked. If the handler function returns an error traversal is immediately halted. If the error returned by the handler is ErrTraversalHalted then nil will be returned by NSFindIterate. If any other error is returned by the handler, that error will be returned by NSFindIterate.
func NSFindOne ¶
NSFindOne behaves identically to NSFindOneCtx, but uses DefaultNSContext for context.
func NSFindOneCtx ¶
NSFindOneCtx conducts a depth-first search for the specified element. If such an element is found a reference to it is returned.
func NSSelectOne ¶
NSSelectOne behaves identically to NSSelectOneCtx, but uses DefaultNSContext as the surrounding context.
func NSSelectOneCtx ¶
func NSSelectOneCtx(ctx NSContext, el *etree.Element, namespace, tag string) (*etree.Element, error)
NSSelectOneCtx conducts a depth-first search for an element with the specified namespace and tag. If such an element is found, a new *etree.Element is returned which is a copy of the found element, but with all in-context namespace declarations attached to the element as attributes.
func NSTraverse ¶
func NSTraverse(ctx NSContext, el *etree.Element, handle NSIterHandler) error
NSTraverse traverses an element tree, invoking the passed handler for each element in the tree.
func NSUnmarshalElement ¶
NSUnmarshalElement unmarshals the passed etree Element into the value pointed to by v using encoding/xml in the context of the passed NSContext. If v implements ElementKeeper, SetUnderlyingElement will be called on v with a reference to el.
Types ¶
type ElementKeeper ¶
type ElementKeeper interface { SetUnderlyingElement(*etree.Element) UnderlyingElement() *etree.Element }
ElementKeeper should be implemented by types which will be passed to UnmarshalElement, but wish to keep a reference
type ErrUndeclaredNSPrefix ¶
type ErrUndeclaredNSPrefix struct {
Prefix string
}
func (ErrUndeclaredNSPrefix) Error ¶
func (e ErrUndeclaredNSPrefix) Error() string
type NSContext ¶
type NSContext struct {
// contains filtered or unexported fields
}
func NSBuildParentContext ¶
NSBuildParentContext recurses upward from an element in order to build an NSContext for its immediate parent. If the element has no parent DefaultNSContext is returned.
func (NSContext) LookupPrefix ¶
LookupPrefix attempts to find a declared namespace for the specified prefix. If the prefix is an empty string this will be the default namespace for this context. If the prefix is undeclared in this context an ErrUndeclaredNSPrefix will be returned.
type NSIterHandler ¶
NSIterHandler is a function which is invoked with a element and its surrounding NSContext during traversals.
type SortedAttrs ¶
SortedAttrs provides sorting capabilities, compatible with XML C14N, on top of an []etree.Attr
func (SortedAttrs) Len ¶
func (a SortedAttrs) Len() int
func (SortedAttrs) Less ¶
func (a SortedAttrs) Less(i, j int) bool
func (SortedAttrs) Swap ¶
func (a SortedAttrs) Swap(i, j int)