예제 #1
0
파일: remotem.c 프로젝트: giacdinh/rr_apps
// below added for xml merge
// removes spaces between # and the text
static int modifytree(xmlNodePtr* ParentPtr, xmlNodePtr sourceNode)
{
	int notfound = -1; //not found
	xmlNodePtr child = (*ParentPtr)->xmlChildrenNode, txt = NULL;
	while (child != NULL)
	{
		if ((xmlStrcmp(child->name, (const xmlChar*)"text")))
		{
			if ((!xmlStrcmp(child->name, sourceNode->name)))
			{
				xmlNodePtr destNode = xmlCopyNode(sourceNode, 1);
				xmlNodePtr old = xmlReplaceNode(child, destNode);
				xmlFreeNode(old);
				notfound = 0;
				break;
			}
		}
		else
		{
			txt = child;
		}
		child = child->next;
	}

	if (notfound == -1)
	{
		xmlAddChild(*ParentPtr, xmlCopyNode(sourceNode, 1));
		xmlAddChild(*ParentPtr, xmlCopyNode(txt, 1));
		logger_remotem("LOAD_CONFIG_FILE: Node not found, adding new node: %s", sourceNode->name);
	}
	return notfound;
}
예제 #2
0
  bool WaveFunctionFactory::build(xmlNodePtr cur, bool buildtree) {

    if(cur == NULL) return false;

    bool attach2Node=false;
    if(buildtree) {
      if(myNode == NULL) {
        myNode = xmlCopyNode(cur,1);
      } else {
        attach2Node=true;
      }
    }


    if(targetPsi==0) {//allocate targetPsi and set the name
      targetPsi  = new TrialWaveFunction;
      targetPsi->setName(myName);
      app_log() << "  Creating a trial wavefunction " << myName << endl;
    }

    cur = cur->children;
    bool success=true;
    while(cur != NULL) {
      string cname((const char*)(cur->name));
      if (cname == OrbitalBuilderBase::detset_tag) 
      {
        success = addFermionTerm(cur);
      } 
      else if (cname ==  OrbitalBuilderBase::jastrow_tag) 
      {
        OrbitalBuilderBase *jbuilder = new JastrowBuilder(*targetPtcl,*targetPsi,ptclPool);
        success = jbuilder->put(cur);
        addNode(jbuilder,cur);
      }
      else if(cname == "agp") 
      {
#if defined(QMC_COMPLEX)
        app_error() << "  AGPDeterminant cannot be used with QMC_COMPLEX=1" << endl;
        return false;
#else
        AGPDeterminantBuilder* agpbuilder = new AGPDeterminantBuilder(*targetPtcl,*targetPsi,ptclPool);
        success = agpbuilder->put(cur);
        addNode(agpbuilder,cur);
#endif
      } 
      if(attach2Node) xmlAddChild(myNode,xmlCopyNode(cur,1));
      cur = cur->next;
    }

    if(OrbitalBuilderBase::print_level>0)
    {
      app_log() << "  List of optimizable variables " << endl;
      targetPsi->VarList.print(app_log());

      //set to zero so that nothing is written again
      OrbitalBuilderBase::print_level=0;
    }

    return success;
  }
