clib

package
v0.0.0-...-e6d9de6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package clib holds all of the dirty C interaction for go-libxml2.

Although this package is visible to the outside world, the API in this package is in NO WAY guaranteed to be stable. This package was initially meant to be placed in an internal package so that the API was not available to the outside world.

The only reason this is visible is so that the REALLY advanced users can abuse the quasi-direct-C-API to overcome shortcomings of the "public" API, if any (and of course, you WILL send me a pull request later... won't you?)

Please DO NOT rely on this API and expect that it will keep backcompat. When the need arises, it WILL be changed, and if you are not ready for it, your code WILL break in horrible horrible ways. You have been warned.

Index

Constants

View Source
const (
	MaxEncodingLength        = 256
	MaxAttributeNameLength   = 1024
	MaxElementNameLength     = 1024
	MaxNamespaceURILength    = 4096
	MaxValueBufferSize       = 4096
	MaxXPathExpressionLength = 4096
)

Variables

View Source
var (
	ErrAttributeNotFound      = errors.New("attribute not found")
	ErrAttributeNameTooLong   = errors.New("attribute name too long")
	ErrElementNameTooLong     = errors.New("element name too long")
	ErrNamespaceURITooLong    = errors.New("namespace uri too long")
	ErrValueTooLong           = errors.New("value too long")
	ErrXPathExpressionTooLong = errors.New("xpath expression too long")
	// ErrInvalidAttribute is returned when the Attribute struct (probably
	// the pointer to the underlying C struct is not valid)
	ErrInvalidAttribute = errors.New("invalid attribute")
	ErrInvalidArgument  = errors.New("invalid argument")
	// ErrInvalidDocument is returned when the Document struct (probably
	// the pointer to the underlying C struct is not valid)
	ErrInvalidDocument = errors.New("invalid document")
	// ErrInvalidParser is returned when the Parser struct (probably
	// the pointer to the underlying C struct is not valid)
	ErrInvalidParser = errors.New("invalid parser")
	// ErrInvalidNamespace is returned when the Namespace struct (probably
	// the pointer to the underlying C struct is not valid)
	ErrInvalidNamespace = errors.New("invalid namespace")
	// ErrInvalidNode is returned when the Node struct (probably
	// the pointer to the underlying C struct is not valid)
	ErrInvalidNode     = errors.New("invalid node")
	ErrInvalidNodeName = errors.New("invalid node name")
	// ErrInvalidXPathContext is returned when the XPathContext struct (probably
	// the pointer to the underlying C struct is not valid)
	ErrInvalidXPathContext = errors.New("invalid xpath context")
	// ErrInvalidXPathExpression is returned when the XPathExpression struct (probably
	// the pointer to the underlying C struct is not valid)
	ErrInvalidXPathExpression = errors.New("invalid xpath expression")
	// ErrInvalidXPathObject is returned when the XPathObject struct (probably
	// the pointer to the underlying C struct is not valid)
	ErrInvalidXPathObject = errors.New("invalid xpath object")
	// ErrInvalidSchema is returned when the Schema struct (probably
	// the pointer to the underlying C struct is not valid)
	ErrInvalidSchema                 = errors.New("invalid schema")
	ErrNodeNotFound                  = errors.New("node not found")
	ErrXPathEmptyResult              = errors.New("empty xpath result")
	ErrXPathCompileFailure           = errors.New("xpath compilation failed")
	ErrXPathNamespaceRegisterFailure = errors.New("cannot register namespace")
)

Functions

func HTMLReadDoc

func HTMLReadDoc(content, url, encoding string, opts int) (uintptr, error)

func ReportErrors

func ReportErrors(b bool)

ReportErrors *globally* changes the behavior of reporting errors. By default libxml2 spews out lots of data to stderr. When you call this function with a `false` value, all those messages are surpressed. When you call this function a `true` value, the default behavior is restored

func SplitPrefixLocal

func SplitPrefixLocal(s string) (string, string)

func XMLAddChild

func XMLAddChild(n PtrSource, child PtrSource) error

func XMLAppendText

func XMLAppendText(n PtrSource, s string) error

func XMLC14NDocDumpMemory

func XMLC14NDocDumpMemory(d PtrSource, mode int, withComments bool) (string, error)

func XMLChildNodes

func XMLChildNodes(n PtrSource) ([]uintptr, error)

func XMLCreateAttributeNS

func XMLCreateAttributeNS(doc PtrSource, uri, k, v string) (uintptr, error)

func XMLCreateDocument

func XMLCreateDocument(version, encoding string) uintptr

func XMLCreateElement

func XMLCreateElement(d PtrSource, name string) (uintptr, error)

func XMLCreateElementNS

func XMLCreateElementNS(doc PtrSource, nsuri, name string) (uintptr, error)

func XMLCreateMemoryParserCtxt

func XMLCreateMemoryParserCtxt(s string, o int) (uintptr, error)

func XMLCtxtReadMemory

func XMLCtxtReadMemory(ctx PtrSource, file string, baseURL string, encoding string, options int) (uintptr, error)

func XMLDocCopyNode

func XMLDocCopyNode(n PtrSource, d PtrSource, extended int) (uintptr, error)

func XMLDocumentElement

func XMLDocumentElement(doc PtrSource) (uintptr, error)

func XMLDocumentEncoding

func XMLDocumentEncoding(doc PtrSource) string

func XMLDocumentStandalone

func XMLDocumentStandalone(doc PtrSource) int

func XMLDocumentString

func XMLDocumentString(doc PtrSource, encoding string, format bool) string

func XMLDocumentURI

func XMLDocumentURI(doc PtrSource) string

func XMLDocumentVersion

func XMLDocumentVersion(doc PtrSource) string

func XMLElementAttributes

func XMLElementAttributes(n PtrSource) ([]uintptr, error)

func XMLElementGetAttributeNode

func XMLElementGetAttributeNode(n PtrSource, name string) (uintptr, error)

func XMLElementNamespaces

func XMLElementNamespaces(n PtrSource) ([]uintptr, error)

func XMLEncodeEntitiesReentrant

func XMLEncodeEntitiesReentrant(docptr *C.xmlDoc, s string) (*C.xmlChar, error)

func XMLEvalXPath

func XMLEvalXPath(x PtrSource, expr PtrSource) (uintptr, error)

func XMLFirstChild

func XMLFirstChild(n PtrSource) (uintptr, error)

func XMLFreeDoc

func XMLFreeDoc(doc PtrSource) error

func XMLFreeNode

func XMLFreeNode(n PtrSource) error

func XMLFreeParserCtxt

func XMLFreeParserCtxt(ctx PtrSource) error

func XMLFreeProp

func XMLFreeProp(attr PtrSource) error

func XMLHasChildNodes

func XMLHasChildNodes(n PtrSource) bool

func XMLLastChild

func XMLLastChild(n PtrSource) (uintptr, error)

func XMLLocalName

func XMLLocalName(n PtrSource) string

func XMLLookupNamespacePrefix

func XMLLookupNamespacePrefix(n PtrSource, href string) (string, error)

func XMLLookupNamespaceURI

func XMLLookupNamespaceURI(n PtrSource, prefix string) (string, error)

func XMLNamespaceFree

func XMLNamespaceFree(n PtrSource)

func XMLNamespaceHref

func XMLNamespaceHref(n PtrSource) string

func XMLNamespacePrefix

func XMLNamespacePrefix(n PtrSource) string

func XMLNamespaceURI

func XMLNamespaceURI(n PtrSource) string

func XMLNewCDataBlock

func XMLNewCDataBlock(doc PtrSource, txt string) (uintptr, error)

func XMLNewComment

func XMLNewComment(txt string) (uintptr, error)

func XMLNewDocNode

func XMLNewDocNode(doc PtrSource, ns PtrSource, local, content string) (uintptr, error)

func XMLNewDocProp

func XMLNewDocProp(doc PtrSource, k, v string) (uintptr, error)

func XMLNewNode

func XMLNewNode(ns PtrSource, name string) (uintptr, error)

func XMLNewNs

func XMLNewNs(n PtrSource, nsuri, prefix string) (uintptr, error)

func XMLNewText

func XMLNewText(txt string) (uintptr, error)

func XMLNextSibling

func XMLNextSibling(n PtrSource) (uintptr, error)

func XMLNodeName

func XMLNodeName(n PtrSource) (string, error)

func XMLNodeSetBase

func XMLNodeSetBase(doc PtrSource, s string)

func XMLNodeValue

func XMLNodeValue(n PtrSource) (string, error)

func XMLOwnerDocument

func XMLOwnerDocument(n PtrSource) (uintptr, error)

func XMLParentNode

func XMLParentNode(n PtrSource) (uintptr, error)

func XMLParseDocument

func XMLParseDocument(ctx PtrSource) error

func XMLParseInNodeContext

func XMLParseInNodeContext(n PtrSource, data string, o int) (uintptr, error)

func XMLPrefix

func XMLPrefix(n PtrSource) string

func XMLPreviousSibling

func XMLPreviousSibling(n PtrSource) (uintptr, error)

func XMLRemoveChild

func XMLRemoveChild(n PtrSource, t PtrSource) error

func XMLSchemaFree

func XMLSchemaFree(s PtrSource) error

func XMLSchemaParse

func XMLSchemaParse(buf []byte, options ...option.Interface) (uintptr, error)

func XMLSchemaParseFromFile

func XMLSchemaParseFromFile(path string) (uintptr, error)

func XMLSchemaValidateDocument

func XMLSchemaValidateDocument(schema PtrSource, document PtrSource, options ...int) []error

func XMLSearchNs

func XMLSearchNs(doc PtrSource, n PtrSource, prefix string) (uintptr, error)

func XMLSearchNsByHref

func XMLSearchNsByHref(doc PtrSource, n PtrSource, uri string) (uintptr, error)

func XMLSetDocumentElement

func XMLSetDocumentElement(doc PtrSource, n PtrSource) error

func XMLSetDocumentEncoding

func XMLSetDocumentEncoding(doc PtrSource, e string)

func XMLSetDocumentStandalone

func XMLSetDocumentStandalone(doc PtrSource, v int)

func XMLSetDocumentVersion

func XMLSetDocumentVersion(doc PtrSource, v string)

func XMLSetNodeName

func XMLSetNodeName(n PtrSource, name string) error

func XMLSetNodeValue

func XMLSetNodeValue(n PtrSource, value string) error

func XMLSetNs

func XMLSetNs(n PtrSource, ns PtrSource) error

func XMLSetProp

func XMLSetProp(n PtrSource, name, value string) error

func XMLSetTreeDoc

func XMLSetTreeDoc(n PtrSource, d PtrSource) error

func XMLTextContent

func XMLTextContent(n PtrSource) string

func XMLTextData

func XMLTextData(n PtrSource) string

func XMLToString

func XMLToString(n PtrSource, format int, docencoding bool) string

func XMLUnsetNsProp

func XMLUnsetNsProp(n PtrSource, ns PtrSource, name string) error

func XMLUnsetProp

func XMLUnsetProp(n PtrSource, name string) error

func XMLXPathCompile

func XMLXPathCompile(s string) (uintptr, error)

func XMLXPathContextSetContextNode

func XMLXPathContextSetContextNode(x PtrSource, n PtrSource) error

func XMLXPathFreeCompExpr

func XMLXPathFreeCompExpr(x PtrSource) error

func XMLXPathFreeContext

func XMLXPathFreeContext(x PtrSource) error

func XMLXPathFreeObject

func XMLXPathFreeObject(x PtrSource)

func XMLXPathNSLookup

func XMLXPathNSLookup(x PtrSource, prefix string) (string, error)

func XMLXPathNewContext

func XMLXPathNewContext(n PtrSource) (uintptr, error)

func XMLXPathObjectBool

func XMLXPathObjectBool(x PtrSource) bool

func XMLXPathObjectFloat64

func XMLXPathObjectFloat64(x PtrSource) float64

func XMLXPathObjectNodeList

func XMLXPathObjectNodeList(x PtrSource) ([]uintptr, error)

func XMLXPathObjectNodeListLen

func XMLXPathObjectNodeListLen(x PtrSource) int

func XMLXPathRegisterNS

func XMLXPathRegisterNS(x PtrSource, prefix, nsuri string) error

Types

type C14NMode

type C14NMode int

C14NMode represents the C14N mode supported by libxml2

type ErrNamespaceNotFound

type ErrNamespaceNotFound struct {
	Target string
}

func (ErrNamespaceNotFound) Error

func (e ErrNamespaceNotFound) Error() string

type PtrSource

type PtrSource interface {
	Pointer() uintptr
}

PtrSource is the single interface that connects the rest of libxml2 package with this pacakge. The clib packages does not really care what sort of object you pass to these low-level functions, as long as the arguments fulfill this interface.

Obviously this causes problems if you pass the an Element node where a Document node is expected, but it is the caller's responsibility to align the argument list.

type XMLNodeType

type XMLNodeType int

XMLNodeType identifies the type of the underlying C struct

const (
	ElementNode XMLNodeType = iota + 1
	AttributeNode
	TextNode
	CDataSectionNode
	EntityRefNode
	EntityNode
	PiNode
	CommentNode
	DocumentNode
	DocumentTypeNode
	DocumentFragNode
	NotationNode
	HTMLDocumentNode
	DTDNode
	ElementDecl
	AttributeDecl
	EntityDecl
	NamespaceDecl
	XIncludeStart
	XIncludeEnd
	DocbDocumentNode
)

func XMLGetNodeType

func XMLGetNodeType(n PtrSource) XMLNodeType

func XMLGetNodeTypeRaw

func XMLGetNodeTypeRaw(n uintptr) XMLNodeType

func (XMLNodeType) String

func (i XMLNodeType) String() string

String returns the string representation of this XMLNodeType

type XPathObjectType

type XPathObjectType int
const (
	XPathUndefinedType XPathObjectType = iota
	XPathNodeSetType
	XPathBooleanType
	XPathNumberType
	XPathStringType
	XPathPointType
	XPathRangeType
	XPathLocationSetType
	XPathUsersType
	XPathXSLTTreeType
)

func XMLXPathObjectType

func XMLXPathObjectType(x PtrSource) XPathObjectType

func (XPathObjectType) String

func (i XPathObjectType) String() string

String returns the stringified version of XPathObjectType

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL