Exemplo n.º 1
0
/**
 * example:
 * @filename:		the input XML filename.
 *
 * Parses input XML file, evaluates XPath expression and update the nodes
 * then print the result.
 *
 * Returns 0 on success and a negative value otherwise.
 */
static int example(const char* filename) {
    xmlDocPtr doc;
    xmlXPathContextPtr xpathCtx;

    assert(filename);

    /* Load XML document */
    doc = xmlParseFile(filename);
    if (doc == NULL) {
        fprintf(stderr, "Error: unable to parse file \"%s\"\n", filename);
        return(-1);
    }

    /* Create xpath evaluation context */
    xpathCtx = xmlXPathNewContext(doc);
    if(xpathCtx == NULL) {
        fprintf(stderr,"Error: unable to create new XPath context\n");
        xmlFreeDoc(doc);
        return(-1);
    }


    //change the PATH attribute of GRID
     if(setNodeValue(xpathCtx, "//ert/eclipse/grid/@path", "sillypath")) {
        xmlFreeDoc(doc);
        return -1;
     }

    //node TEST does not exist but will not create an error. Prints "no nodes!"
     if(setNodeValue(xpathCtx, "//ert/eclipse/test", "sillypath")) {
        xmlFreeDoc(doc);
        return -1;
     }





    /* Cleanup of XPath data */
    xmlXPathFreeContext(xpathCtx);

    /* dump the resulting document */
    xmlDocDump(stdout, doc);


    /* free the document */
    xmlFreeDoc(doc);

    return(0);
}
Exemplo n.º 2
0
void NeuralNetAI::computeCycle()
{
    std::vector< double > newValues;

    // Calculate new node values
    for( auto& node : m_nodes )
    {
        double newValue = 0;
        for( auto& synapse : node.incomingSynapses )
        {
            const int source = synapse.first;
            const double weight = synapse.second;
            newValue += m_nodes.at( source ).value * weight;
        }

        /** newValue is sometimes not a number ( NaN ),  */
        /*
        if( isnan( newValue ) )
        {
            std::cout << "NANNNN" << node.value << std::endl;
            int a;
            std::cin >> a;
        }
        //*/

        newValues.push_back( newValue );
    }

    // Update node values
    for( int i = 0; i < NUMBER_OF_NODES; i++ )
    {
        setNodeValue( i, newValues.at( i ) );
    }
}
Exemplo n.º 3
0
 AttrImpl(DocumentImpl<stringT, string_adaptorT>* ownerDoc, const stringT& name, const stringT& value) : 
     DOMAttr_implT(),
     NodeImplWithChildren<stringT, string_adaptorT>(ownerDoc),
     name_(ownerDoc->stringPool(name)),
     ownerElement_(0),
     specified_(true),
     valueCalculated_(false)
 {
   setNodeValue(value);
 } // AttrImpl
Exemplo n.º 4
0
void rmGraph(Graph *graph){
  Edge **edges = graph->edges;
  for (int i = 0; i<graph->size; i++){
	if (edges[i] != NULL){
	  Node *firstNode = getEdgeFirst(edges[i]);
	  Node *secondNode = getEdgeSecond(edges[i]);
	  if (firstNode != NULL || secondNode != NULL){
		for (int j = i; j<graph->size; j++){
		  if (getEdgeFirst(edges[j]) != NULL){
			if (firstNode == getEdgeFirst(edges[j]) ||
				secondNode == getEdgeFirst(edges[j])){
			  free(getEdgeFirst(edges[j])->value);
			  setNodeValue(getEdgeFirst(edges[j]), NULL);
			  setEdgeFirst(edges[j], NULL);
			}
		  }

		  if (getEdgeSecond(edges[j]) != NULL){
			if (firstNode == getEdgeSecond(edges[j]) ||
				secondNode == getEdgeSecond(edges[j])){
			  free(getEdgeSecond(edges[j])->value);
			  setNodeValue(getEdgeSecond(edges[j]), NULL);
			  setEdgeSecond(edges[j], NULL);
			}
		  }
		}

		if (firstNode != NULL){
		  free(firstNode);
		}

		if (secondNode != NULL){
		  free(secondNode);
		}
	  }
	  free(edges[i]->value);
	  free(edges[i]);
	}
  }
  free(graph->edges);
  free(graph);
}
Exemplo n.º 5
0
static Node transformEdgeArrayToGraph(Edge* e, int size, int rootNum){
  Node root = createNode();
  setNodeValue(root, rootNum);

  int* placedPoints = malloc(sizeof(int)*size);
  for (int i=0; i<size; i++)
    *(placedPoints + i) = -1;
  *placedPoints = rootNum;

  createNodeFor(e, size, root, placedPoints, 1);

  return root;
}
Exemplo n.º 6
0
void DOMCharacterDataImpl::setData(const DOMNode *node, const XMLCh *arg)
{
    setNodeValue(node, arg);
}
Exemplo n.º 7
0
 void setValue(const stringT& value) { setNodeValue(value); }
Exemplo n.º 8
0
void
ProcessingInstruction::setData(String * data)
  throw(DOMException)
{
  setNodeValue(data);
}
Exemplo n.º 9
0
void putMap(Map map, string key, void *value) {
   BSTNode node;

   node = insertBSTNode(map->bst, key);
   setNodeValue(node, value);
}
Exemplo n.º 10
0
void
Attr::normalize()
{
  setNodeValue(getNodeValue());
}