xmlNode* CXBindingsForEachChildHandler::DoWriteResource()
{
	CXBindingsForEachChild* foreachchild = dynamic_cast<CXBindingsForEachChild*>(m_instance);

	xmlNode* node = xmlNewNode( NULL , (const xmlChar*) "foreach_child" );
	
	xmlNewProp( node , (const xmlChar*) "of" , cxxU2C( foreachchild->GetOf() ) );
	
	CXBindingsArrayGrammarRule& rules = foreachchild->GetRules();

	for( unsigned int i = 0; i < rules.size() ; ++i )
	{
		xmlNode* child = CXBindingsXmlReader::Get()->WriteResource( &(rules[i]) );
		if( child != NULL )
			xmlAddChild( node , child );
	}

	return node;
}
Exemplo n.º 2
0
int Page::LoadTemplate(xmlChar * filename)
{
  xmlNodePtr cur, newnode;
  bool setit = false;
  //they want us to load another template !!!
  // first check if we've allready loaded one
  if(templatefile)
    {
      xmlFreeDoc(templates);
      delete templatefile;
    }
  wxString temp((const char*) filename, wxConvUTF8);
  templatefile = temp;
  templates = xmlParseFile((char *) filename);


  // now we have to change the <template> in the <page>
  cur = xmlDocGetRootElement(doc);
  if(xmlStrcmp(cur->name, (const xmlChar *)"page") != 0)
    {
      xmlFreeDoc(doc);
      return 0;
    }
  cur = cur->children;
  while(cur != NULL)
    {
      if(!xmlStrcmp(cur->name, (const xmlChar *)"template"))
        {
          xmlSetProp(cur, (xmlChar *) "uri", filename);
          setit = true;
          break;
        }
      cur = cur->next;
    }
  if(!setit){
    // seems there was no <template>, make a new one
    cur = xmlDocGetRootElement(doc);
    newnode = xmlNewNode(NULL, (xmlChar *) "template");
    xmlAddChild(cur, newnode);
  }
  return true;
}
/**
 * xsltExtElementTest:
 * @ctxt:  an XSLT processing context
 * @node:  The current node
 * @inst:  the instruction in the stylesheet
 * @comp:  precomputed informations
 *
 * Process a libxslt:test node
 */