예제 #3
0
void c_XSLTProcessor::t_importstylesheet(const Object& stylesheet) {
  xmlDocPtr doc = nullptr;

  if (stylesheet.instanceof(c_DOMDocument::classof())) {
    c_DOMDocument *domdoc = stylesheet.getTyped<c_DOMDocument>();
    // This doc will be freed by xsltFreeStylesheet.
    doc = xmlCopyDoc((xmlDocPtr)domdoc->m_node, /*recursive*/ 1);
    if (doc == nullptr) {
      raise_error("Unable to import stylesheet");
    }
  } else if (stylesheet.instanceof(c_SimpleXMLElement::classof())) {
    c_SimpleXMLElement *elem = stylesheet.getTyped<c_SimpleXMLElement>();
    // This doc will be freed by xsltFreeStylesheet.
    doc = xmlNewDoc((const xmlChar*)"1.0");
    xmlNodePtr node = xmlCopyNode(elem->node, /*extended*/ 1);
    if (doc == nullptr || node == nullptr) {
      raise_error("Unable to import stylesheet");
    }
    xmlDocSetRootElement(doc, node);
  } else {
    raise_error("Object must be an instance of DOMDocument or "
                "SimpleXMLElement");
  }

  if (doc) {
    m_stylesheet = xsltParseStylesheetDoc(doc);
    if (m_stylesheet == nullptr) {
      raise_error("Unable to import stylesheet");
    }
  }
}
예제 #4
0
파일: node.c 프로젝트: RareHare/reactos
HRESULT node_clone(xmlnode *This, VARIANT_BOOL deep, IXMLDOMNode **cloneNode)
{
    IXMLDOMNode *node;
    xmlNodePtr clone;

    if(!cloneNode) return E_INVALIDARG;

    clone = xmlCopyNode(This->node, deep ? 1 : 2);
    if (clone)
    {
        xmlSetTreeDoc(clone, This->node->doc);
        xmldoc_add_orphan(clone->doc, clone);

        node = create_node(clone);
        if (!node)
        {
            ERR("Copy failed\n");
            xmldoc_remove_orphan(clone->doc, clone);
            xmlFreeNode(clone);
            return E_FAIL;
        }

        *cloneNode = node;
    }
    else
    {
        ERR("Copy failed\n");
        return E_FAIL;
    }

    return S_OK;
}
예제 #5
0
/*
 * COMMAND: <gda_report_section>
 *
 * Creates copies of its contents, one copy per row in the new run context's
 * data model.
 *
 * uses node's contents: yes
 * requested attributes: none
 *
 * REM: either "query_name" or a <gda_report_query> sub node must be provided to create a data model.
 */
static gboolean
command_gda_report_iter_run (GdaReportEngine *engine, xmlNodePtr node, GSList **created_nodes,
			     RunContext *context, GError **error)
{
	if (!context || !context->iter)
		return TRUE;

	gda_data_model_iter_move_next (context->iter);
	while (gda_data_model_iter_is_valid (context->iter)) {
		xmlNodePtr dup, child;
		dup = xmlCopyNode (node, 1);
				
		if (!real_run_at_node (engine, dup->children, context, error)) {
			xmlFreeNode (dup);
			return FALSE;
		}
		else {
			for (child = dup->children; child; child = dup->children) {
				xmlUnlinkNode (child);
				*created_nodes = g_slist_prepend (*created_nodes, child);
			}
		}
		xmlFreeNode (dup);
		gda_data_model_iter_move_next (context->iter);
	}

	*created_nodes = g_slist_reverse (*created_nodes);

	return TRUE;
}
예제 #6
0
파일: maps-osm.c 프로젝트: GNOME/gnome-maps
static xmlNode *
get_sub_node (xmlDoc *doc)
{
  xmlNode *node;
  xmlXPathContext *xpath_ctx;
  xmlXPathObject * xpath_obj;

  xpath_ctx = xmlXPathNewContext (doc);
  xpath_obj = xmlXPathEvalExpression ((xmlChar *) "/osm/node|/osm/way|/osm/relation",
                                      xpath_ctx);

  if (xpath_obj && xpath_obj->nodesetval && xpath_obj->nodesetval->nodeNr > 0)
    {
      node = xmlCopyNode (xpath_obj->nodesetval->nodeTab[0], 1);
    }
  else
    {
      g_warning ("Couldn't find element");
      node = NULL;
    }

  xmlXPathFreeObject (xpath_obj);
  xmlXPathFreeContext (xpath_ctx);

  return node;
}
예제 #7
0
파일: player.cpp 프로젝트: DuMuT6p/Epiar
/**\brief Convert an XML node from the old saved-games.xml format to the new format.
 * \details
 *   The old saved-games.xml format put all of the Player information in one file.
 *   The new saved-games.xml format only stores some Player information, but
 *   nothing that relies on loading the Simulation.  Everything in the old
 *   style format is by itself in a standalone xml file named after the player.
 * \todo This could save a copy of the old saved-games.xml to a backup location.
 * \param[in] doc The XML document.
 * \param[in] xnode The XML Node.
 * \return A new XML node that represents the PlayerInfo for the Player.
 */
