本文整理汇总了C++中xsltGenericError函数的典型用法代码示例。如果您正苦于以下问题:C++ xsltGenericError函数的具体用法?C++ xsltGenericError怎么用?C++ xsltGenericError使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xsltGenericError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: exsltDynEvaluateFunction
static void
exsltDynEvaluateFunction(xmlXPathParserContextPtr ctxt, int nargs) {
xmlChar *str = NULL;
xmlXPathObjectPtr ret = NULL;
if (ctxt == NULL)
return;
if (nargs != 1) {
xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"dyn:evalute() : invalid number of args %d\n", nargs);
ctxt->error = XPATH_INVALID_ARITY;
return;
}
str = xmlXPathPopString(ctxt);
if (!str||!xmlStrlen(str)) {
if (str) xmlFree(str);
valuePush(ctxt,xmlXPathNewNodeSet(NULL));
return;
}
ret = xmlXPathEval(str,ctxt->context);
if (ret)
valuePush(ctxt,ret);
else {
xsltGenericError(xsltGenericErrorContext,
"dyn:evaluate() : unable to evaluate expression '%s'\n",str);
valuePush(ctxt,xmlXPathNewNodeSet(NULL));
}
xmlFree(str);
return;
}
示例2: xsltResolveSASCallbackInt
/**
* xsltResolveSASCallbackInt:
* @style: the XSLT stylesheet
*
* resolve the references in an attribute set.
*/
static void
xsltResolveSASCallbackInt(xsltAttrElemPtr values, xsltStylesheetPtr style,
const xmlChar *name, const xmlChar *ns,
int depth) {
xsltAttrElemPtr tmp;
xsltAttrElemPtr refs;
tmp = values;
if ((name == NULL) || (name[0] == 0))
return;
if (depth > 100) {
xsltGenericError(xsltGenericErrorContext,
"xsl:attribute-set : use-attribute-sets recursion detected on %s\n",
name);
return;
}
while (tmp != NULL) {
if (tmp->set != NULL) {
/*
* Check against cycles !
*/
if ((xmlStrEqual(name, tmp->set)) && (xmlStrEqual(ns, tmp->ns))) {
xsltGenericError(xsltGenericErrorContext,
"xsl:attribute-set : use-attribute-sets recursion detected on %s\n",
name);
} else {
#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
xsltGenericDebug(xsltGenericDebugContext,
"Importing attribute list %s\n", tmp->set);
#endif
refs = xsltGetSAS(style, tmp->set, tmp->ns);
if (refs == NULL) {
xsltGenericError(xsltGenericErrorContext,
"xsl:attribute-set : use-attribute-sets %s reference missing %s\n",
name, tmp->set);
} else {
/*
* recurse first for cleanup
*/
xsltResolveSASCallbackInt(refs, style, name, ns, depth + 1);
/*
* Then merge
*/
xsltMergeAttrElemList(style, values, refs);
/*
* Then suppress the reference
*/
tmp->set = NULL;
tmp->ns = NULL;
}
}
}
tmp = tmp->next;
}
}
示例3: xsltGenerateIdFunction
/**
* xsltGenerateIdFunction:
* @ctxt: the XPath Parser context
* @nargs: the number of arguments
*
* Implement the generate-id() XSLT function
* string generate-id(node-set?)
*/
void
xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs){
xmlNodePtr cur = NULL;
unsigned long val;
xmlChar str[20];
if (nargs == 0) {
cur = ctxt->context->node;
} else if (nargs == 1) {
xmlXPathObjectPtr obj;
xmlNodeSetPtr nodelist;
int i, ret;
if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_NODESET)) {
ctxt->error = XPATH_INVALID_TYPE;
xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt),
NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"generate-id() : invalid arg expecting a node-set\n");
return;
}
obj = valuePop(ctxt);
nodelist = obj->nodesetval;
if ((nodelist == NULL) || (nodelist->nodeNr <= 0)) {
xmlXPathFreeObject(obj);
valuePush(ctxt, xmlXPathNewCString(""));
return;
}
cur = nodelist->nodeTab[0];
for (i = 1;i < nodelist->nodeNr;i++) {
ret = xmlXPathCmpNodes(cur, nodelist->nodeTab[i]);
if (ret == -1)
cur = nodelist->nodeTab[i];
}
xmlXPathFreeObject(obj);
} else {
xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"generate-id() : invalid number of args %d\n", nargs);
ctxt->error = XPATH_INVALID_ARITY;
return;
}
/*
* Okay this is ugly but should work, use the NodePtr address
* to forge the ID
*/
val = (unsigned long)((char *)cur - (char *)0);
val /= sizeof(xmlNode);
sprintf((char *)str, "id%ld", val);
valuePush(ctxt, xmlXPathNewString(str));
}
示例4: exsltFuncRegisterImportFunc
/*
* exsltFuncRegisterImportFunc
* @data: the exsltFuncFunctionData for the function
* @ch: structure containing context and hash table
* @URI: the function namespace URI
* @name: the function name
*
* Checks if imported function is already registered in top-level
* stylesheet. If not, copies function data and registers function
*/
static void
exsltFuncRegisterImportFunc (exsltFuncFunctionData *data,
exsltFuncImportRegData *ch,
const xmlChar *URI, const xmlChar *name,
ATTRIBUTE_UNUSED const xmlChar *ignored) {
exsltFuncFunctionData *func=NULL;
if ((data == NULL) || (ch == NULL) || (URI == NULL) || (name == NULL))
return;
if (ch->ctxt == NULL || ch->hash == NULL)
return;
/* Check if already present */
func = (exsltFuncFunctionData*)xmlHashLookup2(ch->hash, URI, name);
if (func == NULL) { /* Not yet present - copy it in */
func = exsltFuncNewFunctionData();
memcpy(func, data, sizeof(exsltFuncFunctionData));
if (xmlHashAddEntry2(ch->hash, URI, name, func) < 0) {
xsltGenericError(xsltGenericErrorContext,
"Failed to register function {%s}%s\n",
URI, name);
} else { /* Do the registration */
xsltGenericDebug(xsltGenericDebugContext,
"exsltFuncRegisterImportFunc: register {%s}%s\n",
URI, name);
xsltRegisterExtFunction(ch->ctxt, name, URI,
exsltFuncFunctionFunction);
}
}
}
示例5: exsltFuncInit
/**
* exsltFuncInit:
* @ctxt: an XSLT transformation context
* @URI: the namespace URI for the extension
*
* Initializes the EXSLT - Functions module.
* Called at transformation-time; merges all
* functions declared in the import tree taking
* import precedence into account, i.e. overriding
* functions with lower import precedence.
*
* Returns the data for this transformation
*/
static exsltFuncData *
exsltFuncInit (xsltTransformContextPtr ctxt, const xmlChar *URI) {
exsltFuncData *ret;
xsltStylesheetPtr tmp;
exsltFuncImportRegData ch;
xmlHashTablePtr hash;
ret = (exsltFuncData *) xmlMalloc (sizeof(exsltFuncData));
if (ret == NULL) {
xsltGenericError(xsltGenericErrorContext,
"exsltFuncInit: not enough memory\n");
return(NULL);
}
memset(ret, 0, sizeof(exsltFuncData));
ret->result = NULL;
ret->error = 0;
ch.hash = (xmlHashTablePtr) xsltStyleGetExtData(ctxt->style, URI);
ret->funcs = ch.hash;
xmlHashScanFull(ch.hash, (xmlHashScannerFull) exsltFuncRegisterFunc, ctxt);
tmp = ctxt->style;
ch.ctxt = ctxt;
while ((tmp=xsltNextImport(tmp))!=NULL) {
hash = xsltGetExtInfo(tmp, URI);
if (hash != NULL) {
xmlHashScanFull(hash,
(xmlHashScannerFull) exsltFuncRegisterImportFunc, &ch);
}
}
return(ret);
}
示例6: exsltMathMinFunction
/**
* exsltMathMinFunction:
* @ctxt: an XPath parser context
* @nargs: the number of arguments
*
* Wraps #exsltMathMin for use by the XPath processor.
*/
static void
exsltMathMinFunction (xmlXPathParserContextPtr ctxt, int nargs) {
xmlNodeSetPtr ns;
double ret;
void *user = NULL;
if (nargs != 1) {
xsltGenericError(xsltGenericErrorContext,
"math:min: invalid number of arguments\n");
ctxt->error = XPATH_INVALID_ARITY;
return;
}
/* We need to delay the freeing of value->user */
if ((ctxt->value != NULL) && (ctxt->value->boolval != 0)) {
user = ctxt->value->user;
ctxt->value->boolval = 0;
ctxt->value->user = NULL;
}
ns = xmlXPathPopNodeSet(ctxt);
if (xmlXPathCheckError(ctxt))
return;
ret = exsltMathMin(ns);
xmlXPathFreeNodeSet(ns);
if (user != NULL)
xmlFreeNodeList((xmlNodePtr)user);
xmlXPathReturnNumber(ctxt, ret);
}
示例7: exsltNodeSetFunction
// FIXME: This code is taken from libexslt 1.1.11; should sync with newer versions.
static void exsltNodeSetFunction(xmlXPathParserContextPtr ctxt, int nargs)
{
xmlChar *strval;
xmlNodePtr retNode;
xmlXPathObjectPtr ret;
if (nargs != 1) {
xmlXPathSetArityError(ctxt);
return;
}
if (xmlXPathStackIsNodeSet(ctxt)) {
xsltFunctionNodeSet(ctxt, nargs);
return;
}
strval = xmlXPathPopString(ctxt);
retNode = xmlNewDocText(NULL, strval);
ret = xmlXPathNewValueTree(retNode);
if (ret == NULL) {
xsltGenericError(xsltGenericErrorContext,
"exsltNodeSetFunction: ret == NULL\n");
} else {
ret->type = XPATH_NODESET;
}
if (strval != NULL)
xmlFree(strval);
valuePush(ctxt, ret);
}
示例8: xsltUnparsedEntityURIFunction
/**
* xsltUnparsedEntityURIFunction:
* @ctxt: the XPath Parser context
* @nargs: the number of arguments
*
* Implement the unparsed-entity-uri() XSLT function
* string unparsed-entity-uri(string)
*/
void
xsltUnparsedEntityURIFunction(xmlXPathParserContextPtr ctxt, int nargs){
xmlXPathObjectPtr obj;
xmlChar *str;
if ((nargs != 1) || (ctxt->value == NULL)) {
xsltGenericError(xsltGenericErrorContext,
"unparsed-entity-uri() : expects one string arg\n");
ctxt->error = XPATH_INVALID_ARITY;
return;
}
obj = valuePop(ctxt);
if (obj->type != XPATH_STRING) {
obj = xmlXPathConvertString(obj);
}
str = obj->stringval;
if (str == NULL) {
valuePush(ctxt, xmlXPathNewString((const xmlChar *)""));
} else {
xmlEntityPtr entity;
entity = xmlGetDocEntity(ctxt->context->doc, str);
if (entity == NULL) {
valuePush(ctxt, xmlXPathNewString((const xmlChar *)""));
} else {
if (entity->URI != NULL)
valuePush(ctxt, xmlXPathNewString(entity->URI));
else
valuePush(ctxt, xmlXPathNewString((const xmlChar *)""));
}
}
xmlXPathFreeObject(obj);
}
示例9: xsltMergeSASCallback
/**
* xsltMergeSASCallback,:
* @style: the XSLT stylesheet
*
* Merge an attribute set from an imported stylesheet.
*/
static void
xsltMergeSASCallback(xsltAttrElemPtr values, xsltStylesheetPtr style,
const xmlChar *name, const xmlChar *ns,
ATTRIBUTE_UNUSED const xmlChar *ignored) {
int ret;
xsltAttrElemPtr topSet;
ret = xmlHashAddEntry2(style->attributeSets, name, ns, values);
if (ret < 0) {
/*
* Add failed, this attribute set can be removed.
*/
#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
xsltGenericDebug(xsltGenericDebugContext,
"attribute set %s present already in top stylesheet"
" - merging\n", name);
#endif
topSet = xmlHashLookup2(style->attributeSets, name, ns);
if (topSet==NULL) {
xsltGenericError(xsltGenericErrorContext,
"xsl:attribute-set : logic error merging from imports for"
" attribute-set %s\n", name);
} else {
topSet = xsltMergeAttrElemList(style, topSet, values);
xmlHashUpdateEntry2(style->attributeSets, name, ns, topSet, NULL);
}
xsltFreeAttrElemList(values);
#ifdef WITH_XSLT_DEBUG_ATTRIBUTES
} else {
xsltGenericDebug(xsltGenericDebugContext,
"attribute set %s moved to top stylesheet\n",
name);
#endif
}
}
示例10: xsltFunctionAvailableFunction
/**
* xsltFunctionAvailableFunction:
* @ctxt: the XPath Parser context
* @nargs: the number of arguments
*
* Implement the function-available() XSLT function
* boolean function-available(string)
*/
void
xsltFunctionAvailableFunction(xmlXPathParserContextPtr ctxt, int nargs){
xmlXPathObjectPtr obj;
xmlChar *prefix, *name;
const xmlChar *nsURI = NULL;
if (nargs != 1) {
xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"function-available() : expects one string arg\n");
ctxt->error = XPATH_INVALID_ARITY;
return;
}
if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) {
xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"function-available() : invalid arg expecting a string\n");
ctxt->error = XPATH_INVALID_TYPE;
return;
}
obj = valuePop(ctxt);
name = xmlSplitQName2(obj->stringval, &prefix);
if (name == NULL) {
name = xmlStrdup(obj->stringval);
} else {
nsURI = xmlXPathNsLookup(ctxt->context, prefix);
if (nsURI == NULL) {
xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt),
NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"function-available() : prefix %s is not bound\n", prefix);
}
}
if (xmlXPathFunctionLookupNS(ctxt->context, name, nsURI) != NULL) {
valuePush(ctxt, xmlXPathNewBoolean(1));
} else {
valuePush(ctxt, xmlXPathNewBoolean(0));
}
xmlXPathFreeObject(obj);
if (name != NULL)
xmlFree(name);
if (prefix != NULL)
xmlFree(prefix);
}
示例11: xslDbgShellPrintList
/**
* xslDbgShellPrintList:
* @ctxt: The current shell context
* @arg: What xpath to display and in UTF-8
* @dir: If 1 print in dir mode?,
* otherwise ls mode
*
* Print list of nodes in either ls or dir format
*
* Returns 1 on success,
* 0 otherwise
*/
int
xslDbgShellPrintList(xmlShellCtxtPtr ctxt, xmlChar * arg, int dir)
{
xmlXPathObjectPtr list;
int result = 0;
if (!ctxt || !arg) {
#ifdef WITH_XSLDBG_DEBUG_PROCESS
xsltGenericError(xsltGenericErrorContext,
"Error: NULL arguments provided\n");
#endif
return result;
}
if (arg[0] == 0) {
if (dir)
xmlShellDir(ctxt, NULL, ctxt->node, NULL);
else
xmlShellList(ctxt, NULL, ctxt->node, NULL);
result = 1; /*assume that this worked */
} else {
ctxt->pctxt->node = ctxt->node;
ctxt->pctxt->node = ctxt->node;
if (!xmlXPathNsLookup(ctxt->pctxt, (xmlChar *) "xsl"))
xmlXPathRegisterNs(ctxt->pctxt, (xmlChar *) "xsl",
XSLT_NAMESPACE);
list = xmlXPathEval(arg, ctxt->pctxt);
if (list != NULL) {
switch (list->type) {
case XPATH_NODESET:{
int indx;
for (indx = 0;
indx < list->nodesetval->nodeNr; indx++) {
if (dir)
xmlShellList(ctxt, NULL,
list->nodesetval->
nodeTab[indx], NULL);
else
xmlShellList(ctxt, NULL,
list->nodesetval->
nodeTab[indx], NULL);
}
result = 1;
break;
}
default:
xmlShellPrintXPathError(list->type, (char *) arg);
}
xmlXPathFreeObject(list);
} else {
xsldbgGenericErrorFunc(i18n("Error: XPath %1 results in an empty Node Set.\n").arg(xsldbgText(arg)));
}
ctxt->pctxt->node = NULL;
}
return result;
}
示例12: xsltCurrentFunction
/**
* xsltCurrentFunction:
* @ctxt: the XPath Parser context
* @nargs: the number of arguments
*
* Implement the current() XSLT function
* node-set current()
*/
static void
xsltCurrentFunction(xmlXPathParserContextPtr ctxt, int nargs){
xsltTransformContextPtr tctxt;
if (nargs != 0) {
xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"current() : function uses no argument\n");
ctxt->error = XPATH_INVALID_ARITY;
return;
}
tctxt = xsltXPathGetTransformContext(ctxt);
if (tctxt == NULL) {
xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
xsltGenericError(xsltGenericErrorContext,
"current() : internal error tctxt == NULL\n");
valuePush(ctxt, xmlXPathNewNodeSet(NULL));
} else {
valuePush(ctxt, xmlXPathNewNodeSet(tctxt->node)); /* current */
}
}
示例13: gda_xslt_section_element
static void
gda_xslt_section_element (xsltTransformContextPtr tctxt,
xmlNodePtr node,
xmlNodePtr inst, xsltStylePreCompPtr comp)
{
int res;
GdaXsltIntCont *data;
GdaXsltExCont *execc;
// gda_xslt_dump_element(tctxt,node,inst,comp);
if (tctxt == NULL || node == NULL || inst == NULL
|| tctxt->insert == NULL) {
xsltGenericError (xsltGenericErrorContext,
"gda_xslt_section_element: bad input date\n");
tctxt->state = XSLT_STATE_STOPPED;
return;
}
execc = (GdaXsltExCont *) tctxt->_private;
data = (GdaXsltIntCont *) xsltGetExtData (tctxt,
BAD_CAST GDA_XSLT_EXTENSION_URI);
if (data == NULL || execc == NULL) {
xsltGenericError (xsltGenericErrorContext,
"gda_xslt_section_element: failed to get module internal data\n");
tctxt->state = XSLT_STATE_STOPPED;
return;
}
res = _gda_xslt_bk_section (execc, data, tctxt, node, inst, comp);
if (res < 0) {
xsltGenericError (xsltGenericErrorContext,
"gda_xslt_section_element: execute query backend\n");
tctxt->state = XSLT_STATE_STOPPED;
return;
}
return;
}
示例14: xslDbgPublic
/**
* xslDbgPublic:
* @arg : Is valid
*
* Print what a public ID @arg maps to via the current xml catalog
*
* Returns 1 on sucess,
* 0 otherwise
*/
int
xslDbgPublic(const xmlChar * arg)
{
int result = 0;
xmlChar *name;
if (!arg || (xmlStrlen(arg) == 0)) {
#ifdef WITH_XSLDBG_DEBUG_PROCESS
xsltGenericError(xsltGenericErrorContext,
"Error: NULL argument provided\n");
#endif
return result;
}
name = xmlCatalogResolvePublic(arg);
if (getThreadStatus() == XSLDBG_MSG_THREAD_RUN) {
if (name) {
notifyXsldbgApp(XSLDBG_MSG_RESOLVE_CHANGE, name);
result = 1;
xmlFree(name);
} else {
notifyXsldbgApp(XSLDBG_MSG_RESOLVE_CHANGE, "");
xsldbgGenericErrorFunc(i18n("PublicID \"%1\" was not found in current catalog.\n").arg(xsldbgText(arg)));
}
} else {
if (name) {
xsldbgGenericErrorFunc(i18n("PublicID \"%1\" maps to: \"%2\"\n").arg(xsldbgText(arg)).arg(xsldbgText(name)));
xmlFree(name);
result = 1;
} else {
xsldbgGenericErrorFunc(i18n("PublicID \"%1\" was not found in current catalog.\n").arg(xsldbgText(arg)));
}
xsltGenericError(xsltGenericErrorContext, "%s", buffer);
}
return result;
}
示例15: xsltExtStyleShutdownTest
/**
* xsltExtStyleShutdownTest:
* @style: an XSLT stylesheet
* @URI: the namespace URI for the extension
* @data: the data associated to this module
*
* A function called at shutdown time of an XSLT extension module
*/
static void
xsltExtStyleShutdownTest(xsltStylesheetPtr style ATTRIBUTE_UNUSED,
const xmlChar * URI, void *data)
{
if (testStyleData == NULL) {
xsltGenericError(xsltGenericErrorContext,
"xsltExtShutdownTest: not initialized\n");
return;
}
if (data != testStyleData) {
xsltTransformError(NULL, NULL, NULL,
"xsltExtShutdownTest: wrong data\n");
}
testStyleData = NULL;
xsltGenericDebug(xsltGenericDebugContext,
"Unregistered test plugin module : %s\n", URI);
}