static void
xsltExtElementTest(xsltTransformContextPtr ctxt, xmlNodePtr node,
                   xmlNodePtr inst,
                   xsltElemPreCompPtr comp ATTRIBUTE_UNUSED)
{
    xmlNodePtr commentNode;

    if (testData == NULL) {
        xsltGenericDebug(xsltGenericDebugContext,
                         "xsltExtElementTest: not initialized,"
                         " calling xsltGetExtData\n");
        xsltGetExtData(ctxt, (const xmlChar *) XSLT_TESTPLUGIN_URL);
        if (testData == NULL) {
            xsltTransformError(ctxt, NULL, inst,
                               "xsltExtElementTest: not initialized\n");
            return;
        }
    }
    if (ctxt == NULL) {
        xsltTransformError(ctxt, NULL, inst,
                           "xsltExtElementTest: no transformation context\n");
        return;
    }
    if (node == NULL) {
        xsltTransformError(ctxt, NULL, inst,
                           "xsltExtElementTest: no current node\n");
        return;
    }
    if (inst == NULL) {
        xsltTransformError(ctxt, NULL, inst,
                           "xsltExtElementTest: no instruction\n");
        return;
    }
    if (ctxt->insert == NULL) {
        xsltTransformError(ctxt, NULL, inst,
                           "xsltExtElementTest: no insertion point\n");
        return;
    }
    commentNode = xmlNewComment((const xmlChar *)
                                "libxslt:testplugin element test worked");
    xmlAddChild(ctxt->insert, commentNode);
}
Exemplo n.º 4
0
void xml_Select (char *msg, int entitynum, int brushnum, qboolean bError)
{
	xmlNodePtr node, select;
	char buf[1024];
	char level[2];

	/* now build a proper "select" XML node */
	if( entitynum == 0 && brushnum < 0 )
		sprintf( buf, "Worldspawn: %s", msg );
	else if( entitynum == 0 )
		sprintf( buf, "Brush %i: %s", brushnum, msg );
	else if( brushnum < 0 )
		sprintf( buf, "Entity %i: %s", entitynum, msg );
	else
		sprintf( buf, "Entity %i, Brush %i: %s", entitynum, brushnum, msg );
	node = xmlNewNode( NULL, (xmlChar *)"select" );
	xmlNodeSetContent( node, (xmlChar *)buf );
	level[0] = (int)'0' + (bError ? SYS_ERR : SYS_WRN)  ;
	level[1] = 0;
	xmlSetProp( node, (xmlChar *)"level", (xmlChar *)&level );

	/* a 'select' information */
	sprintf( buf, "%i %i", entitynum, brushnum < 0 ? 0 : brushnum );
	select = xmlNewNode( NULL, (xmlChar *)"brush" );
	xmlNodeSetContent( select, (xmlChar *)buf );
	xmlAddChild( node, select );
	xml_SendNode (node);

	/* print */
	if( entitynum == 0 && brushnum < 0 )
		sprintf( buf, "Worldspawn: %s", msg );
	else if( entitynum == 0 )
		sprintf( buf, "Brush %i: %s", brushnum, msg );
	else if( brushnum < 0 )
		sprintf( buf, "Entity %i: %s", entitynum, msg );
	else
		sprintf( buf, "Entity %i, Brush %i: %s", entitynum, brushnum, msg );
	if( bError )
		Error( buf );
	else
		Sys_FPrintf( SYS_NOXML, "%s\n", buf );
}
Exemplo n.º 5
0
xmlNodePtr xml_write_guitarins(struct ptb_guitarin *guitarins)
{
	struct ptb_guitarin *guitarin = guitarins;
	xmlNodePtr xguitarins = xmlNewNode(NULL, "guitarins");
	
	while(guitarin) {
		xmlNodePtr xguitarin = xmlNewNode(NULL, "guitarin");
		xmlAddChild(xguitarins, xguitarin);

		SMART_ADD_PROP_INT(xguitarin, "offset", guitarin->offset);
		SMART_ADD_PROP_INT(xguitarin, "section", guitarin->section);
		SMART_ADD_PROP_INT(xguitarin, "staff", guitarin->staff);
		SMART_ADD_CHILD_INT(xguitarin, "rhythm_slash", guitarin->rhythm_slash);
		SMART_ADD_CHILD_INT(xguitarin, "staff_in", guitarin->staff_in);

		guitarin = guitarin->next;
	}

	return xguitarins;
}
Exemplo n.º 6
0
static xmlNodePtr
order_dom_tree_create (GncOrder *order)
{
    xmlNodePtr ret;
    Timespec ts;
    kvp_frame *kf;

    ret = xmlNewNode(NULL, BAD_CAST gnc_order_string);
    xmlSetProp(ret, BAD_CAST "version", BAD_CAST order_version_string);

    xmlAddChild(ret, guid_to_dom_tree(order_guid_string,
                                      qof_instance_get_guid(QOF_INSTANCE (order))));

    xmlAddChild(ret, text_to_dom_tree(order_id_string,
                                      gncOrderGetID (order)));

    xmlAddChild(ret, gnc_owner_to_dom_tree (order_owner_string,
                                            gncOrderGetOwner (order)));

    ts = gncOrderGetDateOpened (order);
    xmlAddChild(ret, timespec_to_dom_tree (order_opened_string, &ts));

    ts = gncOrderGetDateClosed (order);
    if (ts.tv_sec || ts.tv_nsec)
        xmlAddChild(ret, timespec_to_dom_tree (order_closed_string, &ts));

    maybe_add_string (ret, order_notes_string, gncOrderGetNotes (order));
    maybe_add_string (ret, order_reference_string, gncOrderGetReference (order));

    xmlAddChild(ret, int_to_dom_tree(order_active_string,
                                     gncOrderGetActive (order)));

    kf = qof_instance_get_slots (QOF_INSTANCE(order));
    if (kf)
    {
        xmlNodePtr kvpnode = kvp_frame_to_dom_tree(order_slots_string, kf);
        if (kvpnode)
        {
            xmlAddChild(ret, kvpnode);
        }
    }

    return ret;
}
Exemplo n.º 7
0
/**\brief Save all Components to an XML file
 */
