Datum xpath_bool(PG_FUNCTION_ARGS) { xmlChar *xpath; int32 pathsize; text *xpathsupp; int bRes; xmlXPathObjectPtr res; /* PG_GETARG_TEXT_P(0) is document buffer */ xpathsupp = PG_GETARG_TEXT_P(1); /* XPath expression */ pathsize = VARSIZE(xpathsupp) - VARHDRSZ; xpath = pgxml_texttoxmlchar(xpathsupp); res = pgxml_xpath(PG_GETARG_TEXT_P(0), xpath); pfree(xpath); if (res == NULL) PG_RETURN_BOOL(false); bRes = xmlXPathCastToBoolean(res); PG_RETURN_BOOL(bRes); }
Datum xpath_bool(PG_FUNCTION_ARGS) { text *document = PG_GETARG_TEXT_P(0); text *xpathsupp = PG_GETARG_TEXT_P(1); /* XPath expression */ xmlChar *xpath; int bRes; xmlXPathObjectPtr res; xpath_workspace workspace; xpath = pgxml_texttoxmlchar(xpathsupp); res = pgxml_xpath(document, xpath, &workspace); pfree(xpath); if (res == NULL) PG_RETURN_BOOL(false); bRes = xmlXPathCastToBoolean(res); cleanup_workspace(&workspace); PG_RETURN_BOOL(bRes); }
// --------------------------------------------------------------------------- // Retrieves numeric value of the result. // Conversion occurs as XPath spec says if the result is not of EBoolean type // --------------------------------------------------------------------------- // EXPORT_C TBool RXmlEngXPathResult::AsBoolean() const { if (RESULT_OBJ->type == XPATH_BOOLEAN) return RESULT_OBJ->boolval; else return xmlXPathCastToBoolean(RESULT_OBJ); }