您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ xmlSearchNs函数代码示例

51自学网 2021-06-03 11:46:29
  C++
这篇教程C++ xmlSearchNs函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中xmlSearchNs函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlSearchNs函数的具体用法?C++ xmlSearchNs怎么用?C++ xmlSearchNs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了xmlSearchNs函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: xmlSearchNs

 xmlNode* child_node_list::create_element_(const std::string& qname) {     // Split QName into prefix and local name.     std::pair<std::string, std::string> name_pair = detail::split_qname(qname);     const std::string& prefix = name_pair.first;     const std::string& name = name_pair.second;     // Find xmlns by prefix (if this child node list belongs to an element).     xmlNs* ns = 0;     if (raw_->type == XML_ELEMENT_NODE)     {         ns = xmlSearchNs( raw_->doc,                           raw_,                           prefix.empty() ? 0 : detail::to_xml_chars(prefix.c_str()) );     }     if (!prefix.empty() && ns == 0)     {         std::string what = "fail to create element " + qname                          + ": xmlns for prefix " + prefix + " not found";         throw bad_dom_operation(what);     }     // Create element under the xmlns.     xmlNode* px = xmlNewDocNode( raw_->doc,                                  ns,                                  detail::to_xml_chars(name.c_str()),                                  0 );     if (px == 0)     {         std::string what = "fail to create libxml2 element node for " + name;         throw internal_dom_error(what);     }     // Return the new element.     return px; }
开发者ID:zhengzhong,项目名称:xtree,代码行数:33,


示例2: node_find_ns

xmlNsPtr node_find_ns(xmlNodePtr node) {  if (node->ns) {    return node->ns;  } else {    return xmlSearchNs(node->doc, node, NULL);  }}
开发者ID:HyeongKyu,项目名称:hiphop-php,代码行数:7,


示例3: PatchCamFlags

		virtual bool PatchCamFlags(xmlDocPtr doc, const char *uuid, const char *slot, const char *flags) {			bool uuid_match=false;			bool flags_set =false;			xmlNode *node = xmlDocGetRootElement(doc);			node = node ? node->children : NULL;			while(node && xmlStrcmp(node->name, (const xmlChar *)"Description"))				node=node->next;			node = node ? node->children : NULL;			while(node) {				if(node && !xmlStrcmp(node->name, (const xmlChar *)"component")) {					xmlNode *item = node->children;					while(item && xmlStrcmp(item->name, (const xmlChar *)"Description")) {						item = item->next;					} // while					xmlChar *about = item ? xmlGetProp(item, (const xmlChar *)"about") : NULL;					if(about) {						if (!xmlStrcmp(about, (const xmlChar *)"Platform")) {							xmlNode *sub = item->children;							while(sub) {								if(!xmlStrcmp(sub->name, (const xmlChar *)"UUID")) {									xmlChar *value=xmlNodeListGetString(doc, sub->children, 1);									if(value) {										uuid_match=!xmlStrcmp(value, (const xmlChar *)uuid); 										xmlFree(value);									} // if								} // if								sub = sub->next;							} // while						} else if(!xmlStrcmp(about, (const xmlChar *)"CAM")) {							xmlNode *sub = item->children;							while(sub) {								if(!xmlStrcmp(sub->name, (const xmlChar *)"Slot")) {									xmlChar *value=xmlNodeListGetString(doc, sub->children, 1);									if(value) {										if (!xmlStrcmp(value, (const xmlChar *)slot)) {											xmlNode *tst = item->children;											while(tst) {												if(!xmlStrcmp(tst->name, (const xmlChar *)"Flags")) {													xmlReplaceNode(tst, xmlNewChild(item, xmlSearchNs(doc, tst, (const xmlChar *)"prf"), (const xmlChar *)"Flags", (const xmlChar *)flags));													xmlFreeNode(tst);													flags_set=true;													tst = NULL;													continue;												} // if												tst = tst->next;											} // while										} // if										xmlFree(value);									} // if								} // if								sub = sub->next;							} // while						} // if						xmlFree(about);					} // if				} // if				node = node->next;			} // while			return uuid_match && flags_set;		}; // PatchCamFlags
开发者ID:suborb,项目名称:reelvdr,代码行数:60,


示例4: xsltGetSpecialNamespace

/** * xsltGetSpecialNamespace: * @ctxt:  a transformation context * @cur:  the input node * @URI:  the namespace URI * @prefix:  the suggested prefix * @out:  the output node (or its parent) * * Find the right namespace value for this URI, if needed create * and add a new namespace decalaration on the node * * Returns the namespace node to use or NULL */xmlNsPtrxsltGetSpecialNamespace(xsltTransformContextPtr ctxt, xmlNodePtr cur,		const xmlChar *URI, const xmlChar *prefix, xmlNodePtr out) {    xmlNsPtr ret;    static int prefixno = 1;    char nprefix[10];    if ((ctxt == NULL) || (cur == NULL) || (out == NULL) || (URI == NULL))	return(NULL);    if ((out->parent != NULL) &&	(out->parent->type == XML_ELEMENT_NODE) &&	(out->parent->ns != NULL) &&	(xmlStrEqual(out->parent->ns->href, URI)))	ret = out->parent->ns;    else	ret = xmlSearchNsByHref(out->doc, out, URI);    if (ret == NULL) {	if (prefix == NULL) {	    do {		sprintf(nprefix, "ns%d", prefixno++);		ret = xmlSearchNs(out->doc, out, (xmlChar *)nprefix);	    } while (ret != NULL);	    prefix = (const xmlChar *) &nprefix[0];	}	if (out->type == XML_ELEMENT_NODE)	    ret = xmlNewNs(out, URI, prefix);    }    return(ret);}
开发者ID:gitpan,项目名称:AxKit-Needs,代码行数:44,


示例5: slaxSetNs

/* * Find or construct a (possibly temporary) namespace node * for the "func" exslt library and put the given node into * that namespace.  We also have to add this as an "extension" * namespace. */static xmlNsPtrslaxSetNs (slax_data_t *sdp, xmlNodePtr nodep,	   const char *prefix, const xmlChar *uri, int local){    xmlNsPtr nsp;    xmlNodePtr root = xmlDocGetRootElement(sdp->sd_docp);    nsp = xmlSearchNs(sdp->sd_docp, root, (const xmlChar *) prefix);    if (nsp == NULL) {	nsp = xmlNewNs(root, uri, (const xmlChar *) prefix);	if (nsp == NULL) {	    xmlParserError(sdp->sd_ctxt, "%s:%d: out of memory",			   sdp->sd_filename, sdp->sd_line);	    return NULL;	}	/*	 * Since we added this namespace, we need to add it to the	 * list of extension prefixes.	 */	slaxNodeAttribExtend(sdp, root,			     ATT_EXTENSION_ELEMENT_PREFIXES, prefix, NULL);    }    if (nodep) {	/* Add a distinct namespace to the current node */	nsp = xmlNewNs(nodep, uri, (const xmlChar *) prefix);	if (local)	    nodep->ns = nsp;    }    return nsp;}
开发者ID:aruns16,项目名称:libslax,代码行数:39,


示例6: if

/** * xlinkIsLink: * @doc:  the document containing the node * @node:  the node pointer itself * * Check whether the given node carries the attributes needed * to be a link element (or is one of the linking elements issued * from the (X)HTML DtDs). * This routine don't try to do full checking of the link validity * but tries to detect and return the appropriate link type. * * Returns the xlinkType of the node (XLINK_TYPE_NONE if there is no *         link detected. */xlinkType xlinkIsLink	(xmlDocPtr doc, xmlNodePtr node) {    xmlChar *type = NULL, *role = NULL;    xlinkType ret = XLINK_TYPE_NONE;    if (node == NULL) return(XLINK_TYPE_NONE);    if (doc == NULL) doc = node->doc;    if ((doc != NULL) && (doc->type == XML_HTML_DOCUMENT_NODE)) {        /*	 * This is an HTML document.	 */    } else if ((node->ns != NULL) &&               (xmlStrEqual(node->ns->href, XHTML_NAMESPACE))) {	/*	 * !!!! We really need an IS_XHTML_ELEMENT function from HTMLtree.h @@@	 */        /*	 * This is an XHTML element within an XML document	 * Check whether it's one of the element able to carry links	 * and in that case if it holds the attributes.	 */    }    /*     * We don't prevent a-priori having XML Linking constructs on     * XHTML elements     */    type = xmlGetNsProp(node, BAD_CAST"type", XLINK_NAMESPACE);    if (type != NULL) {	if (xmlStrEqual(type, BAD_CAST "simple")) {            ret = XLINK_TYPE_SIMPLE;	} if (xmlStrEqual(type, BAD_CAST "extended")) {	    role = xmlGetNsProp(node, BAD_CAST "role", XLINK_NAMESPACE);	    if (role != NULL) {		xmlNsPtr xlink;		xlink = xmlSearchNs(doc, node, XLINK_NAMESPACE);		if (xlink == NULL) {		    /* Humm, fallback method */		    if (xmlStrEqual(role, BAD_CAST"xlink:external-linkset")) 			ret = XLINK_TYPE_EXTENDED_SET;		} else {		    xmlChar buf[200];		    snprintf((char *) buf, sizeof(buf), "%s:external-linkset",			     (char *) xlink->prefix);                    buf[sizeof(buf) - 1] = 0;		    if (xmlStrEqual(role, buf))			ret = XLINK_TYPE_EXTENDED_SET;		}	    }	    ret = XLINK_TYPE_EXTENDED;	}    }    if (type != NULL) xmlFree(type);    if (role != NULL) xmlFree(role);    return(ret);}
开发者ID:Study-C,项目名称:libN47pp,代码行数:73,


示例7: xsltGetNamespace

/** * xsltGetNamespace: * @ctxt:  a transformation context * @cur:  the input node * @ns:  the namespace * @out:  the output node (or its parent) * * Find a matching (prefix and ns-name) ns-declaration * for the requested @ns->prefix and @ns->href in the result tree. * If none is found then a new ns-declaration will be * added to @resultElem. If, in this case, the given prefix is * already in use, then a ns-declaration with a modified ns-prefix * be we created. * * Called by: *  - xsltCopyPropList() (*not*  anymore) *  - xsltShallowCopyElement() *  - xsltCopyTreeInternal() (*not*  anymore) *  - xsltApplySequenceConstructor() (*not* in the refactored code), *  - xsltElement() (*not* anymore) * * Returns a namespace declaration or NULL in case of *         namespace fixup failures or API or internal errors. */xmlNsPtrxsltGetNamespace(xsltTransformContextPtr ctxt, xmlNodePtr cur, xmlNsPtr ns,	         xmlNodePtr out){    if (ns == NULL)	return(NULL);#ifdef XSLT_REFACTORED    /*    * Namespace exclusion and ns-aliasing is performed at    * compilation-time in the refactored code.    * Additionally, aliasing is not intended for non Literal    * Result Elements.    */    return(xsltGetSpecialNamespace(ctxt, cur, ns->href, ns->prefix, out));#else    {	xsltStylesheetPtr style;	const xmlChar *URI = NULL; /* the replacement URI */	if ((ctxt == NULL) || (cur == NULL) || (out == NULL))	    return(NULL);	style = ctxt->style;	while (style != NULL) {	    if (style->nsAliases != NULL)		URI = (const xmlChar *)		xmlHashLookup(style->nsAliases, ns->href);	    if (URI != NULL)		break;	    style = xsltNextImport(style);	}	if (URI == UNDEFINED_DEFAULT_NS) {	    return(xsltGetSpecialNamespace(ctxt, cur, NULL, NULL, out));#if 0	    /*	    * TODO: Removed, since wrong. If there was no default	    * namespace in the stylesheet then this must resolve to	    * the NULL namespace.	    */	    xmlNsPtr dflt;	    dflt = xmlSearchNs(cur->doc, cur, NULL);	    if (dflt != NULL)		URI = dflt->href;	    else		return NULL;#endif	} else if (URI == NULL)	    URI = ns->href;	return(xsltGetSpecialNamespace(ctxt, cur, URI, ns->prefix, out));    }#endif}
开发者ID:GYGit,项目名称:reactos,代码行数:82,


示例8: xsltElementAvailableFunction

/** * xsltElementAvailableFunction: * @ctxt:  the XPath Parser context * @nargs:  the number of arguments * * Implement the element-available() XSLT function *   boolean element-available(string) */voidxsltElementAvailableFunction(xmlXPathParserContextPtr ctxt, int nargs){    xmlXPathObjectPtr obj;    xmlChar *prefix, *name;    const xmlChar *nsURI = NULL;    xsltTransformContextPtr tctxt;    if (nargs != 1) {	xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,		"element-available() : expects one string arg/n");	ctxt->error = XPATH_INVALID_ARITY;	return;    }    xmlXPathStringFunction(ctxt, 1);    if ((ctxt->value == NULL) || (ctxt->value->type != XPATH_STRING)) {	xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,	    "element-available() : invalid arg expecting a string/n");	ctxt->error = XPATH_INVALID_TYPE;	return;    }    obj = valuePop(ctxt);    tctxt = xsltXPathGetTransformContext(ctxt);    if (tctxt == NULL) {	xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,		"element-available() : internal error tctxt == NULL/n");	xmlXPathFreeObject(obj);	valuePush(ctxt, xmlXPathNewBoolean(0));	return;    }    name = xmlSplitQName2(obj->stringval, &prefix);    if (name == NULL) {	xmlNsPtr ns;	name = xmlStrdup(obj->stringval);	ns = xmlSearchNs(tctxt->inst->doc, tctxt->inst, NULL);	if (ns != NULL) nsURI = xmlStrdup(ns->href);    } else {	nsURI = xmlXPathNsLookup(ctxt->context, prefix);	if (nsURI == NULL) {	    xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,		"element-available() : prefix %s is not bound/n", prefix);	}    }    if (xsltExtElementLookup(tctxt, name, nsURI) != NULL) {	valuePush(ctxt, xmlXPathNewBoolean(1));    } else {	valuePush(ctxt, xmlXPathNewBoolean(0));    }    xmlXPathFreeObject(obj);    if (name != NULL)	xmlFree(name);    if (prefix != NULL)	xmlFree(prefix);}
开发者ID:Paxxi,项目名称:libxslt,代码行数:66,


示例9: attr_find_ns

xmlNsPtr attr_find_ns(xmlAttrPtr node) {  if (node->ns) {    return node->ns;  } else if (node->parent->ns) {    return node->parent->ns;  } else {    return xmlSearchNs(node->doc, node->parent, NULL);  }}
开发者ID:HyeongKyu,项目名称:hiphop-php,代码行数:9,


示例10: epp_getSubtree

char *epp_getSubtree(void *pool,		epp_command_data *cdata,		const char *xpath_expr,		int position){	char	*subtree;	xmlBufferPtr	 buf;	xmlDocPtr	 doc;	xmlNodePtr	 node;	xmlXPathObjectPtr	 xpath_obj;	xmlXPathContextPtr	 xpath_ctx;	doc = (xmlDocPtr) cdata->parsed_doc;	xpath_ctx = (xmlXPathContextPtr) cdata->xpath_ctx;	xpath_obj = xmlXPathEvalExpression(BAD_CAST xpath_expr, xpath_ctx);	if (xpath_obj == NULL)		return NULL;	/* correct position for non-list elements */	if (position == 0) position++;	if (xmlXPathNodeSetGetLength(xpath_obj->nodesetval) < position) {		xmlXPathFreeObject(xpath_obj);		/* return empty string if the node is not there */		return epp_strdup(pool, "");	}	/*	 * Get content of problematic tag. It's not so easy task. We have	 * to declare namespaces defined higher in the tree which are relevant	 * to the part of document being dumped. Fortunatelly there is a	 * function from libxml library doing exactly that (xmlreconsiliatens).	 */	buf = xmlBufferCreate();	if (buf == NULL)		return NULL;	node = xmlXPathNodeSetItem(xpath_obj->nodesetval, position - 1);	if (node->ns != NULL) {		xmlNsPtr	 nsdef;		nsdef = xmlSearchNs(doc, node, node->ns->prefix);		if (nsdef != NULL)			xmlNewNs(node, nsdef->href, nsdef->prefix);	}	if (xmlNodeDump(buf, doc, node, 0, 0) < 0)	{		xmlXPathFreeObject(xpath_obj);		xmlBufferFree(buf);		return NULL;	}	subtree = epp_strdup(pool, (char *) buf->content);	xmlXPathFreeObject(xpath_obj);	xmlBufferFree(buf);	return subtree;}
开发者ID:LANJr4D,项目名称:FRED,代码行数:55,


示例11: eXmlInvalid

std::string cXmlDoc::searchNs(const std::string& prefix, xmlNodePtr node) {    if (!m_doc)        throw eXmlInvalid("Tried to search namespace for bad document");    xmlNsPtr ns = xmlSearchNs(m_doc.get(), node?node:xmlDocGetRootElement(m_doc.get()), (prefix=="")?NULL:reinterpret_cast<const xmlChar*>(prefix.c_str()));    if (ns) {        return ns->href?string(reinterpret_cast<const char*>(ns->href)):"";    } else {        return "";    }}
开发者ID:Joeywp,项目名称:OVLMake,代码行数:11,


示例12: xmlSearchNs

const XMLNs *XMLElement::getNamespaceByPrefix(const char *prefix) const{    xmlNs *ns = xmlSearchNs(doc.getRealDocument(), node, (const xmlChar *)prefix);    XMLObject *obj = scope->getXMLObjectFromLibXMLPtr(ns);    if (obj)    {        return static_cast < XMLNs * >(obj);    }    return new XMLNs(*this, ns);}
开发者ID:ASP1234,项目名称:Scilabv5.5.2,代码行数:11,


示例13: InternalError

xmlNodePtr Node::createChild(const string &name, const string &prefix) const{    xmlNs * ns = nullptr;    if ( Type() != NodeType::Element )        throw InternalError("Cannot add children to non-element node of type '" + TypeString(Type()) + "'");        if ( prefix.empty() )    {        ns = xmlSearchNs(_xml->doc, _xml, nullptr);    }    else    {        // use the existing namespace if one exists        ns = xmlSearchNs(_xml->doc, _xml, prefix.utf8());        if ( ns == nullptr )            throw InternalError(std::string("The namespace prefix '") + prefix.c_str() + "' is unknown");    }        return xmlNewNode(ns, name.utf8());}
开发者ID:Hasimir,项目名称:readium-sdk,代码行数:20,


示例14: setNodeNameSpace

void XMLElement::setNodeNameSpace(const XMLNs & ns) const{    xmlNs *n = ns.getRealNs();    if (n)    {        if (!n->prefix || !xmlSearchNs(doc.getRealDocument(), node, n->prefix))        {            n = xmlNewNs(node, (const xmlChar *)ns.getHref(), (const xmlChar *)ns.getPrefix());        }        xmlSetNs(node, n);    }}
开发者ID:ASP1234,项目名称:Scilabv5.5.2,代码行数:12,


示例15: f_manage_input_xml

int f_manage_input_xml(const char *p_name,int s_type,audiovideo_t *p_audiovideo){    static xmlDocPtr p_doc;    xmlNodePtr p_node;    xmlNsPtr ns;    if (s_type)     //read the file from p_name    {        p_doc = xmlParseFile(p_name);        p_node = xmlDocGetRootElement(p_doc);        if (p_node == NULL)        {            xmlFreeDoc(p_doc);            tc_log_error(__FILE__,"Invalid file format");            return(-1);        }        ns = xmlSearchNsByHref(p_doc, p_node, (const xmlChar *) "http://www.w3.org/2001/SMIL20/Language");        if (ns == NULL)        {            xmlFreeDoc(p_doc);            tc_log_error(__FILE__,"Invalid Namespace");            return(-1);        }        ns = xmlSearchNs(p_doc, p_node, (const xmlChar *) "smil2");        if (ns == NULL)        {            xmlFreeDoc(p_doc);            tc_log_error(__FILE__,"Invalid Namespace");            return(-1);        }        if (xmlStrcmp(p_node->name, (const xmlChar *) "smil"))        {            xmlFreeDoc(p_doc);            tc_log_error(__FILE__,"Invalid Namespace");            return(-1);        }        f_delete_unused_node(p_node);        memset(p_audiovideo,'/0',sizeof(audiovideo_t));        if(f_parse_tree(p_node,p_audiovideo))            return(1);        if (f_complete_tree(p_audiovideo))            return(1);    }    else    {            f_free_tree(p_audiovideo);            xmlFreeDoc(p_doc);    }    return(0);}
开发者ID:BackupTheBerlios,项目名称:tcforge,代码行数:50,


示例16: _dom_new_reconNs

static xmlNsPtr _dom_new_reconNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns) /* {{{ */{    xmlNsPtr def;    xmlChar prefix[50];    int counter = 1;	if ((tree == NULL) || (ns == NULL) || (ns->type != XML_NAMESPACE_DECL)) {		return NULL;	}	/* Code taken from libxml2 (2.6.20) xmlNewReconciliedNs	 *	 * Find a close prefix which is not already in use.	 * Let's strip namespace prefixes longer than 20 chars !	 */	if (ns->prefix == NULL)		snprintf((char *) prefix, sizeof(prefix), "default");	else		snprintf((char *) prefix, sizeof(prefix), "%.20s", (char *)ns->prefix);	def = xmlSearchNs(doc, tree, prefix);	while (def != NULL) {		if (counter > 1000) return(NULL);		if (ns->prefix == NULL)			snprintf((char *) prefix, sizeof(prefix), "default%d", counter++);		else			snprintf((char *) prefix, sizeof(prefix), "%.20s%d",			(char *)ns->prefix, counter++);		def = xmlSearchNs(doc, tree, prefix);	}	/*	 * OK, now we are ready to create a new one.	 */	def = xmlNewNs(tree, ns->href, prefix);	return(def);}
开发者ID:13572293130,项目名称:php-src,代码行数:37,


示例17: exclude_namespace

int exclude_namespace(elcgen *gen, expression *expr, const char *uri){  int found = 0;  expression *xp;  if (!strcmp(uri,XSLT_NS))    return 1;  for (xp = expr; xp && !found; xp = xp->parent) {    char *str;    if (xp->xmlnode->ns && !strcmp((char*)xp->xmlnode->ns->href,XSLT_NS))      str = xmlGetNsProp(xp->xmlnode,"exclude-result-prefixes",NULL);    else      str = xmlGetNsProp(xp->xmlnode,"exclude-result-prefixes",XSLT_NS);    if (str) {      int end = 0;      char *start = str;      char *c;      for (c = str; !found && !end; c++) {        end = ('/0' == *c);        if (end || isspace(*c)) {          if (c > start) {            xmlNsPtr ns;            *c = '/0';            if (!strcmp(start,"#all")) {              found = (NULL != xmlSearchNsByHref(gen->parse_doc,xp->xmlnode,(xmlChar*)uri));            }            else if (!strcmp(start,"#default")) {              found = ((NULL != xp->xmlnode->ns) && !strcmp((char*)xp->xmlnode->ns->href,uri));            }            else {              ns = xmlSearchNs(gen->parse_doc,xp->xmlnode,(xmlChar*)start);              found = ((NULL != ns) && !strcmp((char*)ns->href,uri));            }          }          start = c+1;        }      }      free(str);    }  }  return found;}
开发者ID:amirsalah,项目名称:cs2007,代码行数:45,


示例18: fetch_ns

static xmlNsPtrfetch_ns (ESoapMessage *msg,          const gchar *prefix,          const gchar *ns_uri){	ESoapMessagePrivate *priv = E_SOAP_MESSAGE_GET_PRIVATE (msg);	xmlNsPtr ns = NULL;	if (prefix && ns_uri)		ns = xmlNewNs (priv->last_node, (const xmlChar *) ns_uri, (const xmlChar *) prefix);	else if (prefix && !ns_uri) {		ns = xmlSearchNs (priv->doc, priv->last_node, (const xmlChar *) prefix);		if (!ns)			ns = xmlNewNs (priv->last_node, (const xmlChar *)"", (const xmlChar *)prefix);	}	return ns;}
开发者ID:tivv,项目名称:evolution-ews,代码行数:18,


示例19: xmlSetNsProp

void XMLAttr::setAttributeValue(xmlNode * node, const char *prefix, const char *name, const char *value){    if (node && node->type == XML_ELEMENT_NODE)    {        xmlAttr *attrs = 0;        for (xmlAttr * cur = node->properties; cur; cur = cur->next)        {            if (cur->ns && !strcmp(name, (const char *)cur->name)                    && (!strcmp(prefix, (const char *)cur->ns->prefix) || !strcmp(prefix, (const char *)cur->ns->href)))            {                attrs = cur;                break;            }        }        if (attrs)        {            xmlSetNsProp(node, attrs->ns, (const xmlChar *)name, (const xmlChar *)value);        }        else        {            xmlNs *ns = 0;            if (!strncmp(prefix, "http://", strlen("http://")))            {                ns = xmlSearchNsByHref(node->doc, node, (const xmlChar *)prefix);            }            else            {                ns = xmlSearchNs(node->doc, node, (const xmlChar *)prefix);            }            if (ns)            {                xmlSetNsProp(node, ns, (const xmlChar *)name, (const xmlChar *)value);            }            else            {                xmlSetProp(node, (const xmlChar *)name, (const xmlChar *)value);            }        }    }}
开发者ID:FOSSEE-Internship,项目名称:scilab,代码行数:44,


示例20: if

xlinkType xlinkIsLink	(xmlDocPtr doc, xmlNodePtr node) {    xmlChar *type = NULL, *role = NULL;    xlinkType ret = XLINK_TYPE_NONE;    if (node == NULL) return(XLINK_TYPE_NONE);    if (doc == NULL) doc = node->doc;    if ((doc != NULL) && (doc->type == XML_HTML_DOCUMENT_NODE)) {    } else if ((node->ns != NULL) &&               (xmlStrEqual(node->ns->href, XHTML_NAMESPACE))) {    }    type = xmlGetNsProp(node, BAD_CAST"type", XLINK_NAMESPACE);    if (type != NULL) {	if (xmlStrEqual(type, BAD_CAST "simple")) {            ret = XLINK_TYPE_SIMPLE;	} if (xmlStrEqual(type, BAD_CAST "extended")) {	    role = xmlGetNsProp(node, BAD_CAST "role", XLINK_NAMESPACE);	    if (role != NULL) {		xmlNsPtr xlink;		xlink = xmlSearchNs(doc, node, XLINK_NAMESPACE);		if (xlink == NULL) {		    		    if (xmlStrEqual(role, BAD_CAST"xlink:external-linkset")) 			ret = XLINK_TYPE_EXTENDED_SET;		} else {		    xmlChar buf[200];		    snprintf((char *) buf, sizeof(buf), "%s:external-linkset",			     (char *) xlink->prefix);                    buf[sizeof(buf) - 1] = 0;		    if (xmlStrEqual(role, buf))			ret = XLINK_TYPE_EXTENDED_SET;		}	    }	    ret = XLINK_TYPE_EXTENDED;	}    }    if (type != NULL) xmlFree(type);    if (role != NULL) xmlFree(role);    return(ret);}
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:44,


示例21: EB_Msg__prepareSignature

int EB_Msg__prepareSignature(xmlDocPtr doc) {  xmlNodePtr node;  xmlNsPtr ns;  xmlNodePtr n;  xmlNodePtr nn;  xmlNodePtr nnn;  xmlNodePtr nnnn;  node=xmlNewChild(xmlDocGetRootElement(doc),                   NULL, BAD_CAST "AuthSignature", NULL);  ns=xmlSearchNs(doc, node, BAD_CAST "ds");  assert(ns);  n=xmlNewChild(node, ns, BAD_CAST "SignedInfo", NULL);  nn=xmlNewChild(n, ns, BAD_CAST "CanonicalizationMethod", NULL);  xmlNewProp(nn,             BAD_CAST "Algorithm",             BAD_CAST "http://www.w3.org/TR/2001/REC-xml-c14n-20010315");  nn=xmlNewChild(n, ns, BAD_CAST "SignatureMethod", NULL);  xmlNewProp(nn,             BAD_CAST "Algorithm",             BAD_CAST "http://www.w3.org/2000/09/xmldsig#rsa-sha1");  nn=xmlNewChild(n, ns, BAD_CAST "Reference", NULL);  xmlNewProp(nn,             BAD_CAST "URI",             BAD_CAST "#xpointer(//*[@authenticate='true'])");  nnn=xmlNewChild(nn, ns, BAD_CAST "Transforms", NULL);  nnnn=xmlNewChild(nnn, ns, BAD_CAST "Transform", NULL);  xmlNewProp(nnnn,             BAD_CAST "Algorithm",             BAD_CAST "http://www.w3.org/TR/2001/REC-xml-c14n-20010315");  nn=xmlNewChild(n, ns, BAD_CAST "DigestMethod", NULL);  xmlNewProp(nn,             BAD_CAST "Algorithm",             BAD_CAST "http://www.w3.org/2000/09/xmldsig#sha1");  return 0;}
开发者ID:Zauberstuhl,项目名称:aqbanking,代码行数:42,


示例22: dom_get_dom1_attribute

static xmlNodePtr dom_get_dom1_attribute(xmlNodePtr elem, xmlChar *name) /* {{{ */{    int len;    const xmlChar *nqname;	nqname = xmlSplitQName3(name, &len);	if (nqname != NULL) {		xmlNsPtr ns;		xmlChar *prefix = xmlStrndup(name, len);		if (prefix && xmlStrEqual(prefix, (xmlChar *)"xmlns")) {			ns = elem->nsDef;			while (ns) {				if (xmlStrEqual(ns->prefix, nqname)) {					break;				}				ns = ns->next;			}			xmlFree(prefix);			return (xmlNodePtr)ns;		}		ns = xmlSearchNs(elem->doc, elem, prefix);		if (prefix != NULL) {			xmlFree(prefix);		}		if (ns != NULL) {			return (xmlNodePtr)xmlHasNsProp(elem, nqname, ns->href);		}	} else {		if (xmlStrEqual(name, (xmlChar *)"xmlns")) {			xmlNsPtr nsPtr = elem->nsDef;			while (nsPtr) {				if (nsPtr->prefix == NULL) {					return (xmlNodePtr)nsPtr;				}				nsPtr = nsPtr->next;			}			return NULL;		}	}	return (xmlNodePtr)xmlHasNsProp(elem, name, NULL);}
开发者ID:13572293130,项目名称:php-src,代码行数:41,


示例23: soap_env_find_urn

char *soap_env_find_urn(SoapEnv * env){  xmlNsPtr ns;  xmlNodePtr body, node;  if (!(body = soap_env_get_body(env)))  {    log_verbose1("body is NULL");    return 0;  }  /* node is the first child */  if (!(node = soap_xml_get_children(body)))  {    log_error1("No namespace found");    return 0;  }  /* if (node->ns && node->ns->prefix) MRC 1/25/2006 */  if (node->ns)  {    ns = xmlSearchNs(body->doc, node, node->ns->prefix);    if (ns != NULL)    {      return((char *) ns->href); /* namespace found! */    }  }  else  {    static char *empty = "";    log_warn1("No namespace found");    return(empty);  }  return 0;}
开发者ID:millken,项目名称:zhuxianB30,代码行数:37,


示例24: validerr_callback

/** * This is a callback for validator errors. * * Purpose is to cumulate all encountered errors in a list, which is further * processed after the validation is done. If any malloc inside this routine * fails, the error is silently dropped and is not queued in the list of * errors. That makes algorithm a bit less complicated. * * @param ctx     Hook's context pointer. * @param error   Specification of encountered error. */static voidvaliderr_callback(void *ctx, xmlErrorPtr error){	/* used to get content of problematic xml tag */	xmlBufferPtr	buf;	xmlNodePtr	node;	int	len;	/* used for new list item creation */	epp_error	*valerr;	/* get context parameters */	qhead	*error_list = ((valerr_ctx *) ctx)->err_list;	xmlDocPtr	doc = ((valerr_ctx *) ctx)->doc;	void	*pool = ((valerr_ctx *) ctx)->pool;	/* in case of allocation failure simply don't log the error and exit */	if ((valerr = epp_malloc(pool, sizeof *valerr)) == NULL) return;	/*	 * xmlError has quite a lot of fields, we are interested only in 3	 * of them: code, message, node.	 */	/*	 * XXX error code should be further examined in order to get	 * more detailed error	 * valerr->code = error->code;	 */	/*	 * get error message (we don't use strdup because we have to	 * truncate trailing newline)	 */	len = strlen(error->message);	valerr->reason = (char *) epp_malloc(pool, len);	if (valerr->reason == NULL)		return;	strncpy(valerr->reason, error->message, --len); /*truncate trailing /n */	(valerr->reason)[len] = '/0';	/* XXX this needs to be done better way */	/*	 * recognized errors:	 *    unknown command (2000)	 *    required parameter missing (2003)	 *    Parameter value range error (2004)	 *    Parameter value syntax error (2005)	 *    Unimplemented extension (2103)	 *    ???Unimplemented command (2101)???	 *    ???Unimplemented option (2102)???	 * all other errors are reported as:	 *    command syntax error (2001)	 */	/* get content of problematic tag */	buf = xmlBufferCreate();	if (buf == NULL)		return;	node = (xmlNodePtr) error->node;	if (node->ns != NULL) {		xmlNsPtr	 nsdef;		nsdef = xmlSearchNs(doc, node, node->ns->prefix);		if (nsdef != NULL)			xmlNewNs(node, nsdef->href, nsdef->prefix);	}	if (xmlNodeDump(buf, doc, (xmlNodePtr) node, 0, 0) < 0) {		xmlBufferFree(buf);		return;	}	valerr->value = epp_strdup(pool, (char *) buf->content);	xmlBufferFree(buf);	if (valerr->value == NULL)		return;	valerr->spec = errspec_not_valid; /* surrounding tags are included */	/* enqueue new error item */	if (q_add(pool, error_list, valerr))		/* we have nothing to do here in case of error */		return;}
开发者ID:LANJr4D,项目名称:FRED,代码行数:91,


示例25: relink_namespace

/* :nodoc: */static void relink_namespace(xmlNodePtr reparented){  xmlChar *name, *prefix;  xmlNodePtr child;  xmlNsPtr ns;  if (reparented->type != XML_ATTRIBUTE_NODE &&      reparented->type != XML_ELEMENT_NODE) return;  if (reparented->ns == NULL || reparented->ns->prefix == NULL) {    name = xmlSplitQName2(reparented->name, &prefix);    if(reparented->type == XML_ATTRIBUTE_NODE) {      if (prefix == NULL || strcmp((char*)prefix, XMLNS_PREFIX) == 0) return;    }    ns = xmlSearchNs(reparented->doc, reparented, prefix);    if (ns == NULL && reparented->parent) {      ns = xmlSearchNs(reparented->doc, reparented->parent, prefix);    }    if (ns != NULL) {      xmlNodeSetName(reparented, name);      xmlSetNs(reparented, ns);    }  }  /* Avoid segv when relinking against unlinked nodes. */  if (reparented->type != XML_ELEMENT_NODE || !reparented->parent) return;  /* Make sure that our reparented node has the correct namespaces */  if(!reparented->ns && reparented->doc != (xmlDocPtr)reparented->parent)    xmlSetNs(reparented, reparented->parent->ns);  /* Search our parents for an existing definition */  if(reparented->nsDef) {    xmlNsPtr curr = reparented->nsDef;    xmlNsPtr prev = NULL;    while(curr) {      xmlNsPtr ns = xmlSearchNsByHref(          reparented->doc,          reparented->parent,          curr->href      );      /* If we find the namespace is already declared, remove it from this       * definition list. */      if(ns && ns != curr) {        if (prev) {          prev->next = curr->next;        } else {          reparented->nsDef = curr->next;        }        nokogiri_root_nsdef(curr, reparented->doc);      } else {        prev = curr;      }      curr = curr->next;    }  }  /* Only walk all children if there actually is a namespace we need to */  /* reparent. */  if(NULL == reparented->ns) return;  /* When a node gets reparented, walk it's children to make sure that */  /* their namespaces are reparented as well. */  child = reparented->children;  while(NULL != child) {    relink_namespace(child);    child = child->next;  }  if (reparented->type == XML_ELEMENT_NODE) {    child = (xmlNodePtr)((xmlElementPtr)reparented)->attributes;    while(NULL != child) {      relink_namespace(child);      child = child->next;    }  }}
开发者ID:RubyShare,项目名称:nokogiri,代码行数:83,


示例26: EBC_Provider_SignMessage_X001

static int EBC_Provider_SignMessage_X001(AB_PROVIDER *pro,					 EB_MSG *msg,					 AB_USER *u,					 xmlNodePtr node) {  EBC_PROVIDER *dp;  int rv;  GWEN_CRYPT_TOKEN *ct;  const GWEN_CRYPT_TOKEN_CONTEXT *ctx;  const GWEN_CRYPT_TOKEN_KEYINFO *ki;  uint32_t keyId;  GWEN_BUFFER *hbuf;  GWEN_BUFFER *bbuf;  xmlNodePtr nodeX = NULL;  xmlNodePtr nodeXX = NULL;  xmlNodePtr nodeXXX = NULL;  xmlNodePtr nodeXXXX = NULL;  xmlNsPtr ns;  assert(pro);  dp=GWEN_INHERIT_GETDATA(AB_PROVIDER, EBC_PROVIDER, pro);  assert(dp);  /* get crypt token and context */  rv=EBC_Provider_MountToken(pro, u, &ct, &ctx);  if (rv<0) {    DBG_INFO(AQEBICS_LOGDOMAIN, "here (%d)", rv);    return rv;  }  /* get key id */  keyId=GWEN_Crypt_Token_Context_GetAuthSignKeyId(ctx);  ki=GWEN_Crypt_Token_GetKeyInfo(ct,				 keyId,				 0xffffffff,				 0);  if (ki==NULL) {    DBG_INFO(AQEBICS_LOGDOMAIN,	     "Keyinfo %04x not found on crypt token [%s:%s]",	     keyId,	     GWEN_Crypt_Token_GetTypeName(ct),	     GWEN_Crypt_Token_GetTokenName(ct));    GWEN_Crypt_Token_Close(ct, 0, 0);    return GWEN_ERROR_NOT_FOUND;  }  /* prepare signature nodes */  ns=xmlSearchNs(EB_Msg_GetDoc(msg), node, BAD_CAST "ds");  assert(ns);  /* build hash */  bbuf=GWEN_Buffer_new(0, 256, 0, 1);  rv=EB_Msg_BuildHashSha1(msg, bbuf);  if (rv) {    DBG_ERROR(AQEBICS_LOGDOMAIN, "Could not build hash");    GWEN_Buffer_free(bbuf);    return rv;  }  /* base64 encode */  hbuf=GWEN_Buffer_new(0, 256, 0, 1);  rv=GWEN_Base64_Encode((const uint8_t*)GWEN_Buffer_GetStart(bbuf),			GWEN_Buffer_GetUsedBytes(bbuf),			hbuf, 0);  if (rv<0) {    DBG_INFO(AQEBICS_LOGDOMAIN, "here (%d)", rv);    GWEN_Buffer_free(hbuf);    GWEN_Buffer_free(bbuf);    return rv;  }  GWEN_Buffer_free(bbuf);  /* create signature node */  nodeX=xmlNewChild(node, ns, BAD_CAST "SignedInfo", NULL);  nodeXX=xmlNewChild(nodeX, ns, BAD_CAST "CanonicalizationMethod", NULL);  xmlNewProp(nodeXX,	     BAD_CAST "Algorithm",	     BAD_CAST "http://www.w3.org/TR/2001/REC-xml-c14n-20010315");  nodeXX=xmlNewChild(nodeX, ns, BAD_CAST "SignatureMethod", NULL);  xmlNewProp(nodeXX,	     BAD_CAST "Algorithm",	     BAD_CAST "http://www.w3.org/2000/09/xmldsig#rsa-sha1");  nodeXX=xmlNewChild(nodeX, ns, BAD_CAST "Reference", NULL);  xmlNewProp(nodeXX,	     BAD_CAST "URI",	     BAD_CAST "#xpointer(//*[@authenticate='true'])");  nodeXXX=xmlNewChild(nodeXX, ns, BAD_CAST "Transforms", NULL);  nodeXXXX=xmlNewChild(nodeXXX, ns, BAD_CAST "Transform", NULL);  xmlNewProp(nodeXXXX,	     BAD_CAST "Algorithm",	     BAD_CAST "http://www.w3.org/TR/2001/REC-xml-c14n-20010315");  nodeXXX=xmlNewChild(nodeXX, ns, BAD_CAST "DigestMethod", NULL);  xmlNewProp(nodeXXX,	     BAD_CAST "Algorithm",	     BAD_CAST "http://www.w3.org/2000/09/xmldsig#sha1");  /* store hash value */  xmlNewTextChild(nodeXX, ns,		  BAD_CAST "DigestValue",		  BAD_CAST GWEN_Buffer_GetStart(hbuf));//.........这里部分代码省略.........
开发者ID:Zauberstuhl,项目名称:aqbanking,代码行数:101,


示例27: rest_show_check

//.........这里部分代码省略.........  node = (mtev_conf_section_t)xmlXPathNodeSetItem(pobj->nodesetval, 0);  uuid_conf = (char *)xmlGetProp(node, (xmlChar *)"uuid");  if(!uuid_conf || uuid_parse(uuid_conf, checkid)) goto error;  if(npats == 3 && !strcmp(pats[2], ".json")) {    return rest_show_check_json(restc, checkid);  }  doc = xmlNewDoc((xmlChar *)"1.0");  root = xmlNewDocNode(doc, NULL, (xmlChar *)"check", NULL);  xmlDocSetRootElement(doc, root);#define MYATTR(node,a,n,b) _mtev_conf_get_string(node, &(n), "@" #a, &(b))#define INHERIT(node,a,n,b) /  _mtev_conf_get_string(node, &(n), "ancestor-or-self::node()/@" #a, &(b))#define SHOW_ATTR(parent, node, a) do { /  char *_value = NULL; /  INHERIT(node, a, anode, _value); /  if(_value != NULL) { /    int clen, plen;/    char *_cpath, *_apath; /    xmlNodePtr child; /    _cpath = node ? (char *)xmlGetNodePath(node) : strdup(""); /    _apath = anode ? (char *)xmlGetNodePath(anode) : strdup(""); /    clen = strlen(_cpath); /    plen = strlen("/noit/checks"); /    child = xmlNewNode(NULL, (xmlChar *)#a); /    xmlNodeAddContent(child, (xmlChar *)_value); /    if(!strncmp(_cpath, _apath, clen) && _apath[clen] == '/') { /    } /    else { /      xmlSetProp(child, (xmlChar *)"inherited", (xmlChar *)_apath+plen); /    } /    xmlAddChild(parent, child); /    free(_cpath); /    free(_apath); /    free(_value); /  } /} while(0)  attr = xmlNewNode(NULL, (xmlChar *)"attributes");  xmlAddChild(root, attr);  SHOW_ATTR(attr,node,uuid);  SHOW_ATTR(attr,node,seq);  /* Name is odd, it falls back transparently to module */  if(!INHERIT(node, module, tmp, module)) module = NULL;  xmlAddChild(attr, (tmp = xmlNewNode(NULL, (xmlChar *)"name")));  if(MYATTR(node, name, anode, value))    xmlNodeAddContent(tmp, (xmlChar *)value);  else if(module)    xmlNodeAddContent(tmp, (xmlChar *)module);  if(value) free(value);  if(module) free(module);  SHOW_ATTR(attr,node,module);  SHOW_ATTR(attr,node,target);  SHOW_ATTR(attr,node,resolve_rtype);  SHOW_ATTR(attr,node,seq);  SHOW_ATTR(attr,node,period);  SHOW_ATTR(attr,node,timeout);  SHOW_ATTR(attr,node,oncheck);  SHOW_ATTR(attr,node,filterset);  SHOW_ATTR(attr,node,disable);  /* Add the config */  config = xmlNewNode(NULL, (xmlChar *)"config");  configh = mtev_conf_get_hash(node, "config");  while(mtev_hash_next(configh, &iter, &k, &klen, &data))    NODE_CONTENT(config, k, data);  mtev_hash_destroy(configh, free, free);  free(configh);  mod_cnt = noit_check_registered_module_cnt();  for(mod=0; mod<mod_cnt; mod++) {    xmlNsPtr ns;    const char *nsname;    char buff[256];    nsname = noit_check_registered_module(mod);     snprintf(buff, sizeof(buff), "noit://module/%s", nsname);    ns = xmlSearchNs(root->doc, root, (xmlChar *)nsname);    if(!ns) ns = xmlNewNs(root, (xmlChar *)buff, (xmlChar *)nsname);    if(ns) {      configh = mtev_conf_get_namespaced_hash(node, "config", nsname);      if(configh) {        memset(&iter, 0, sizeof(iter));        while(mtev_hash_next(configh, &iter, &k, &klen, &data)) {          NS_NODE_CONTENT(config, ns, "value", data,            xmlSetProp(tmp, (xmlChar *)"name", (xmlChar *)k);          );        }        mtev_hash_destroy(configh, free, free);        free(configh);      }    }  }
开发者ID:damajor,项目名称:reconnoiter,代码行数:101,


示例28: xmlelem_getAttribute

static HRESULT WINAPI xmlelem_getAttribute(IXMLElement *iface, BSTR name,    VARIANT *value){    static const WCHAR xmllangW[] = { 'x','m','l',':','l','a','n','g',0 };    xmlelem *This = impl_from_IXMLElement(iface);    xmlChar *val = NULL;    TRACE("(%p)->(%s, %p)/n", This, debugstr_w(name), value);    if (!value)        return E_INVALIDARG;    VariantInit(value);    V_BSTR(value) = NULL;    if (!name)        return E_INVALIDARG;    /* case for xml:lang attribute */    if (!lstrcmpiW(name, xmllangW))    {        xmlNsPtr ns;        ns = xmlSearchNs(This->node->doc, This->node, (xmlChar*)"xml");        val = xmlGetNsProp(This->node, (xmlChar*)"lang", ns->href);    }    else    {        xmlAttrPtr attr;        xmlChar *xml_name;        xml_name = xmlchar_from_wchar(name);        attr = This->node->properties;        while (attr)        {            BSTR attr_name;            attr_name = bstr_from_xmlChar(attr->name);            if (!lstrcmpiW(name, attr_name))            {                val = xmlNodeListGetString(attr->doc, attr->children, 1);                SysFreeString(attr_name);                break;            }            attr = attr->next;            SysFreeString(attr_name);        }        heap_free(xml_name);    }    if (val)    {        V_VT(value) = VT_BSTR;        V_BSTR(value) = bstr_from_xmlChar(val);    }    xmlFree(val);    TRACE("returning %s/n", debugstr_w(V_BSTR(value)));    return (val) ? S_OK : S_FALSE;}
开发者ID:GYGit,项目名称:reactos,代码行数:61,



注:本文中的xmlSearchNs函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ xmlSecAssert2函数代码示例
C++ xmlSaveFormatFileEnc函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。