xmlNodePtr PlayerInfo::ConvertOldVersion( xmlDocPtr doc, xmlNodePtr node ) {
	char buff[256];
	xmlDocPtr xmlPtr;
	xmlNodePtr  attr;
	xmlNodePtr  copy = xmlCopyNode( node, 1);
	string filename = "Resources/Definitions/"+ name +".xml";

	LogMsg(INFO, "Converting %s to an xml file: %s ", name.c_str(), filename.c_str() );

	xmlPtr = xmlNewDoc( BAD_CAST "1.0" );
	xmlDocSetRootElement(xmlPtr, copy);

	// Version information
	snprintf(buff, sizeof(buff), "%d", EPIAR_VERSION_MAJOR);
	xmlNewChild(copy, NULL, BAD_CAST "version-major", BAD_CAST buff);
	snprintf(buff, sizeof(buff), "%d", EPIAR_VERSION_MINOR);
	xmlNewChild(copy, NULL, BAD_CAST "version-minor", BAD_CAST buff);
	snprintf(buff, sizeof(buff), "%d", EPIAR_VERSION_MICRO);
	xmlNewChild(copy, NULL, BAD_CAST "version-macro", BAD_CAST buff);

	xmlSaveFormatFileEnc( filename.c_str(), xmlPtr, "ISO-8859-1", 1);

	xmlNodePtr new_node = xmlNewNode(NULL, BAD_CAST "player");
	xmlNewChild(new_node, NULL, BAD_CAST "name", BAD_CAST GetName().c_str() );
	xmlNewChild(new_node, NULL, BAD_CAST "file", BAD_CAST filename.c_str() );

	if( (attr = FirstChildNamed(copy, "lastLoadTime")) ){
		xmlNewChild(new_node, NULL, BAD_CAST "lastLoadTime", BAD_CAST NodeToString(doc,attr).c_str() );
	}
	
	return new_node;
}
예제 #8
0
XmlNode& XmlNode::operator =(const XmlNode& n)
{
	if (m_hXml)
		xmlDestroyNode(m_hXml);
	m_hXml = xmlCopyNode(n);
	return *this;
}
예제 #9
0
    /// get XML from current object
    FWXML_API xmlNodePtr getXMLFrom( ::fwData::Object::sptr obj )
    {
        OSLM_DEBUG("GenericXMLTranslator for " << obj->className() << "-" <<  obj.get() );

        // check obj is well realated to RealObject
        ::boost::shared_ptr<RealData> robj = ::boost::dynamic_pointer_cast<RealData >(obj);
        SLM_ASSERT("robj not instanced", robj);

        // create master node with className+id
        xmlNodePtr node = XMLTranslatorHelper::MasterNode( robj );


        // create data information using boost tweaked archive

        ::boost::archive::fw_xml_oarchive ao_xml(0);
        {
            ao_xml.operator&( ::boost::serialization::make_nvp("BoostManagedObject", *robj ) ); // Serialization with pointer generate an NVP (.first with NULL name !!!)
        }

        xmlNodePtr boostXML =  ao_xml.getXMLNode();
        SLM_ASSERT("boostXML not instanced", boostXML);
        boostXML = boostXML->children;
        while ( boostXML!=NULL )
        {
            if ( boostXML->type == XML_ELEMENT_NODE )
            {
                xmlAddChild( node, xmlCopyNode(boostXML,1) );
            }
            boostXML =  boostXML->next;
        }

        xmlFree( ao_xml.getXMLNode() );
        return node;
    }
