// C14n Canonicalise the node using the SAML specified exclusive method // Very slow on large documents with node != nil func (xp *Xp) C14n(node *C.xmlNode) string { var buffer *C.xmlChar var nodeset *C.xmlNodeSet if node != nil { C.xmlXPathSetContextNode(node, xp.xpathCtx) xpathObj := C.xmlXPathEvalExpression(exclc14nxpath, xp.xpathCtx) defer C.xmlXPathFreeObject(xpathObj) nodeset = xpathObj.nodesetval //fmt.Printf("%+v\n", nodeset) } C.xmlC14NDocDumpMemory(xp.doc, nodeset, C.XML_C14N_EXCLUSIVE_1_0, nil, 0, &buffer) defer C.free(unsafe.Pointer(buffer)) p := (*C.char)(unsafe.Pointer(buffer)) return C.GoString(p) }
func (n *xmlNode) ToStringC14N(exclusive bool) (string, error) { var result *C.xmlChar var exclInt C.int if exclusive { exclInt = 1 } ret := C.xmlC14NDocDumpMemory( n.ptr.doc, nil, exclInt, nil, 0, &result, ) if ret == 0 { return "", errors.New("Boo") } return xmlCharToString(result), nil }