bool Components::Save(string filename) {
    xmlDocPtr doc = NULL;       /* document pointer */
    xmlNodePtr root_node = NULL, section = NULL;/* node pointers */

    doc = xmlNewDoc(BAD_CAST "1.0");
    root_node = xmlNewNode(NULL, BAD_CAST rootName.c_str() );
    xmlDocSetRootElement(doc, root_node);

	xmlNewChild(root_node, NULL, BAD_CAST "version-major", BAD_CAST "0");
	xmlNewChild(root_node, NULL, BAD_CAST "version-minor", BAD_CAST "7");
	xmlNewChild(root_node, NULL, BAD_CAST "version-macro", BAD_CAST "0");

	for( map<string,Component*>::iterator i = components.begin(); i != components.end(); ++i ) {
		section = i->second->ToXMLNode(componentName);
		xmlAddChild(root_node, section);
	}
	xmlSaveFormatFileEnc( filename.c_str(), doc, "ISO-8859-1", 1);
	xmlFreeDoc( doc );
	return true;
}
Exemplo n.º 8
0
static void merge_two_sections(xmlNodePtr sect_node, xmlNodePtr other_sect_node)
{
	xmlNodePtr node, new_node;
	xmlChar *uid;
	
	for(node = other_sect_node->children; node != NULL; node = node->next) {
		if (xmlStrcmp(node->name, (xmlChar *)"doc")) {
			continue;
		}
	
		uid = get_doc_uid(node);
		if (uid != NULL) {
			if (!find_uid_in_sect(sect_node, uid)) {
				new_node = xmlCopyNode(node, 1);
				check_ptr(new_node, "");
				xmlAddChild(sect_node, new_node);
			}
		}
	}
}
Exemplo n.º 9
0
std::shared_ptr<Node> Node::CopyIn(std::shared_ptr<const Node> nodeToCopy, bool recursive)
{
    if ( nodeToCopy == nullptr )
        return nullptr;
    
    // complains about the difference between 'const xmlNode *' and 'xmlNode const *' ...
    xmlNodePtr theCopy = xmlDocCopyNode(const_cast<_xmlNode *>(nodeToCopy->xml()), _xml->doc, recursive ? 1 : 0);
    if ( theCopy == nullptr )
        throw InternalError("Unable to copy node", xmlGetLastError());
    
    xmlNode * added = xmlAddChild(_xml, theCopy);
    if ( added == nullptr )
    {
        xmlFreeNode(theCopy);
        throw InternalError("Unable to add copied node as a new child", xmlGetLastError());
    }
    
    // if added != theCopy, then theCopy has already been freed
    return Wrapped<Node, _xmlNode>(added);
}
Exemplo n.º 10
0
PKI_CONFIG_ELEMENT *PKI_CONFIG_ELEMENT_new ( char *name, char *value ) {

	PKI_CONFIG_ELEMENT *ret = NULL;
	// xmlNsPtr ns = NULL;

	if( !name ) return ( NULL );

	if((ret = xmlNewNode( NULL, BAD_CAST name )) == NULL ) {
		return ( NULL );
	}

	// ns = xmlNewNs ( ret, PKI_NAMESPACE_PREFIX, NULL );

	if( value ) {
		xmlAddChild( ret, xmlNewText ( BAD_CAST value ));
	}

	return ( ret );

}
Exemplo n.º 11
0
enum jal_status jal_parse_xml_snippet(
    xmlNodePtr *ctx_node,
    const char *snippet)
{
    if (!ctx_node || !snippet) {
        return JAL_E_INVAL;
    }

    xmlDocPtr doc = xmlParseMemory(snippet, strlen(snippet));
    if (!doc) {
        return JAL_E_XML_PARSE;
    }
    if (*ctx_node) {
        xmlAddChild(*ctx_node, xmlDocGetRootElement(doc));
    }
    else {
        *ctx_node = xmlDocGetRootElement(doc);
    }
    return JAL_OK;
}
Exemplo n.º 12
0
void xml_Point( char *msg, vec3_t pt ){
	xmlNodePtr node, point;
	char buf[1024];
	char level[2];

	node = xmlNewNode( NULL, (xmlChar*)"pointmsg" );
	xmlNodeSetContent( node, (xmlChar*)msg );
	level[0] = (int)'0' + SYS_ERR;
	level[1] = 0;
	xmlSetProp( node, (xmlChar*)"level", (xmlChar *)&level );
	// a 'point' node
	sprintf( buf, "%g %g %g", pt[0], pt[1], pt[2] );
	point = xmlNewNode( NULL, (xmlChar*)"point" );
	xmlNodeSetContent( point, (xmlChar*)buf );
	xmlAddChild( node, point );
	xml_SendNode( node );

	sprintf( buf, "%s (%g %g %g)", msg, pt[0], pt[1], pt[2] );
	Error( buf );
}
Exemplo n.º 13
0
/**
 * Creates a new child element node and appends it to the list
 * of children in "this".
 *
 * @param pcszElementName
 * @return
 */
