Example #1
0
static xmlNodePtr
phone_number_to_xmlnode (GDataEntryPhoneNumber *number)
{

	xmlNodePtr number_node;

	number_node = xmlNewNode(NULL, (xmlChar *)"phoneNumber");
	xmlSetNs (number_node, xmlNewNs (number_node, NULL, (xmlChar *)"gd"));
	if (number->uri)
		xmlSetProp (number_node, (xmlChar *)"uri", (xmlChar *)number->uri);

	if (number->rel)
		xmlSetProp (number_node, (xmlChar *)"rel", (xmlChar *)number->rel);

	if (number->label)
		xmlSetProp (number_node, (xmlChar *)"label", (xmlChar *)number->label);
	
	if (number->primary)
		xmlSetProp (number_node, (xmlChar *)"primary", (xmlChar *)"true");

	if (number->number)
		xmlNodeAddContent(number_node, (xmlChar *)number->number);

	return number_node;
}
Example #2
0
static xmlNodePtr
organization_to_xmlnode (GDataEntryOrganization *organization)
{

	xmlNodePtr organization_node;

	organization_node = xmlNewNode(NULL, (xmlChar *)"organization");
	xmlSetNs (organization_node, xmlNewNs (organization_node, NULL, (xmlChar *)"gd"));
	if (organization->rel)
		xmlSetProp (organization_node, (xmlChar *)"rel", (xmlChar *)organization->rel);

	if (organization->label)
		xmlSetProp (organization_node, (xmlChar *)"label", (xmlChar *)organization->label);
	
	if (organization->primary)
		xmlSetProp (organization_node, (xmlChar *)"primary", (xmlChar *)"true");

	if (organization->name)
		xmlNewTextChild (organization_node, NULL, (xmlChar *)"orgName", (xmlChar *)organization->name);

	if (organization->title)
		xmlNewTextChild (organization_node, NULL, (xmlChar *)"orgTitle", (xmlChar *)organization->title);

	return organization_node;
}
Example #3
0
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;
}
Example #4
0
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 ;
    }
  }
}
Example #5
0
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;
}
Example #6
0
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;
}
Example #7
0
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;
}
Example #8
0
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;
}
Example #9
0
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;
}
Example #10
0
/*
 * 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;
}
Example #11
0
/**
 *  Prepare XSLT stylesheet based on command line options
 */
int
selPrepareXslt(xmlDocPtr style, selOptionsPtr ops, xmlChar *ns_arr[],
               int start, int argc, char **argv)
{
    int i, t, ns, use_inputfile = 0, use_value_of = 0;
    xmlNodePtr root, root_template = NULL;
    xmlNsPtr xslns;
    xmlBufferPtr attr_buf;

    root = xmlNewDocRawNode(style, NULL, BAD_CAST "stylesheet", NULL);
    xmlDocSetRootElement(style, root);
    xmlNewProp(root, BAD_CAST "version", BAD_CAST "1.0");
    xslns = xmlNewNs(root, XSLT_NAMESPACE, BAD_CAST "xsl");
    xmlSetNs(root, xslns);

    ns = 0;
    while(ns_arr[ns])
    {
        xmlNewNs(root, ns_arr[ns+1], xmlStrlen(ns_arr[ns])?ns_arr[ns] : NULL);
        ns += 2;
    }
    cleanupNSArr(ns_arr);

    {
        xmlNodePtr output;
        output = xmlNewChild(root, xslns, BAD_CAST "output", NULL);
        xmlNewProp(output, BAD_CAST "omit-xml-declaration",
            BAD_CAST ((ops->no_omit_decl)?"no":"yes"));
        xmlNewProp(output, BAD_CAST "indent",
            BAD_CAST ((ops->indent)?"yes":"no"));
        if (ops->encoding) xmlNewProp(output, BAD_CAST "encoding", ops->encoding);
        if (ops->outText) xmlNewProp(output, BAD_CAST "method", BAD_CAST "text");
    }

    for (i = start, t = 0; i < argc; i++)
        if(!strcmp(argv[i], "-t") || !strcmp(argv[i], "--template"))
            t++;

    /*
     *  At least one -t option must be found
     */
    if (t == 0)
    {
        fprintf(stderr, "error in arguments:");
        fprintf(stderr, " no -t or --template options found\n");
        exit(EXIT_BAD_ARGS);
    }

    if (t > 1)
        root_template = xmlNewChild(root, xslns, BAD_CAST "template", NULL);

    t = 0;
    i = start;
    while(i < argc)
    {
        if(!strcmp(argv[i], "-t") || !strcmp(argv[i], "--template"))
        {
            xmlNodePtr call_template, template;
            int lastTempl = 0;
            t++;
Example #12
0
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;
}
Example #13
0
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);
		}