예제 #10
0
/*CopyElement - copies element of other CXMLElement
truecopy - if true this is set to point to element of telement, 
otherwise this is set to point to a copy of element in telement
output: telement - xml element to copy from
*/
void CXMLElement::CopyElement(CXMLElement *telement,Bool truecopy)
{
	if (truecopy)
		element = xmlCopyNode(telement->GetNodePtr(), 1);
	else
		element = telement->GetNodePtr();
}
예제 #11
0
xmlNodePtr design_tolerance_to_xml_node(design_tolerance_s *t)
{
  xmlNodePtr n = NULL;
  xmlNodePtr vn = NULL;
  char sn[MAX_SN];

    // Sanity check parameters.
  assert(t);

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

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

  snprintf(sn, MAX_SN, "%f", t->text_size);
  xmlNewChild(n, NULL, BAD_CAST "text-size", BAD_CAST sn);

  snprintf(sn, MAX_SN, "%f", t->plus);
  xmlNewChild(n, NULL, BAD_CAST "plus", BAD_CAST sn);

  snprintf(sn, MAX_SN, "%f", t->minus);
  xmlNewChild(n, NULL, BAD_CAST "minus", BAD_CAST sn);

  snprintf(sn, MAX_SN, "%d", t->precision);
  xmlNewChild(n, NULL, BAD_CAST "precision", BAD_CAST sn);

    // Return RETVAL
  return n;
}
예제 #12
0
    void XMLNodeList::replaceAtIndex(int index, const XMLElement & elem)
    {
        xmlNode *n = getListNode(index);

        if (n && n != elem.getRealNode())
        {
            if (index == 1)
            {
                scope->unregisterNodeListPointer(parent->children);
            }
            xmlNode *previous = n->prev;
            xmlNode *next = n->next;
            xmlNode *cpy = xmlCopyNode(elem.getRealNode(), 1);

            xmlUnlinkNode(cpy);
            xmlReplaceNode(n, cpy);
            xmlFreeNode(n);
            prevNode = cpy;
            cpy->prev = previous;
            cpy->next = next;
            if (index == 1)
            {
                scope->registerPointers(parent->children, this);
            }
        }
    }
예제 #13
0
    void XMLNodeList::insertAtEnd(const XMLElement & elem)
    {
        xmlNode *cpy = xmlCopyNode(elem.getRealNode(), 1);

        xmlUnlinkNode(cpy);
        xmlAddChild(parent, cpy);
        size++;
    }
예제 #14
0
파일: Node.cpp 프로젝트: ASTL-NICT/MCML-OSS
// Inherits XMLSpy generation source function.
xmlNodePtr CNode::InternalInsertNodeAt(const tstring& sNamespaceURI, const tstring& sName, int nIndex, CNode& rNode)
{
	rNode.m_pDOMNode = xmlAddPrevSibling(
			InternalGetAt(Element, sNamespaceURI, sName, nIndex),
			xmlCopyNode(rNode.m_pDOMNode, 1)
			);

	return rNode.m_pDOMNode;
}
예제 #15
0
Extension::Extension( ::boost::shared_ptr< Bundle > bundle, const std::string & id, const std::string & point, xmlNodePtr xmlNode )
: BundleElement ( bundle                    ),
  m_id          ( id                        ),
  m_point       ( point                     ),
  m_xmlDoc      ( xmlNewDoc(BAD_CAST "1.0") ),
  m_xmlNode     ( xmlCopyNode(xmlNode, 1)   ),
  m_validity    ( UnknownValidity           )
{
    xmlDocSetRootElement(m_xmlDoc, m_xmlNode);
}
예제 #16
0
    void XMLNodeList::insertAtBeginning(const XMLElement & elem)
    {
        xmlNode *cpy = xmlCopyNode(elem.getRealNode(), 1);

        xmlUnlinkNode(cpy);
        scope->unregisterNodeListPointer(parent->children);
        xmlAddPrevSibling(parent->children, cpy);
        scope->registerPointers(parent->children, this);
        size++;
    }