ElementNode* ElementNode::createChild(const char *pcszElementName)
{
    // we must be an element, not an attribute
    if (!m_plibNode)
        throw ENodeIsNotElement(RT_SRC_POS);

    // libxml side: create new node
    xmlNode *plibNode;
    if (!(plibNode = xmlNewNode(NULL,        // namespace
                                (const xmlChar*)pcszElementName)))
        throw std::bad_alloc();
    xmlAddChild(m_plibNode, plibNode);

    // now wrap this in C++
    ElementNode *p = new ElementNode(m_pelmRoot, this, plibNode);
    boost::shared_ptr<ElementNode> pNew(p);
    m->children.push_back(pNew);

    return p;
}
Exemplo n.º 14
0
xmlNodePtr
soap_addressing_set_to(struct SoapEnv *envelope, xmlNodePtr address)
{
  xmlNodePtr ret;
  xmlNodePtr node;

  node = soap_addressing_get_to(envelope);
  if (node != NULL)
  {
    xmlUnlinkNode(node);
    xmlFreeNode(node);
  }

  ret = _soap_addressing_add_node(envelope->header, WSA_TO, NULL);
  node = xmlCopyNode(address, 1);
  xmlUnlinkNode(node);
  xmlAddChild(ret, node);

  return ret;
}
Exemplo n.º 15
0
/**
 *  'move' operation
 */