Example #14
0
File: fixNS.c Project: omegahat/XML
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);
}
Example #15
0
static xmlNodePtr
im_address_to_xmlnode (GDataEntryIMAddress *im)
{

	xmlNodePtr im_node;

	im_node = xmlNewNode(NULL, (xmlChar *)"im");
	xmlSetNs (im_node, xmlNewNs (im_node, NULL, (xmlChar *)"gd"));
	if (im->address)
		xmlSetProp (im_node, (xmlChar *)"address", (xmlChar *)im->address);

	if (im->protocol)
		xmlSetProp (im_node, (xmlChar *)"protocol", (xmlChar *)im->protocol);

	if (im->rel)
		xmlSetProp (im_node, (xmlChar *)"rel", (xmlChar *)im->rel);

	if (im->label)
		xmlSetProp (im_node, (xmlChar *)"label", (xmlChar *)im->label);
	
	if (im->primary)
		xmlSetProp (im_node, (xmlChar *)"primary", (xmlChar *)"true");

	return im_node;
}
Example #16
0
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;
}
Example #17
0
 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;
 }
Example #18
0
// 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;
}
Example #19
0
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);
}
Example #20
0
File: webdav.c Project: JuanS/uwsgi
static void uwsgi_webdav_add_a_prop(xmlNode *node, char *opt, xmlNode *req_prop, int type, char *force_name) {
	char *first_space = strchr(opt, ' ');
	if (!first_space) return;
	*first_space = 0;
	char *second_space = strchr(first_space + 1, ' ');
	xmlNode *new_node = NULL;
	char *ns = opt;
	if (!force_name) force_name = first_space + 1;
	else {
		ns = "DAV:";
	}
	if (second_space) {
		*second_space = 0;
		if (!uwsgi_webdav_prop_requested(req_prop, ns, force_name)) {
                	*first_space = ' ';
                        *second_space = ' ';
                        return;
                }
		// href
		if (type == 1) {
			new_node = xmlNewChild(node, NULL, BAD_CAST first_space + 1, NULL);
			xmlNewTextChild(new_node, NULL, BAD_CAST "href", BAD_CAST second_space + 1);
		}
		// comp
		else if (type == 2) {
			new_node = xmlNewChild(node, NULL, BAD_CAST first_space + 1, NULL);
			char *comps = uwsgi_str(second_space + 1);
			char *p = strtok(comps, ",");
			while(p) {
				xmlNode *comp = xmlNewChild(new_node, NULL, BAD_CAST "comp", NULL);
				xmlNewProp(comp, BAD_CAST "name", BAD_CAST p);
				p = strtok(NULL, ",");
			}
			free(comps);
		}
		else {
			if (!uwsgi_webdav_prop_requested(req_prop, ns, first_space + 1)) {
                                *first_space = ' ';
                                *second_space = ' ';
                                return;
                        }
			new_node = xmlNewTextChild(node, NULL, BAD_CAST first_space + 1, BAD_CAST second_space + 1);
		}
		*second_space = ' ';
	}
	else {
		if (!uwsgi_webdav_prop_requested(req_prop, ns, force_name)) {
                        *first_space = ' ';
                        return;
                }
		new_node = xmlNewChild(node, NULL, BAD_CAST first_space + 1, NULL);
	}
	xmlNsPtr x_ns = xmlNewNs(new_node, BAD_CAST opt, NULL);
	xmlSetNs(new_node, x_ns);
	*first_space = ' ';
}
Example #21
0
KmlRenderer::KmlRenderer(int width, int height, outputFormatObj *format, colorObj* color/*=NULL*/)
  : Width(width), Height(height), MapCellsize(1.0), XmlDoc(NULL), LayerNode(NULL), GroundOverlayNode(NULL),
    PlacemarkNode(NULL), GeomNode(NULL),
    Items(NULL), NumItems(0), FirstLayer(MS_TRUE), map(NULL), currentLayer(NULL),
    mElevationFromAttribute( false ), mElevationAttributeIndex( -1 ), mCurrentElevationValue(0.0)

