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
- Variables
- func HTMLReadDoc(content, url, encoding string, opts int) (uintptr, error)
- func ReportErrors(b bool)
- func SplitPrefixLocal(s string) (string, string)
- func XMLAddChild(n PtrSource, child PtrSource) error
- func XMLAppendText(n PtrSource, s string) error
- func XMLC14NDocDumpMemory(d PtrSource, mode int, withComments bool) (string, error)
- func XMLChildNodes(n PtrSource) ([]uintptr, error)
- func XMLCreateAttributeNS(doc PtrSource, uri, k, v string) (uintptr, error)
- func XMLCreateDocument(version, encoding string) uintptr
- func XMLCreateElement(d PtrSource, name string) (uintptr, error)
- func XMLCreateElementNS(doc PtrSource, nsuri, name string) (uintptr, error)
- func XMLCreateMemoryParserCtxt(s string, o int) (uintptr, error)
- func XMLCtxtReadMemory(ctx PtrSource, file string, baseURL string, encoding string, options int) (uintptr, error)
- func XMLDocCopyNode(n PtrSource, d PtrSource, extended int) (uintptr, error)
- func XMLDocumentElement(doc PtrSource) (uintptr, error)
- func XMLDocumentEncoding(doc PtrSource) string
- func XMLDocumentStandalone(doc PtrSource) int
- func XMLDocumentString(doc PtrSource, encoding string, format bool) string
- func XMLDocumentURI(doc PtrSource) string
- func XMLDocumentVersion(doc PtrSource) string
- func XMLElementAttributes(n PtrSource) ([]uintptr, error)
- func XMLElementGetAttributeNode(n PtrSource, name string) (uintptr, error)
- func XMLElementNamespaces(n PtrSource) ([]uintptr, error)
- func XMLEncodeEntitiesReentrant(docptr *C.xmlDoc, s string) (*C.xmlChar, error)
- func XMLEvalXPath(x PtrSource, expr PtrSource) (uintptr, error)
- func XMLFirstChild(n PtrSource) (uintptr, error)
- func XMLFreeDoc(doc PtrSource) error
- func XMLFreeNode(n PtrSource) error
- func XMLFreeParserCtxt(ctx PtrSource) error
- func XMLFreeProp(attr PtrSource) error
- func XMLHasChildNodes(n PtrSource) bool
- func XMLLastChild(n PtrSource) (uintptr, error)
- func XMLLocalName(n PtrSource) string
- func XMLLookupNamespacePrefix(n PtrSource, href string) (string, error)
- func XMLLookupNamespaceURI(n PtrSource, prefix string) (string, error)
- func XMLNamespaceFree(n PtrSource)
- func XMLNamespaceHref(n PtrSource) string
- func XMLNamespacePrefix(n PtrSource) string
- func XMLNamespaceURI(n PtrSource) string
- func XMLNewCDataBlock(doc PtrSource, txt string) (uintptr, error)
- func XMLNewComment(txt string) (uintptr, error)
- func XMLNewDocNode(doc PtrSource, ns PtrSource, local, content string) (uintptr, error)
- func XMLNewDocProp(doc PtrSource, k, v string) (uintptr, error)
- func XMLNewNode(ns PtrSource, name string) (uintptr, error)
- func XMLNewNs(n PtrSource, nsuri, prefix string) (uintptr, error)
- func XMLNewText(txt string) (uintptr, error)
- func XMLNextSibling(n PtrSource) (uintptr, error)
- func XMLNodeName(n PtrSource) (string, error)
- func XMLNodeSetBase(doc PtrSource, s string)
- func XMLNodeValue(n PtrSource) (string, error)
- func XMLOwnerDocument(n PtrSource) (uintptr, error)
- func XMLParentNode(n PtrSource) (uintptr, error)
- func XMLParseDocument(ctx PtrSource) error
- func XMLParseInNodeContext(n PtrSource, data string, o int) (uintptr, error)
- func XMLPrefix(n PtrSource) string
- func XMLPreviousSibling(n PtrSource) (uintptr, error)
- func XMLRemoveChild(n PtrSource, t PtrSource) error
- func XMLSchemaFree(s PtrSource) error
- func XMLSchemaParse(buf []byte, options ...option.Interface) (uintptr, error)
- func XMLSchemaParseFromFile(path string) (uintptr, error)
- func XMLSchemaValidateDocument(schema PtrSource, document PtrSource, options ...int) []error
- func XMLSearchNs(doc PtrSource, n PtrSource, prefix string) (uintptr, error)
- func XMLSearchNsByHref(doc PtrSource, n PtrSource, uri string) (uintptr, error)
- func XMLSetDocumentElement(doc PtrSource, n PtrSource) error
- func XMLSetDocumentEncoding(doc PtrSource, e string)
- func XMLSetDocumentStandalone(doc PtrSource, v int)
- func XMLSetDocumentVersion(doc PtrSource, v string)
- func XMLSetNodeName(n PtrSource, name string) error
- func XMLSetNodeValue(n PtrSource, value string) error
- func XMLSetNs(n PtrSource, ns PtrSource) error
- func XMLSetProp(n PtrSource, name, value string) error
- func XMLSetTreeDoc(n PtrSource, d PtrSource) error
- func XMLTextContent(n PtrSource) string
- func XMLTextData(n PtrSource) string
- func XMLToString(n PtrSource, format int, docencoding bool) string
- func XMLUnsetNsProp(n PtrSource, ns PtrSource, name string) error
- func XMLUnsetProp(n PtrSource, name string) error
- func XMLXPathCompile(s string) (uintptr, error)
- func XMLXPathContextSetContextNode(x PtrSource, n PtrSource) error
- func XMLXPathFreeCompExpr(x PtrSource) error
- func XMLXPathFreeContext(x PtrSource) error
- func XMLXPathFreeObject(x PtrSource)
- func XMLXPathNSLookup(x PtrSource, prefix string) (string, error)
- func XMLXPathNewContext(n PtrSource) (uintptr, error)
- func XMLXPathObjectBool(x PtrSource) bool
- func XMLXPathObjectFloat64(x PtrSource) float64
- func XMLXPathObjectNodeList(x PtrSource) ([]uintptr, error)
- func XMLXPathObjectNodeListLen(x PtrSource) int
- func XMLXPathRegisterNS(x PtrSource, prefix, nsuri string) error
- type C14NMode
- type ErrNamespaceNotFound
- type PtrSource
- type XMLNodeType
- type XPathObjectType
Constants ¶
const ( MaxEncodingLength = 256 MaxAttributeNameLength = 1024 MaxElementNameLength = 1024 MaxNamespaceURILength = 4096 MaxValueBufferSize = 4096 MaxXPathExpressionLength = 4096 )
Variables ¶
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 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 XMLAddChild ¶
func XMLAppendText ¶
func XMLC14NDocDumpMemory ¶
func XMLChildNodes ¶
func XMLCreateAttributeNS ¶
func XMLCreateDocument ¶
func XMLCreateElementNS ¶
func XMLCtxtReadMemory ¶
func XMLDocumentElement ¶
func XMLDocumentEncoding ¶
func XMLDocumentStandalone ¶
func XMLDocumentURI ¶
func XMLDocumentVersion ¶
func XMLElementAttributes ¶
func XMLElementNamespaces ¶
func XMLFirstChild ¶
func XMLFreeDoc ¶
func XMLFreeNode ¶
func XMLFreeParserCtxt ¶
func XMLFreeProp ¶
func XMLHasChildNodes ¶
func XMLLastChild ¶
func XMLLocalName ¶
func XMLNamespaceFree ¶
func XMLNamespaceFree(n PtrSource)
func XMLNamespaceHref ¶
func XMLNamespacePrefix ¶
func XMLNamespaceURI ¶
func XMLNewComment ¶
func XMLNewDocNode ¶
func XMLNewText ¶
func XMLNextSibling ¶
func XMLNodeName ¶
func XMLNodeSetBase ¶
func XMLNodeValue ¶
func XMLOwnerDocument ¶
func XMLParentNode ¶
func XMLParseDocument ¶
func XMLParseInNodeContext ¶
func XMLPreviousSibling ¶
func XMLRemoveChild ¶
func XMLSchemaFree ¶
func XMLSchemaParseFromFile ¶
func XMLSearchNsByHref ¶
func XMLSetDocumentElement ¶
func XMLSetDocumentEncoding ¶
func XMLSetDocumentVersion ¶
func XMLSetNodeName ¶
func XMLSetNodeValue ¶
func XMLSetProp ¶
func XMLSetTreeDoc ¶
func XMLTextContent ¶
func XMLTextData ¶
func XMLUnsetProp ¶
func XMLXPathCompile ¶
func XMLXPathFreeCompExpr ¶
func XMLXPathFreeContext ¶
func XMLXPathFreeObject ¶
func XMLXPathFreeObject(x PtrSource)
func XMLXPathNewContext ¶
func XMLXPathObjectBool ¶
func XMLXPathObjectFloat64 ¶
func XMLXPathObjectNodeList ¶
func XMLXPathRegisterNS ¶
Types ¶
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