static void
edMove(xmlDocPtr doc, xmlNodeSetPtr nodes, xmlNodePtr to)
{
    int i;
    for (i = 0; i < nodes->nodeNr; i++)
    {
        if (nodes->nodeTab[i] == (void*) doc) {
            fprintf(stderr, "The document node cannot be moved.\n");
            exit(EXIT_INTERNAL_ERROR);
        }

        if (nodes->nodeTab[i]->type == XML_NAMESPACE_DECL) {
            fprintf(stderr, "FIXME: can't move namespace nodes\n");
            exit(EXIT_INTERNAL_ERROR);
        }
        /* move node */
        xmlUnlinkNode(nodes->nodeTab[i]);
        xmlAddChild(to, nodes->nodeTab[i]);
    }
}
Exemplo n.º 16
0
void
OPENLDAP::Source::add (const std::string name,
		       const std::string hostname,
		       int port,
		       const std::string base,
		       const std::string scope,
		       const std::string call_attribute,
		       const std::string password)
{
  Book *book = NULL;
  xmlNodePtr root;

  root = xmlDocGetRootElement (doc);
  book = new Book (core, name, hostname, port, base,
		   scope, call_attribute, password);

  xmlAddChild (root, book->get_node ());

  common_add (*book);
}
Exemplo n.º 17
0
xmlNodePtr design_point_to_xml_node(design_point_s *p)
{
  xmlNodePtr n = NULL;
  xmlNodePtr vn = NULL;

    // Sanity check parameters.
  assert(p);

  n = xmlNewNode(NULL, BAD_CAST "point");
  if (!n) return NULL;

  vn = vertex_to_xml_node(p->location);
  if (vn)
  {
    xmlAddChild(n, xmlCopyNode(vn, 1));
    xmlFreeNode(vn);
  }

    // Return RETVAL
  return n;
}
Exemplo n.º 18
0
XmlNode *
Xml::addChildNode(XmlNode *parentNode, XmlNode *childNode)
{
    if (NULL == parentNode) {
        fprintf(stderr, "[ERROR] In Xml::addChildNode, "
                "parentNode == NULL\n");
        return NULL;
    }

    if (NULL == childNode) {
        fprintf(stderr, "[ERROR] In Xml::addChildNode, childNode == NULL\n");
        return NULL;
    }

    if (NULL == _doc) {
        fprintf(stderr, "[ERROR] In Xml::addChildNode, _doc == NULL\n");
        return NULL;
    }

    return xmlAddChild(parentNode, childNode);
}
static void
foreach_save_func (gpointer key,
                   gpointer value,
                   gpointer user_data)
{
	struct save_data *sd = user_data;
	xmlNodePtr new_node;
	xmlChar *enc;

	if (sd->type == E_XML_HASH_TYPE_OBJECT_UID) {
		new_node = xmlNewNode (NULL, (xmlChar *)"object");
		xmlNewProp (new_node, (xmlChar *)"uid", (const xmlChar *) key);
	} else
		new_node = xmlNewNode (NULL, (const xmlChar *) key);

	enc = xmlEncodeEntitiesReentrant (sd->doc, value);
	xmlNodeSetContent (new_node, enc);
	xmlFree (enc);

	xmlAddChild (sd->root, new_node);
}
Exemplo n.º 20
0
xmlNodePtr
gnc_book_dom_tree_create(QofBook *book)
{
    xmlNodePtr ret;
    G_GNUC_UNUSED gboolean allow_incompat = TRUE;

    ret = xmlNewNode(NULL, BAD_CAST gnc_book_string);
    xmlSetProp(ret, BAD_CAST "version", BAD_CAST gnc_v2_book_version_string);

    xmlAddChild(ret, guid_to_dom_tree(book_id_string,
                                      qof_book_get_guid(book)));

    if (qof_instance_get_slots (QOF_INSTANCE (book)))
    {
        xmlNodePtr kvpnode = kvp_frame_to_dom_tree(book_slots_string,
                             qof_instance_get_slots (QOF_INSTANCE (book)));
        if (kvpnode)
            xmlAddChild(ret, kvpnode);
    }

#ifdef IMPLEMENT_BOOK_DOM_TREES_LATER
    /* theoretically, we should be adding all the below to the book
     * but in fact, there's enough brain damage in the code already
     * that we are only going to hand-edit the file at a higher layer.
     * And that's OK, since its probably a performance boost anyway.
     */
    xmlAddChild(ret, gnc_commodity_dom_tree_create(
                    gnc_commodity_table_get_table(book)));
    xmlAddChild(ret, gnc_pricedb_dom_tree_create(gnc_pricedb_get_db(book)));
    if (allow_incompat)
    {
        accnode = gnc_account_dom_tree_create(account, FALSE);
        xmlAddChild (ret, rootAccNode);
    }
    append_account_tree (ret, gnc_book_get_root(book));

    xaccAccountTreeForEachTransaction (gnc_book_get_root_account(book),
                                       traverse_txns, ret);

    /* xxx FIXME hack alert how are we going to handle
     *  gnc_book_get_template_group handled ???   */
    xmlAddChild(ret, gnc_schedXaction_dom_tree_create(
                    gnc_book_get_schedxactions(book)));

#endif

    return ret;
}
Exemplo n.º 21
0
XmlDocHelper
StatBuilder::createReport() const {
    XmlDocHelper doc(xmlNewDoc((const xmlChar*) "1.0"));
    XmlUtils::throwUnless(NULL != doc.get());

    xmlNodePtr root = xmlNewDocNode(doc.get(), NULL, (const xmlChar*)data_->name_.c_str(), NULL);
    XmlUtils::throwUnless(NULL != root);

    xmlDocSetRootElement(doc.get(), root);

    for(std::vector<const CounterBase*>::const_iterator c = data_->counters_.begin();
        c != data_->counters_.end();
        ++c) {
        const CounterBase * cnt = *c;
        XmlNodeHelper line = cnt->createReport();
        xmlAddChild(root, line.get());
        line.release();
    }

    return doc;
}
Exemplo n.º 22
0
static void
append_account_tree (xmlNodePtr parent,
                     Account *account,
                     gboolean allow_incompat)
{
    GList *children, *node;

    children = gnc_account_get_children(account);
    children = g_list_sort(children, qof_instance_guid_compare);
    for (node = children; node; node = node->next)
    {
        xmlNodePtr accnode;
        Account *account;

        account = node->data;
        accnode = gnc_account_dom_tree_create(account, FALSE, allow_incompat);
        xmlAddChild (parent, accnode);
        append_account_tree(accnode, account);
    }
    g_list_free(children);
}
Exemplo n.º 23
0
xmlNodePtr xml_write_chordtexts(struct ptb_chordtext *chordtexts)
{
	xmlNodePtr xchordtexts = xmlNewNode(NULL, "chordtexts");
	struct ptb_chordtext *chordtext = chordtexts;

	while(chordtext) {
		xmlNodePtr xchordtext = xmlNewNode(NULL, "chordtext");
		xmlAddChild(xchordtexts, xchordtext);

		SMART_ADD_CHILD_STRING(xchordtext, "note1", ptb_get_tone(chordtext->name[0]));
		SMART_ADD_CHILD_STRING(xchordtext, "note2", ptb_get_tone(chordtext->name[1]));
		SMART_ADD_PROP_INT(xchordtext, "offset", chordtext->offset);
		SMART_ADD_CHILD_INT(xchordtext, "additions", chordtext->additions);
		SMART_ADD_CHILD_INT(xchordtext, "alterations", chordtext->alterations);
		SMART_ADD_CHILD_INT(xchordtext, "properties", chordtext->properties);
		SMART_ADD_CHILD_INT(xchordtext, "VII", chordtext->VII);

		chordtext = chordtext->next;
	}
	return xchordtexts;
}
Exemplo n.º 24
0
/*
 * gint rasta_scope_add_state_xml(RastaContext *ctxt,
 *                                xmlDocPtr doc)
 *
 * Adds XML data for the scopes to doc
 */