{
  /*private variables*/
  pszLayerDescMetadata = NULL;
  papszLayerIncludeItems = NULL;
  nIncludeItems=0;
  papszLayerExcludeItems = NULL;
  nExcludeItems=0;
  pszLayerNameAttributeMetadata = NULL;  /*metadata to use for a name for each feature*/

  LineStyle = NULL;
  numLineStyle = 0;

  xmlNodePtr styleNode;
  xmlNodePtr listStyleNode;
  /*  Create document.*/
  XmlDoc = xmlNewDoc(BAD_CAST "1.0");

  xmlNodePtr rootNode = xmlNewNode(NULL, BAD_CAST "kml");

  /*  Name spaces*/
  xmlSetNs(rootNode, xmlNewNs(rootNode, BAD_CAST "http://www.opengis.net/kml/2.2", NULL));

  xmlDocSetRootElement(XmlDoc, rootNode);

  DocNode = xmlNewChild(rootNode, NULL, BAD_CAST "Document", NULL);

  styleNode = xmlNewChild(DocNode, NULL, BAD_CAST "Style", NULL);
  xmlNewProp(styleNode, BAD_CAST "id", BAD_CAST "LayerFolder_check");
  listStyleNode = xmlNewChild(styleNode, NULL, BAD_CAST "ListStyle", NULL);
  xmlNewChild(listStyleNode, NULL, BAD_CAST "listItemType", BAD_CAST "check");

  styleNode = xmlNewChild(DocNode, NULL, BAD_CAST "Style", NULL);
  xmlNewProp(styleNode, BAD_CAST "id", BAD_CAST "LayerFolder_checkHideChildren");
  listStyleNode = xmlNewChild(styleNode, NULL, BAD_CAST "ListStyle", NULL);
  xmlNewChild(listStyleNode, NULL, BAD_CAST "listItemType", BAD_CAST "checkHideChildren");

  styleNode = xmlNewChild(DocNode, NULL, BAD_CAST "Style", NULL);
  xmlNewProp(styleNode, BAD_CAST "id", BAD_CAST "LayerFolder_checkOffOnly");
  listStyleNode = xmlNewChild(styleNode, NULL, BAD_CAST "ListStyle", NULL);
  xmlNewChild(listStyleNode, NULL, BAD_CAST "listItemType", BAD_CAST "checkOffOnly");

  styleNode = xmlNewChild(DocNode, NULL, BAD_CAST "Style", NULL);
  xmlNewProp(styleNode, BAD_CAST "id", BAD_CAST "LayerFolder_radioFolder");
  listStyleNode = xmlNewChild(styleNode, NULL, BAD_CAST "ListStyle", NULL);
  xmlNewChild(listStyleNode, NULL, BAD_CAST "listItemType", BAD_CAST "radioFolder");


  StyleHashTable = msCreateHashTable();

}
Example #22
0
void
soup_soap_message_persist (SoupSoapMessage *msg)
{
	g_return_if_fail (SOUP_SOAP_IS_MESSAGE (msg));

	xmlChar *buffer;
	const gchar *contents;

	SoupSoapMessagePrivate *priv = msg->priv;

	xmlDocPtr doc = xmlNewDoc (BAD_CAST "1.0");


	xmlNodePtr envelope_node = xmlNewNode (NULL, BAD_CAST "Envelope");
	xmlSetNs (envelope_node,
	          xmlNewNs (envelope_node,
	                    BAD_CAST SOAP_ENV_NAMESPACE,
	                    BAD_CAST "SOAP-ENV"));
	xmlNewNs (envelope_node,
	          BAD_CAST XSD_NAMESPACE,
	          BAD_CAST "xsd");
	xmlNewNs (envelope_node,
	          BAD_CAST XSI_NAMESPACE,
	          BAD_CAST "xsi");
	xmlNewNs (envelope_node,
	          BAD_CAST SOAP_ENC_NAMESPACE,
	          BAD_CAST "SOAP-ENC");
	xmlSetProp (envelope_node,
	            BAD_CAST "SOAP-ENV:encodingStyle",
	            BAD_CAST SOAP_ENCODING_STYLE);
	xmlDocSetRootElement (doc, envelope_node);

	create_param_node (doc, SOUP_SOAP_PARAM (priv->header), envelope_node);

	xmlNodePtr body_node = xmlNewChild (envelope_node, NULL, BAD_CAST "Body", NULL);
	create_param_node (doc, SOUP_SOAP_PARAM (priv->body), body_node);


	xmlDocDumpFormatMemoryEnc (doc, &buffer, NULL, "UTF-8", 0);

	contents = (gchar *) buffer;
	soup_message_body_truncate (priv->message_body);
	soup_message_body_append (priv->message_body, SOUP_MEMORY_COPY,
	                          contents, strlen (contents));
	soup_message_body_complete (priv->message_body);

	xmlFree (buffer);


	xmlFreeDoc (doc);


	soup_message_headers_set_content_type (priv->message_headers,
	                                       "text/xml", NULL);
}
Example #23
0
/*--------------------------------------------------------------------------*/
static xmlDocPtr
doc_to_xml (gbDoc          *doc,
	    gbDocXMLStatus *status)
{
	xmlDocPtr   xmldoc;
	xmlNsPtr    ns;
	xmlNodePtr  xml_bond;
	GList      *p;
	gbDocBond  *p_bond;
	gchar      *title, *idate, *denom;

	gb_debug (DEBUG_XML, "START");

	LIBXML_TEST_VERSION;

	xmldoc = xmlNewDoc ((xmlChar *)"1.0");
	xmldoc->xmlRootNode = xmlNewDocNode (xmldoc, NULL, (xmlChar *)"Bond-Inventory", NULL);

	ns = xmlNewNs (xmldoc->xmlRootNode, (xmlChar *)NAME_SPACE, (xmlChar *)"gbonds");
	xmlSetNs (xmldoc->xmlRootNode, ns);

	title = gb_doc_get_title (doc);
	if ( title != NULL ) {
		xmlNewChild( xmldoc->xmlRootNode, NULL, (xmlChar *)"Title", (xmlChar *)title );
		g_free (title);
	}

	for ( p=doc->list; p!=NULL; p=p->next ) {
		p_bond = (gbDocBond *)p->data;

		idate = gb_date_fmt( p_bond->idate );
		denom = g_strdup_printf( "%.0f", p_bond->denom );

		xml_bond = xmlNewChild( xmldoc->xmlRootNode, NULL, (xmlChar *)"Bond", NULL );
		xmlSetProp( xml_bond, (xmlChar *)"series", (xmlChar *)gb_series_fmt( p_bond->series ) );
		xmlSetProp( xml_bond, (xmlChar *)"idate", (xmlChar *)idate );
		xmlSetProp( xml_bond, (xmlChar *)"denom", (xmlChar *)denom );
		if ( p_bond->sn != NULL ) {
			/* Imported SBW inventories may not have SNs */
			xmlSetProp( xml_bond, (xmlChar *)"sn", (xmlChar *)p_bond->sn );
		}

		g_free( idate );
		idate = NULL;
		g_free( denom );
		denom = NULL;
	}

	gb_debug (DEBUG_XML, "END");

	*status = GB_DOC_XML_OK;
	return xmldoc;
}
Example #24
0
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);
    }
}
Example #25
0
static void
insure_namespace(xmlNode *xmlnode, xmlNs *ns)
{
	xmlNode *t = xmlnode->children;

	xmlSetNs(xmlnode, ns);
	while (t) {
		if (t->type == XML_ELEMENT_NODE && t->ns == NULL)
			insure_namespace(t, ns);
		t = t->next;
	}
}
Example #26
0
xml_node_t * xml_node_create_text_ns(struct xml_node_ctx *ctx,
				     xml_node_t *parent, const char *ns_uri,
				     const char *name, const char *value)
{
	xmlNodePtr node;
	xmlNsPtr ns;

	node = xmlNewTextChild((xmlNodePtr) parent, NULL,
			       (const xmlChar *) name, (const xmlChar *) value);
	ns = xmlNewNs(node, (const xmlChar *) ns_uri, NULL);
	xmlSetNs(node, ns);
	return (xml_node_t *) node;
}
Example #27
0
File: fixNS.c Project: omegahat/XML
void
setDefaultNs(xmlNodePtr node, xmlNsPtr ns, int recursive)
{
    if(!node->ns)
	xmlSetNs(node, ns);
    if(recursive) {
	xmlNodePtr cur = node->children;
	while(cur) {
	    setDefaultNs(cur, ns, 1);
	    cur = cur->next;
	}
    }
}
Example #28
0
Element *
element__new( Document *doc, unsigned char *name, Namespc *ns )
{
    /* NOTE: apparently libxml2 makes its own copy of the element name. */
    xmlNode* el = xmlNewNode( 0, name );

    /* Avoid "unused parameter" warning. */
    doc = 0;

    if ( ns )
        xmlSetNs( el, ( xmlNs* ) ns );

    return ( Element* ) el ;
}
Example #29
0
/* :nodoc: */
static void relink_namespace(xmlNodePtr reparented)
{
  xmlNodePtr child;

  /* Avoid segv when relinking against unlinked nodes. */
  if(!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;
  }
}
Example #30
0
/**
 * xmlSecSoap12CreateEnvelope:
 * @doc:        the parent doc (might be NULL).
 * 
 * Creates a new SOAP 1.2 Envelope node. Caller is responsible for 
 * adding the returned node to the XML document.
 *
 * XML Schema (http://www.w3.org/2003/05/soap-envelope):
 * 
 *     <xs:element name="Envelope" type="tns:Envelope"/>
 *     <xs:complexType name="Envelope">
 *         <xs:sequence>
 *             <xs:element ref="tns:Header" minOccurs="0"/>
 *             <xs:element ref="tns:Body" minOccurs="1"/>
 *         </xs:sequence>
 *         <xs:anyAttribute namespace="##other" processContents="lax"/>
 *     </xs:complexType>
 *
 * Returns pointer to newly created <soap:Envelope> node or NULL
 * if an error occurs.
 */
