本文整理汇总了C++中xmlSetNs函数的典型用法代码示例。如果您正苦于以下问题:C++ xmlSetNs函数的具体用法?C++ xmlSetNs怎么用?C++ xmlSetNs使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xmlSetNs函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_xmlNode
static xmlNode*
get_xmlNode(LassoNode *node, G_GNUC_UNUSED gboolean lasso_dump)
{
xmlNode *xmlnode;
LassoIdentity *identity = LASSO_IDENTITY(node);
#ifdef LASSO_WSF_ENABLED
xmlNode *t;
#endif
xmlnode = xmlNewNode(NULL, (xmlChar*)"Identity");
xmlSetNs(xmlnode, xmlNewNs(xmlnode, (xmlChar*)LASSO_LASSO_HREF, NULL));
xmlSetProp(xmlnode, (xmlChar*)"Version", (xmlChar*)"2");
/* Federations */
if (g_hash_table_size(identity->federations))
g_hash_table_foreach(identity->federations,
(GHFunc)add_childnode_from_hashtable, xmlnode);
#ifdef LASSO_WSF_ENABLED
/* Resource Offerings */
g_hash_table_foreach(identity->private_data->resource_offerings_map,
(GHFunc)add_childnode_from_hashtable, xmlnode);
/* Service Metadatas IDs (svcMDID) */
if (identity->private_data->svcMDID != NULL) {
t = xmlNewTextChild(xmlnode, NULL, (xmlChar*)"SvcMDIDs", NULL);
g_list_foreach(identity->private_data->svcMDID,
(GFunc)add_text_childnode_from_list, t);
}
#endif
return xmlnode;
}
示例2: recursively_remove_namespaces_from_node
static void recursively_remove_namespaces_from_node(xmlNodePtr node)
{
xmlNodePtr child ;
xmlAttrPtr property ;
xmlSetNs(node, NULL);
for (child = node->children ; child ; child = child->next)
recursively_remove_namespaces_from_node(child);
if (((node->type == XML_ELEMENT_NODE) ||
(node->type == XML_XINCLUDE_START) ||
(node->type == XML_XINCLUDE_END)) &&
node->nsDef) {
xmlFreeNsList(node->nsDef);
node->nsDef = NULL;
}
if (node->type == XML_ELEMENT_NODE && node->properties != NULL) {
property = node->properties ;
while (property != NULL) {
if (property->ns) property->ns = NULL ;
property = property->next ;
}
}
}
示例3: node_add_child
static int node_add_child(lua_State *L) {
xmlNodePtr node = lua_touserdata(L, 1);
const char *name = lua_tostring(L, 2);
const char *ns_href = lua_tostring(L, 3);
xmlNsPtr ns = NULL;
if (node == NULL) return luaL_error(L, "add_child: Invalid parent node");
if (node->type != XML_ELEMENT_NODE) return luaL_error(L, "add_child: Invalid parent node type (not element node)");
if (name == NULL) return luaL_error(L, "I can't create node without its name");
xmlNodePtr child;
if (ns_href != NULL) { //add namespace requested
ns = xmlSearchNsByHref(node->doc, node, BAD_CAST ns_href); //try to find ns
}
if (ns_href != NULL && ns == NULL) { //ns requested and not found
child = xmlNewChild(node, ns, BAD_CAST name, NULL); //crete node w/o ns
ns = xmlNewNs(child, BAD_CAST ns_href, NULL); //create namespace and define it in child
if (ns == NULL) return luaL_error(L, "Namespace allocation error.");
xmlSetNs(child, ns); //set new ns to child
} else {
child = xmlNewChild(node, ns, BAD_CAST name, NULL); //ns nor requested ir was found... use it
}
lua_pushlightuserdata(L, child);
luaL_setmetatable(L, WRAP_XMLNODE);
return 1;
}
示例4: processDoc
static int processDoc(xmlDoc *doc, lpc2xml_context *ctx) {
int ret = 0;
xmlNs *xsi_ns;
xmlNs *lpc_ns;
xmlAttr *schemaLocation;
xmlNode *root_node = xmlNewNode(NULL, (const xmlChar *)"config");
if(root_node == NULL) {
lpc2xml_log(ctx, LPC2XML_ERROR, "Can't create \"config\" element");
return -1;
}
lpc_ns = xmlNewNs(root_node, (const xmlChar *)"http://www.linphone.org/xsds/lpconfig.xsd", NULL);
if(lpc_ns == NULL) {
lpc2xml_log(ctx, LPC2XML_WARNING, "Can't create lpc namespace");
} else {
xmlSetNs(root_node, lpc_ns);
}
xsi_ns = xmlNewNs(root_node, (const xmlChar *)"http://www.w3.org/2001/XMLSchema-instance", (const xmlChar *)"xsi");
if(lpc_ns == NULL) {
lpc2xml_log(ctx, LPC2XML_WARNING, "Can't create xsi namespace");
}
schemaLocation = xmlNewNsProp(root_node, xsi_ns, (const xmlChar *)"schemaLocation", (const xmlChar *)"http://www.linphone.org/xsds/lpconfig.xsd lpconfig.xsd");
if(schemaLocation == NULL) {
lpc2xml_log(ctx, LPC2XML_WARNING, "Can't create schemaLocation");
}
ret = processConfig(root_node, ctx);
xmlDocSetRootElement(doc, root_node);
return ret;
}
示例5: add_project
static xmlNodePtr
add_project (GPInstructProject *project)
{
GPInstructCategory *curr_category;
GList *categories, *curr_categories;
xmlNodePtr node = xmlNewNode (NULL, BAD_CAST "project");
xmlSetProp (node, BAD_CAST "title",
BAD_CAST gpinstruct_project_get_title (project));
xmlSetNs (node, xmlNewNs (node,
BAD_CAST PACKAGE_URL,
BAD_CAST PACKAGE_TARNAME));
categories = gpinstruct_project_get_categories (project);
curr_categories = categories;
while (curr_categories)
{
curr_category = GPINSTRUCT_CATEGORY (curr_categories->data);
add_category (curr_category, node);
curr_categories = curr_categories->next;
}
g_list_free (categories);
return node;
}
示例6: wi_p7_message_init_with_name
wi_p7_message_t * wi_p7_message_init_with_name(wi_p7_message_t *p7_message, wi_string_t *message_name, wi_p7_socket_t *p7_socket) {
p7_message = wi_p7_message_init(p7_message, p7_socket);
if(p7_message->serialization == WI_P7_BINARY) {
p7_message->binary_capacity = _WI_P7_MESSAGE_BINARY_BUFFER_INITIAL_SIZE;
p7_message->binary_buffer = wi_malloc(p7_message->binary_capacity);
p7_message->binary_size = _WI_P7_MESSAGE_BINARY_HEADER_SIZE;
} else {
p7_message->xml_doc = xmlNewDoc((xmlChar *) "1.0");
p7_message->xml_root_node = xmlNewNode(NULL, (xmlChar *) "message");
xmlDocSetRootElement(p7_message->xml_doc, p7_message->xml_root_node);
p7_message->xml_ns = xmlNewNs(p7_message->xml_root_node, (xmlChar *) "http://www.zankasoftware.com/P7/Message", (xmlChar *) "p7");
xmlSetNs(p7_message->xml_root_node, p7_message->xml_ns);
}
if(!wi_p7_message_set_name(p7_message, message_name)) {
wi_release(p7_message);
return NULL;
}
return p7_message;
}
示例7: jal_create_base64_element
enum jal_status jal_create_base64_element(
xmlDocPtr doc,
const uint8_t *buffer,
const size_t buf_len,
const xmlChar *namespace_uri,
const xmlChar *elm_name,
xmlNodePtr *new_elem)
{
if (!doc || !buffer || (buf_len == 0) || !namespace_uri ||
!elm_name || !new_elem || *new_elem) {
return JAL_E_INVAL;
}
char *base64_val = NULL;
xmlChar *xml_base64_val = NULL;
base64_val = jal_base64_enc(buffer, buf_len);
if (!base64_val) {
// this should never actually happen since the input is
// non-zero in length.
return JAL_E_INVAL;
}
xml_base64_val = (xmlChar *)base64_val;
xmlNodePtr elm = xmlNewDocNode(doc, NULL, elm_name, NULL);
xmlNsPtr ns = xmlNewNs(elm, namespace_uri, NULL);
xmlSetNs(elm, ns);
xmlNodeAddContent(elm, xml_base64_val);
free(base64_val);
*new_elem = elm;
return JAL_OK;
}
示例8: new_xml_doc
/*
* Create new document and edit document handlers
*/
static int new_xml_doc(lua_State *L) {
const char *name = lua_tostring(L, 1);
const char *ns_href = lua_tostring(L, 2);
xmlNsPtr ns = NULL;
if (name == NULL) return luaL_error(L, "new_xml_doc needs name of root node.");
/**
* http://www.acooke.org/cute/Usinglibxm0.html was very helpful with this issue
*/
xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0"); //create document
xmlNodePtr root_node = xmlNewNode(NULL, BAD_CAST name); //create root node
if (doc == NULL || root_node == NULL) return luaL_error(L, "New document allocation error.");
if (ns_href != NULL) { //if NS is requested
ns = xmlNewNs(root_node, BAD_CAST ns_href, NULL);
if (ns == NULL) return luaL_error(L, "Namespace allocation error.");
xmlSetNs(root_node, ns);
}
struct xmlwrap_object *xml2 = lua_newuserdata(L, sizeof(*xml2));
luaL_setmetatable(L, WRAP_XMLDOC);
xml2->doc = doc;
xmlDocSetRootElement(xml2->doc, root_node);
return 1;
}
示例9: get_xmlNode
static xmlNode*
get_xmlNode(LassoNode *node, gboolean lasso_dump)
{
xmlNode *xmlnode, *t;
xmlnode = parent_class->get_xmlNode(node, lasso_dump);
if (LASSO_SAMLP_RESPONSE(node)->Status &&
has_lib_status(LASSO_SAMLP_RESPONSE(node)->Status->StatusCode)) {
/* liberty QName, add liberty namespace */
xmlNewNs(xmlnode, (xmlChar*)LASSO_LIB_HREF, (xmlChar*)LASSO_LIB_PREFIX);
}
for (t = xmlnode->children; t && strcmp((char*)t->name, "Assertion"); t = t->next) ;
if (t && strcmp((char*)t->ns->href, LASSO_LIB_HREF) == 0) {
/* liberty nodes are not allowed in samlp nodes */
xmlSetNs(t, xmlNewNs(xmlnode, (xmlChar*)LASSO_SAML_ASSERTION_HREF,
(xmlChar*)LASSO_SAML_ASSERTION_PREFIX));
if (xmlHasNsProp(t, (xmlChar*)"type", (xmlChar*)LASSO_XSI_HREF) == NULL)
xmlNewNsProp(t, xmlNewNs(xmlnode,
(xmlChar*)LASSO_XSI_HREF,
(xmlChar*)LASSO_XSI_PREFIX),
(xmlChar*)"type", (xmlChar*)"lib:AssertionType");
}
return xmlnode;
}
示例10: insure_namespace
static void
insure_namespace(xmlNode *xmlnode, xmlNs *ns)
{
/* insure children are kept in saml namespace */
xmlNode *t;
xmlNs *xsi_ns;
t = xmlnode->children;
while (t) {
if (t->type != XML_ELEMENT_NODE) {
t = t->next;
continue;
}
if (xmlnode->ns && strcmp((char*)xmlnode->ns->href, LASSO_LIB_HREF) == 0) {
char *typename, *gtypename;
GType gtype;
typename = g_strdup_printf("lib:%sType", xmlnode->name);
gtypename = g_strdup_printf("LassoSaml%s", xmlnode->name);
gtype = g_type_from_name(gtypename);
if (gtype) {
xmlSetNs(xmlnode, ns);
if (xmlHasNsProp(t, (xmlChar*)"type",
(xmlChar*)LASSO_XSI_HREF) == NULL) {
xsi_ns = xmlNewNs(xmlnode, (xmlChar*)LASSO_XSI_HREF,
(xmlChar*)LASSO_XSI_PREFIX);
xmlNewNsProp(xmlnode, xsi_ns, (xmlChar*)"type",
(xmlChar*)typename);
}
}
lasso_release(gtypename);
lasso_release(typename);
}
示例11: R_getAncestorDefaultNSDef
SEXP
R_getAncestorDefaultNSDef(SEXP r_node, SEXP r_recursive)
{
xmlNodePtr cur, node;
xmlNs *ans = NULL;
cur = (xmlNodePtr) R_ExternalPtrAddr(r_node);
node = cur->parent;
while(node && (node->type != XML_DOCUMENT_NODE &&
node->type != XML_HTML_DOCUMENT_NODE)) { /* Need to check for HTML_DOC or XML_DOC ?*/
ans = findNSByPrefix(node, NULL);
if(ans)
break;
node = node->parent;
}
if(ans) {
xmlSetNs(cur, ans);
if(LOGICAL(r_recursive)[0]) {
setDefaultNs(cur, ans, 1);
}
return(ScalarLogical(1)); // R_createXMLNsRef(ans));
}
return(R_NilValue);
}
示例12: jal_create_audit_transforms_elem
enum jal_status jal_create_audit_transforms_elem(
xmlDocPtr doc,
xmlNodePtr *new_elem)
{
if (!new_elem || *new_elem || !doc) {
return JAL_E_XML_CONVERSION;
}
xmlChar *namespace_uri = (xmlChar *)JAL_XMLDSIG_URI;
xmlNodePtr out_elem = xmlNewDocNode(doc, NULL, (xmlChar *) JAL_XML_TRANSFORMS, NULL);
xmlNsPtr ns = xmlNewNs(out_elem, namespace_uri, NULL);
xmlSetNs(out_elem, ns);
xmlNodePtr transform_elem = xmlNewChild(
out_elem, NULL,
(xmlChar *) JAL_XML_TRANSFORM,
NULL);
xmlSetProp(transform_elem,
(xmlChar *) JAL_XML_ALGORITHM, (xmlChar *) JAL_XML_WITH_COMMENTS);
*new_elem = out_elem;
return JAL_OK;
}
示例13: xmlNewDocNode
xmlNode* child_node_list::create_element_(const std::string& qname, const std::string& uri)
{
// 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;
// Create element without namespace.
xmlNode* px = xmlNewDocNode( raw_->doc,
0,
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);
}
// Declare XML namespace on the element, and put the element under it.
xmlNs* ns = xmlNewNs( px,
detail::to_xml_chars(uri.c_str()),
prefix.empty() ? 0 : detail::to_xml_chars(prefix.c_str()) );
if (ns == 0)
{
// TODO: delete the node.
std::string what = "fail to create libxml2 namespace for " + prefix + "=" + uri;
throw internal_dom_error(what);
}
xmlSetNs(px, ns);
// Return the new element.
return px;
}
示例14: write_xml_schematic
// Create an XML subtree of doc equivalent to the given Schematic.
static xmlNodePtr
write_xml_schematic (parseXmlContext *ctxt, Schematic *sm, GError **error)
{
xmlNodePtr cur;
xmlNodePtr grid;
xmlNsPtr ogo;
gchar *str;
cur = xmlNewDocNode (ctxt->doc, ctxt->ns, BAD_CAST "schematic", NULL);
if (cur == NULL) {
printf ("%s:%d NULL that shall be not NULL!\n", __FILE__,
__LINE__);
return NULL;
}
if (ctxt->ns == NULL) {
ogo = xmlNewNs (cur,
BAD_CAST "http://www.dtek.chalmers.se/~d4hult/oregano/v1",
BAD_CAST "ogo");
xmlSetNs (cur,ogo);
ctxt->ns = ogo;
}
// General information about the Schematic.
str = g_strdup_printf ("%s", schematic_get_author (sm));
xmlNewChild (cur, ctxt->ns, BAD_CAST "author", xmlEncodeEntitiesReentrant (ctxt->doc, BAD_CAST str));
g_free (str);
str = g_strdup_printf ("%s", schematic_get_title (sm));
xmlNewChild (cur, ctxt->ns, BAD_CAST "title", xmlEncodeEntitiesReentrant (ctxt->doc, BAD_CAST str));
g_free (str);
str = g_strdup_printf ("%s", schematic_get_comments (sm));
xmlNewChild (cur, ctxt->ns, BAD_CAST "comments", xmlEncodeEntitiesReentrant (ctxt->doc, BAD_CAST str));
g_free (str);
// Grid.
grid = xmlNewChild (cur, ctxt->ns, BAD_CAST "grid", NULL);
xmlNewChild (grid, ctxt->ns, BAD_CAST "visible", BAD_CAST "true");
xmlNewChild (grid, ctxt->ns, BAD_CAST "snap", BAD_CAST "true");
// Simulation settings.
write_xml_sim_settings (cur, ctxt, sm);
// Parts.
ctxt->node_parts = xmlNewChild (cur, ctxt->ns, BAD_CAST "parts", NULL);
schematic_parts_foreach (sm, (gpointer) write_xml_part, ctxt);
// Wires.
ctxt->node_wires = xmlNewChild (cur, ctxt->ns, BAD_CAST "wires", NULL);
schematic_wires_foreach (sm, (gpointer) write_xml_wire, ctxt);
// Text boxes.
ctxt->node_textboxes = xmlNewChild (cur, ctxt->ns, BAD_CAST "textboxes", NULL);
schematic_items_foreach (sm, (gpointer) write_xml_textbox, ctxt);
return cur;
}
示例15: recursively_remove_namespaces_from_node
static void recursively_remove_namespaces_from_node(xmlNodePtr node)
{
xmlNodePtr child ;
xmlSetNs(node, NULL);
for (child = node->children ; child ; child = child->next)
recursively_remove_namespaces_from_node(child);
}