gint rasta_scope_add_state_xml(RastaContext *ctxt,
                               xmlDocPtr doc)
{
    xmlNodePtr par, cur;
    RastaScope *scope;
    GList *elem;

    g_return_val_if_fail(ctxt != NULL, -EINVAL);
    g_return_val_if_fail(ctxt->scopes != NULL, -EINVAL);
    g_return_val_if_fail(doc != NULL, -EINVAL);

    par = xmlDocGetRootElement(doc);
    g_return_val_if_fail(par != NULL, -EINVAL);

    elem = ctxt->scopes;
    while(elem->next != NULL)
        elem = g_list_next(elem);
    
    while (elem != NULL)
    {
        scope = (RastaScope *)elem->data;
        g_assert(scope != NULL);

        cur = xmlNewNode(NULL, "SCOPE");
        if (cur == NULL)
            return(-ENOMEM);

        xmlSetProp(cur, "NAME", scope->id);
        xmlAddChild(par, cur);

        g_hash_table_foreach(scope->symbols,
                             rasta_scope_build_symbol_xml,
                             cur);

        par = cur;
        elem = g_list_previous(elem);
    }

    return(0);
}  /* rasta_scope_add_state_xml() */
Exemplo n.º 25
0
XmlNode *
Xml::addChildNode(XmlNode *parentNode, const std::string &nodeName)
{
    if (NULL == parentNode) {
        fprintf(stderr, "[ERROR] In Xml::addChildNode, parentNode == NULL\n");
        return NULL;
    }

    if (NULL == _doc) {
        fprintf(stderr, "[ERROR] In Xml::addChildNode, _doc = NULL\n");
        return NULL;
    }

    xmlNode *childNode = xmlNewNode(NULL, BAD_CAST nodeName.c_str());

    if (NULL == childNode) {
        fprintf(stderr, "[ERROR] In Xml::addChildNode, xmlNewNode() error\n");
        return NULL;
    }

    return xmlAddChild(parentNode, childNode);
}
Exemplo n.º 26
0
void
R_processBranch(RS_XMLParserData * rinfo, 
                int branchIndex, 
                const xmlChar * localname, 
                const xmlChar * prefix, 
                const xmlChar * URI, 
                int nb_namespaces, 
                const xmlChar ** namespaces, 
                int nb_attributes, 
                int nb_defaulted, 
                const xmlChar ** attributes,
		Rboolean sax1)
{
    xmlNodePtr node;

    node = xmlNewNode(NULL, localname);
    if(attributes) {
        const xmlChar ** p = attributes;
        int i;
	if(sax1) {
	  for(i = 0; *p ; i += 2, p += 2) 
            xmlSetProp(node, p[0], p[1]); /*??? Do we need to xmlStrdup() this. */
	} else {
	  const xmlChar **ptr = p;
	  for(i = 0; i < nb_attributes; i++, ptr += 5) {
	    /*XXX does this get freed later on?*/
            xmlSetProp(node, xmlStrdup(ptr[0]), getPropertyValue(ptr));
	  }
	}
    }
    if(rinfo->current) {
        /* Add to children */
        xmlAddChild(rinfo->current, node);
    } else {
        rinfo->top = node;
        rinfo->branchIndex = branchIndex;
    }
    rinfo->current = node;
}
Exemplo n.º 27
0
static xmlNodePtr
add_selections_to_xmlNode(const freesasa_selection **selections,
                          xmlNodePtr parent)
{
    xmlNodePtr xml_selection;

    while (*selections) {
        xml_selection = selection2xml(*selections);
        if (xml_selection == NULL) {
            fail_msg("");
            return NULL;
        }

        if (xmlAddChild(parent, xml_selection) == NULL) {
            fail_msg("");
            xmlFreeNode(xml_selection);
            return NULL;
        }
        ++selections;
    }
    return parent;
}
Exemplo n.º 28
0
bool BayesianClassifier::Save(xmlNodePtr classifierNode)
{
  int i;
  bool retCode = true;
  xmlNodePtr modelNode;

  SetIntValue(classifierNode, DIMENSION_STR, mNumDimensions);
  SetIntValue(classifierNode, CLASSES_STR, mNumClasses);
  SetStringValue(classifierNode, FEATURE_STR, mFeatureString);

  for (i = 0; (i < mNumClasses) && retCode; i++)
  {
    modelNode = xmlNewNode(NULL, (const xmlChar*)GMM_STR);
    xmlAddChild(classifierNode, modelNode);
    SetDoubleValue(modelNode, WEIGHT_STR, mClassWeights[i]);
    retCode = mModels[i].Save(modelNode);
    if ( !retCode )
      fprintf(stderr, "BayesianClassifier::Save - Failed saviing GMM %d\n", i);
  }

  return retCode;
}
Exemplo n.º 29
0
xmlNodePtr Mission::ToXMLNode()
{
    char buff[256];

    xmlNodePtr section = xmlNewNode(NULL, BAD_CAST "Mission" );

    xmlNewChild(section, NULL, BAD_CAST "type", BAD_CAST type.c_str() );

    snprintf(buff, sizeof(buff), "%d", GetVersion() );
    xmlNewChild(section, NULL, BAD_CAST "version", BAD_CAST buff );

    lua_State *L = Lua::CurrentState();

    lua_pushstring(L,"missionTable");
    PushMissionTable();

    xmlAddChild(section, Lua::ConvertToXML(L, lua_gettop(L), lua_gettop(L)-1) );

    lua_pop(L, 1); // Pop Table

    return section;
}
Exemplo n.º 30
0
int CXML::AddChildNode(const char *a_chPath, const char *a_chNodeName)
{
		int nRet = XML_OK;
		xmlNodePtr pNode = NULL;
		xmlNodePtr pNewNode = NULL;

		nRet = GetNodeFromXPath(a_chPath, &pNode);
		if(nRet != XML_OK){
				XML_LOG(XML_ERR,"Node not exist(ret=%d, path=%s, attrName=%s)\n",nRet, a_chPath, a_chAttrName);
				return nRet;
		}

		pNewNode = xmlNewNode(NULL,(const xmlChar*)a_chNodeName);
		if(pNewNode == NULL){
				XML_LOG(XML_ERR,"Node create failed(path=%s, name=%s)\n", a_chPath, a_chNodeName);
				return XML_NODE_CREATE_FAILED;
		}

		xmlAddChild(pNode, pNewNode);

		return XML_OK;
}