EXPORT_C
xmlNodePtr 
xmlSecSoap12CreateEnvelope(xmlDocPtr doc) {
    xmlNodePtr envNode;
    xmlNodePtr bodyNode;
    xmlNsPtr ns;
    
    /* create Envelope node */
    envNode = xmlNewDocNode(doc, NULL, xmlSecNodeEnvelope, NULL);
    if(envNode == NULL) {
	xmlSecError(XMLSEC_ERRORS_HERE,
		    NULL,
		    "xmlNewDocNode",
		    XMLSEC_ERRORS_R_XML_FAILED,
		    "node=%s",
		    xmlSecErrorsSafeString(xmlSecNodeEnvelope));
	return(NULL);	            
    }
    
    ns = xmlNewNs(envNode, xmlSecSoap12Ns, NULL) ;
    if(ns == NULL) {
	xmlSecError(XMLSEC_ERRORS_HERE,
		    NULL,
		    "xmlNewNs",
		    XMLSEC_ERRORS_R_XML_FAILED,
		    "ns=%s",
		    xmlSecErrorsSafeString(xmlSecSoap12Ns));
	xmlFreeNode(envNode);
	return(NULL);	        	
    }
    xmlSetNs(envNode, ns);
    
    /* add required Body node */    
    bodyNode = xmlSecAddChild(envNode, xmlSecNodeBody, xmlSecSoap12Ns);
    if(bodyNode == NULL) {
	xmlSecError(XMLSEC_ERRORS_HERE,
		    NULL,
		    "xmlSecAddChild",
		    XMLSEC_ERRORS_R_XMLSEC_FAILED,
		    "node=%s",
		    xmlSecErrorsSafeString(xmlSecNodeBody));
	xmlFreeNode(envNode);
	return(NULL);	        	
    }
    
    return(envNode);
}