예제 #17
0
파일: Node.cpp 프로젝트: ASTL-NICT/MCML-OSS
// Inherits XMLSpy generation source function.
xmlNodePtr CNode::InternalReplaceNodeAt(const tstring& sNamespaceURI, const tstring& sName, int nIndex, CNode& rNode)
{
	xmlNodePtr pOldNode = rNode.m_pDOMNode;
	rNode.m_pDOMNode = xmlReplaceNode(
			InternalGetAt(Element, sNamespaceURI, sName, nIndex),
			xmlCopyNode(rNode.m_pDOMNode, 1)
			);
	CDoc::ReleaseFragment(pOldNode);

	return rNode.m_pDOMNode;
}
예제 #18
0
파일: spmxml.cpp 프로젝트: smurav/gis36
xmlNodePtr CSpmXml::Clone(xmlNodePtr pNode, bool bDeep)
{
	pNode = GetNode(pNode);
	if (0 == pNode)
		return 0;

	int nRecursive = 1;
	if (!bDeep)
		nRecursive = 2;

	return xmlCopyNode(pNode, nRecursive);
}
예제 #19
0
파일: elements.c 프로젝트: galaris/openscap
xmlNode *oscap_xmlstr_to_dom(xmlNode *parent, const char *elname, const char *content)
{
	char *str = oscap_sprintf("<x xmlns:xhtml='http://www.w3.org/1999/xhtml'>%s</x>", content);
	xmlDoc *doc = xmlReadMemory(str, strlen(str), NULL, NULL,
		XML_PARSE_RECOVER | XML_PARSE_NOERROR | XML_PARSE_NOWARNING | XML_PARSE_NONET | XML_PARSE_NSCLEAN);
	xmlNode *text_node = xmlCopyNode(xmlDocGetRootElement(doc), 1);
	xmlNodeSetName(text_node, BAD_CAST elname);
	xmlAddChild(parent, text_node);
	xmlFreeDoc(doc);
	oscap_free(str);
	return text_node;
}
예제 #20
0
//USAGEMODE HRESULT TS_hGetConfigurationData(BYTE*& pDesBuffer, UINT& nBuffSize)
USAGEMODE HRESULT TS_hGetConfigurationData(xmlNodePtr* pxmlNodePtr)
{
    if(g_pomTSExecutorChildWindow != NULL)
    {
        return g_pomTSExecutorChildWindow->GetConfigurationData(*pxmlNodePtr);
    }
    else
    {
        *pxmlNodePtr = xmlCopyNode(m_pXmlConfigNode, 1);
        return S_OK;
    }
}
예제 #21
0
void Document::copyNodes(const NodeList& nodeList) {
	if (!isValid() || _xmlDoc->children == NULL) {
		return; // is not Valid, place an assertion here?
	}

	// Copy the child nodes one by one
	for (std::size_t i = 0; i < nodeList.size(); i++) {
		// Copy the node
		xmlNodePtr node = xmlCopyNode(nodeList[i].getNodePtr(), 1);
		// Add this node to the top level node of this document
		xmlAddChild(xmlDocGetRootElement(_xmlDoc), node);
	}
}
예제 #22
0
void XMLElement::setChildren(const XMLElement & elem) const
{
    xmlNode *n = elem.getRealNode();
    if (n && n->parent != node)
    {
        xmlNode *cpy = xmlCopyNode(n, 1);
        xmlUnlinkNode(cpy);
        xmlUnlinkNode(node->children);
        xmlFreeNodeList(node->children);
        node->children = 0;
        xmlAddChild(node, cpy);
    }
}
예제 #23
0
void XMLElement::append(const XMLElement & elem) const
{
    XMLNodeList * list = 0;
    xmlNode *cpy = xmlCopyNode(elem.getRealNode(), 1);
    xmlUnlinkNode(cpy);
    xmlAddChild(node, cpy);

    list = scope->getXMLNodeListFromLibXMLPtr(node->children);
    if (list)
    {
        list->incrementSize();
    }
}
예제 #24
0
    void XMLNodeList::insertAtIndex(int index, const XMLElement & elem)
    {
        xmlNode *n = getListNode(index);

        if (n)
        {
            xmlNode *cpy = xmlCopyNode(elem.getRealNode(), 1);

            xmlUnlinkNode(cpy);
            xmlAddNextSibling(n, cpy);
            size++;
        }
    }
예제 #25
0
/*
 * call-seq:
 *  dup
 *
 * Copy this node
 */
static VALUE duplicate_node(VALUE self)
{
  xmlNodePtr node, dup;
  Data_Get_Struct(self, xmlNode, node);

  dup = xmlCopyNode(node, 1);
  if(dup == NULL) return Qnil;
  dup->doc = node->doc;
  assert(node->parent);

  xmlAddChild(node->parent, dup);

  return Nokogiri_wrap_xml_node(dup);
}
예제 #26
0
std::string XMLParser::toString(xmlNodePtr node)
{
    SLM_ASSERT("node not instanced", node);

    xmlDocPtr doc = xmlNewDoc(BAD_CAST "1.0");
    xmlDocSetRootElement ( doc , xmlCopyNode( node, 1 ) );

    std::stringstream ss;
    XMLStream::toStream( doc, ss );

    // cleaning
    xmlFreeDoc( doc );
    return ss.str();
}
예제 #27
0
xml_node_t * xml_node_from_buf(struct xml_node_ctx *ctx, const char *buf)
{
	xmlDocPtr doc;
	xmlNodePtr node;

	doc = xmlParseMemory(buf, strlen(buf));
	if (doc == NULL)
		return NULL;
	node = xmlDocGetRootElement(doc);
	node = xmlCopyNode(node, 1);
	xmlFreeDoc(doc);

	return (xml_node_t *) node;
}
예제 #28
0
/**
 * gda_report_engine_run_as_node
 * @engine: a #GdaReportEngine object
 * @error: a place to store errors, or %NULL
 *
 * Execute the @engine engine and creates a new xmlNodePtr XML node
 *
 * Returns: a new xmlNodePtr or %NULL if an error occurred
 */
xmlNodePtr 
gda_report_engine_run_as_node (GdaReportEngine *engine, GError **error)
{
	xmlNodePtr retnode;
	g_return_val_if_fail (GDA_IS_REPORT_ENGINE (engine), NULL);
	g_return_val_if_fail (engine->priv, NULL);
	g_return_val_if_fail (engine->priv->spec, NULL);

	retnode = xmlCopyNode (engine->priv->spec, 1);
	if (!real_run_at_node (engine, retnode, NULL, error)) {
		xmlFreeNode (retnode);
		retnode = NULL;
	}
	return retnode;
}
예제 #29
0
파일: XMLNode.cpp 프로젝트: 0of/WebOS-Magna
    XMLNode::NodeData * XMLNode::NodeData::detachingClone(){
      --m_invRefCount;

      NodeData *_data = new NodeData;

      //copy
      _data->m_content = m_content;
      _data->m_name = m_name;
      _data->m_attributes = m_attributes;
      _data->m_childNodes = m_childNodes;

      _data->m_node = xmlCopyNode( m_node,  2 );  
  
      return _data;
    }
예제 #30
0
파일: xml.cpp 프로젝트: coinhelper/coin
xmlNodePtr GetXmlNodePtrFromString( const string& xml_string ) {	
	xmlNodePtr root_node = 0;
	Xml::DocPtr doc_( xmlParseDoc( BAD_CAST xml_string.c_str() ) );

	if ( doc_ ) {
		root_node = xmlDocGetRootElement( doc_ );
    }
	
	if ( root_node )
	{
		return xmlCopyNode( root_node, 1 );
    }

	return 0;
}