示例#1
0
void Parameters::readFile(string str){
  file = str;
  XMLPlatformUtils::Initialize();
  XercesDOMParser parser;
  parser.setValidationScheme(XercesDOMParser::Val_Always);
  HandlerBase errHandler;// = (ErrorHandler*) new HandlerBase();
  parser.setErrorHandler(&errHandler);
  parser.parse(str.c_str());
  DOMDocument * doc = parser.getDocument();
  DOMElement* elementRoot = doc->getDocumentElement();

  // Extract floats
  DOMElement* floatRoot = (DOMElement *) 
    elementRoot->getElementsByTagName(XMLString::transcode("real"))->item(0);
  DOMElement* child = floatRoot->getFirstElementChild();
  do{
    saveReal(XMLString::transcode(child->getNodeName()),  
		    atof(XMLString::transcode(child->getTextContent())));
    child = child->getNextElementSibling();
  }while(child != NULL);

  // Extract integers
  DOMElement* intRoot = (DOMElement *) 
    elementRoot->getElementsByTagName(XMLString::transcode("integer"))->item(0);
  child = intRoot->getFirstElementChild();
  do{
    saveInteger(
		    XMLString::transcode(child->getNodeName()),  
		    atoi(XMLString::transcode(child->getTextContent())));
    child = child->getNextElementSibling();
  }while(child != NULL);
}
示例#2
0
int main( int argc, char **argv ){

 
  m_doc = openDocument( argv[1] );

  DOMElement *root = m_doc->getDocumentElement();
  DOMNodeList *parts = root->getElementsByTagName(XS("part"));


  /*

  */
  DOMElement *part1 = (DOMElement*)parts->item(0);
  DOMElement *part2 = (DOMElement*)parts->item(1);

  mergeParts( part1, part2 );


  root->removeChild( part2 );
  DOMElement *partlist = getSingleElement( root, "part-list" );
  partlist->removeChild( partlist->getElementsByTagName(XS("score-part"))->item(1) );


  writeFile("merged.xml");



}
示例#3
0
/**
TEMP! 2DO Returns perf part by index (will not create perf part)
 */
PerfPart *PMLDocument::getPerfPart( int index ){
    DOMElement *root = m_doc->getDocumentElement();
    DOMElement *perf = (DOMElement*)root->getElementsByTagName(XS("performance"))->item(0);
    DOMNodeList *parts = perf->getElementsByTagName(XS("perfpart"));

    DOMElement *perfPartEl = (DOMElement*)parts->item(index);
    PerfPart *perfPart = new PerfPart(this, perfPartEl);
    return perfPart;
}
示例#4
0
void Generation::GenerationImpl::getGeneration(DOMElement *node) {
    XMLCh tempStr[20];

    XMLString::transcode("id", tempStr, 19);
    DOMNode *p = node->getAttributes()->getNamedItem(tempStr);
    if (p) {
        m_id = getStringNodeValue(p);
    }

    XMLString::transcode("name", tempStr, 19);
    DOMNodeList *list = node->getElementsByTagName(tempStr);
    if (list->getLength() != 0) {
        m_name = getTextFromElement((DOMElement *)list->item(0));
    }

    XMLString::transcode("metagames", tempStr, 19);
    list = node->getElementsByTagName(tempStr);
    if (list->getLength() != 0) {
        DOMElement *metagames = (DOMElement *)list->item(0);
        XMLString::transcode("metagame", tempStr, 19);
        list = metagames->getElementsByTagName(tempStr);
        const int length = list->getLength();
        for (int i = 0; i < length; ++i) {
            DOMElement *item = (DOMElement *)list->item(i);
            MetagamePtr metagame(new Metagame());
            metagame.get()->m_impl->getMetagame(item);
            metagame.get()->m_impl->m_idx = i;
            metagame.get()->m_impl->m_generation = m_owner;
            m_metagames.push_back(metagame);
        }
    }
}
示例#5
0
// to check the value of child node
string cap::parread(const char* parentTag, int parentIndex,const char* childTag,  int childIndex)
{

	
	XMLCh* temp=XMLString::transcode(parentTag);
	DOMNodeList* list = doc->getElementsByTagName(temp);
    XMLString::release(&temp);
 
    DOMElement* parent =dynamic_cast<DOMElement*>(list->item(parentIndex));
    DOMElement* child =dynamic_cast<DOMElement*>(parent->getElementsByTagName(XMLString::transcode(childTag))->item(childIndex));
     
    string value;
    if (child) {
        char* temp2 = XMLString::transcode(child->getTextContent());
		//cout<<"its :"<<child->getTextContent()<<endl;
        value = temp2;
        XMLString::release(&temp2);
    }
    else {
        value = "NO VALUE";
    }
	
	
	return value;

}
示例#6
0
void Generation::readGenerations(const string &file,
        vector<GenerationPtr> &generations) {
    XMLPlatformUtils::Initialize();
    XercesDOMParser parser;

    GenerationErrorHandler handler;
    parser.setErrorHandler(&handler);
    parser.setEntityResolver(&handler);

    parser.parse(file.c_str());

    DOMDocument *doc = parser.getDocument();
    DOMElement *root = doc->getDocumentElement();

    XMLCh tempStr[12];
    XMLString::transcode("generation", tempStr, 11);
    DOMNodeList *list = root->getElementsByTagName(tempStr);

    int length = list->getLength();
    for (int i = 0; i < length; ++i) {
        DOMElement *item = (DOMElement *)list->item(i);
        GenerationPtr generation(new Generation());
        generation->m_impl->m_owner = generation.get();
        generation->m_impl->getGeneration(item);
        generation->m_impl->m_idx = i;
        generations.push_back(generation);
    }
}
示例#7
0
int Problem::GetNumVar()
{
  // first check if we have already read in this value yet.
  if(!hasNumVar_)
    {
      DOMNodeList* nodeList;
      DOMNode* tmpNode;
      DOMElement* variableXML;
      DOMElement* tmpXML;

      // if not, count the number of variables given in the
      // Variable Array
      if((nodeList =
	  applicationXML_->getElementsByTagName(XMLString::transcode("VariableClass")))->getLength() > 0)
	{
	  tmpNode = nodeList->item(0);
	  tmpXML = (DOMElement *)tmpNode;
	}
      if((nodeList =
	  applicationXML_->getElementsByTagName(XMLString::transcode("Array")))->getLength() > 0)
	{
	  tmpNode = nodeList->item(0);
	  variableXML = (DOMElement *)tmpNode;
	}

      numVar_ =
	variableXML->getElementsByTagName(XMLString::transcode("Variables"))->getLength();
      hasNumVar_ = true;
    }
  return numVar_;
}
示例#8
0
文件: main.cpp 项目: lgwizme/macaon
// 2006/12/16
void stampDocument(DOMElement* root) {
  DOMElement* meta = NULL;
  DOMElement* macastamps = NULL;
  DOMElement* stamp = NULL;

  stamp = (root->getOwnerDocument())->createElement(XMLString::transcode("maca_stamp"));
  stamp->setAttribute(XMLString::transcode("module"),
                      XMLString::transcode(_INSTALLED_NAME_));
  stamp->setAttribute(XMLString::transcode("version"),
                      XMLString::transcode(_VERSION_));
  stamp->setAttribute(XMLString::transcode("timestamp"),
                      XMLString::transcode(getTimestamp().c_str()));

  DOMNodeList* metaList = root->getElementsByTagName(XMLString::transcode("meta"));
  if (metaList->getLength() == 0) { // NO meta Element
    meta = (root->getOwnerDocument())->createElement(XMLString::transcode("meta"));
    macastamps =
      (root->getOwnerDocument())->createElement(XMLString::transcode("maca_stamps"));
    meta->appendChild(macastamps);
    root->insertBefore(meta,root->getFirstChild());
  } else { // meta Element
    meta = (DOMElement*)metaList->item(0);
    DOMNodeList* macastampsList = 
      meta->getElementsByTagName(XMLString::transcode("maca_stamps"));
    if (macastampsList->getLength() == 0) { // NO macastamps Element
      macastamps =
        (root->getOwnerDocument())->createElement(XMLString::transcode("maca_stamps"));
      meta->appendChild(macastamps);
    } else { // macastamps Element
      macastamps = (DOMElement*)macastampsList->item(0);
    }
  }
  macastamps->appendChild(stamp);
}
示例#9
0
/**
 * Create PerfPart element
 */
PerfPart::PerfPart( PMLDocument *doc, DOMElement *element ){
    m_doc = doc;
    m_element = element;

    DOMDocument *domdoc = m_element->getOwnerDocument();

    const XMLCh *partID = m_element->getAttribute( XS("part") );

    DOMElement *root = m_element->getOwnerDocument()->getDocumentElement();
    DOMNodeList *parts = root->getElementsByTagName(XS("part"));

    for( unsigned int i=0; i<parts->getLength(); i++ ){

        DOMElement *e = (DOMElement*)parts->item(i);

        cout << " perf  " << XS( m_element->getAttribute(XS("id")))
                << " score " << XS( e->getAttribute(XS("part")) )
                << endl;

        if( !strcmp(XS( m_element->getAttribute(XS("id")) ),  XS( e->getAttribute(XS("part")) ))   ){
            m_scorePart = new ScorePart( m_doc, e );
        }
    }
  
    DOMNodeList *nl = m_element->getElementsByTagName(XS(PNote::Tag));
    for( int i=0; i<nl->getLength(); i++ ){
        m_notes.push_back( new PNote( m_doc, (DOMElement*)nl->item(i) ) );
    
    }
  
}
示例#10
0
map<string, DatasetSpecification> Specifications::readDatasetIndex(string str){
  map<string, DatasetSpecification> result;
  XERCES_CPP_NAMESPACE_USE
  XMLPlatformUtils::Initialize();
  XercesDOMParser parser;
  parser.setValidationScheme(XercesDOMParser::Val_Always);
  HandlerBase errHandler;// = (ErrorHandler*) new HandlerBase();
  parser.setErrorHandler(&errHandler);
  parser.parse(str.c_str());
  DOMDocument * doc = parser.getDocument();
  DOMElement* elementRoot = doc->getDocumentElement();
  DOMNodeList *entries = 
    elementRoot->getElementsByTagName(XMLString::transcode("dataset"));
  
  cout << "Databases in index:\n";
  for(size_t i = 0; i < entries->getLength(); ++i){
    DOMNode *current = entries->item(i);
    DatasetSpecification dss;
    dss.name = XMLString::transcode(current->getAttributes()->
				    getNamedItem(XMLString::transcode("name"))->
				    getNodeValue());
    dss.root = XMLString::transcode(current->getAttributes()->
				    getNamedItem(XMLString::transcode("root"))->
				    getNodeValue());
    cout << "  name: " << dss.name << " root: " << dss.root << endl;
    DOMNodeList *categories = current->getChildNodes();
    for(size_t j = 0; j < categories->getLength(); ++j)
      if((string) XMLString::transcode(categories->item(j)->getNodeName()) ==
	 "category")
	dss.categories.push_back(XMLString::transcode(categories->item(j)->getTextContent()));
    result[dss.name] = dss;
  }
  return result;
}
示例#11
0
list<string> InputHandler::getPostProcessorNameList()
{
	list<string> names;
	
	//get the postprocessor node 
	DOMElement *elem = dynamic_cast<DOMElement*>(getElementByTagName(TAG_postprocessor.xmlStr()));
	//check whether there is one
	if(!elem)
	{
		crusde_info("No postprocessors found.");
		return names;
	}
	//if so, grab all plugins it owns.
	DOMNodeList *plugins = elem->getElementsByTagName(TAG_plugin.xmlStr());
	unsigned int i(0);
	
	//if there are plugins ... 
	while(plugins && i < plugins->getLength() )
	{
		if( plugins->item(i)->getNodeType() == DOMNode::ELEMENT_NODE)
		{			
			/* upcast child to element node */
			DOMElement *elem = dynamic_cast<DOMElement*>( plugins->item(i) );
			StrXML name(elem->getAttribute(ATTR_name.xmlStr()));
			//... add names to list for later lookup.
			names.push_back(name.cppStr());
		}
		++i;		
	}
	
	//return filled list
	return names;
}
示例#12
0
/**
 * extract's the value of an attribute and returns it:
 *
 * <parentNode>
 *	<elementNode attribute="returnstring" />
 * </parentNode>
 *
 * the first parentNode found in the document is used. thus, it is expected to be unique.
 *
 * @param parentNode 
 * @param elementNode 
 * @param attribute 
 * @return 
 */
string InputHandler::getAttributeValue(const XMLCh* parentNode, const XMLCh* elementNode, const XMLCh* attribute)
{
crusde_debug("%s, line: %d, InputHandler::getAttributeValue(%s) ", __FILE__, __LINE__, XMLString::transcode(elementNode));

	DOMElement *root = doc->getDocumentElement();
	DOMNodeList *node_list = root->getElementsByTagName(parentNode);
	
	/*if element does not exist, return emptry string*/
	if(node_list->getLength() == 0)
		return string();
		
	DOMNode *child = node_list->item(0)->getFirstChild();

	DOMNamedNodeMap *attributes = NULL;
		
	while (child)
	{
		if( child->getNodeType() == DOMNode::ELEMENT_NODE)
	       	{
			attributes = child->getAttributes();

			if( XMLString::compareIString(child->getNodeName(), elementNode) == 0 )
			{
				char *val = XMLString::transcode(attributes->getNamedItem(attribute)->getNodeValue());
				string value(val);
				XMLString::release(&val);
				return value;
			}
			
		}
		child = child->getNextSibling();
	}
	return string();
}
示例#13
0
ScorePart *PMLDocument::getScorePart( int index ){
    DOMElement *root = m_doc->getDocumentElement();
    DOMNodeList *parts = root->getElementsByTagName(XS("part"));

    DOMElement *score = (DOMElement*)parts->item(index);
    ScorePart *scorePart = new ScorePart(this, score);
    return scorePart;
}
示例#14
0
int XmlDomDocument::getChildCount(const char* parentTag, int parentIndex, const char* childTag)
{
	XMLCh* temp = XMLString::transcode(parentTag);
	DOMNodeList* list = m_doc->getElementsByTagName(temp);
	XMLString::release(&temp);

	DOMElement* parent = dynamic_cast<DOMElement*>(list->item(parentIndex));
	DOMNodeList* childList = parent->getElementsByTagName(XMLString::transcode(childTag));
    return (int)childList->getLength(); 
}
DOMElement* NewtonProblem::FindParameterXML()
{
  DOMElement* solverXML = GetSolverXML();

  DOMElement* parameterXML;
  DOMNodeList* nodeList;
  DOMNode* tmpNode;

  string trName = "trustRegion";
  string lsName = "lineSearch";
  string pdsName = "trustPDS";

  // now check to see which search method is used.

  if((nodeList =
      solverXML->getElementsByTagName(XMLString::transcode(trName.c_str())))->getLength() > 0)
    {
      searchType_ = trustRegion;
      tmpNode = nodeList->item(0);
      parameterXML = (DOMElement *) tmpNode;
    }
  else if((nodeList =
	   solverXML->getElementsByTagName(XMLString::transcode(lsName.c_str())))->getLength() > 0)
    {
      searchType_ = lineSearch;
      tmpNode = nodeList->item(0);
      parameterXML = (DOMElement *) tmpNode;
    }
  else if((nodeList =
	   solverXML->getElementsByTagName(XMLString::transcode(pdsName.c_str())))->getLength() > 0)
  {
    searchType_ = trustPDS;
    tmpNode = nodeList->item(0);
    parameterXML = (DOMElement *) tmpNode;
  }
  else
  {
    cerr << "CANNOT determine search strategy type" << endl;
    exit(1);
  }
  return parameterXML;
}
示例#16
0
void InputHandler::initParamsFromDOM()
{
     assert(doc);

     crusde_debug("%s, line: %d, initParamsFromDOM().", __FILE__, __LINE__);

     DOMElement *root = doc->getDocumentElement();

     initParamsFromDOM(root->getElementsByTagName(TAG_green.xmlStr())->item(0), SimulationCore::s_params.green);
     initParamsFromDOMNodeList(root->getElementsByTagName( TAG_load.xmlStr()), SimulationCore::s_params.load);
     initParamsFromDOM(root->getElementsByTagName(TAG_kernel.xmlStr())->item(0), SimulationCore::s_params.kernel);
     initParamsFromDOM(root->getElementsByTagName(TAG_postprocessor.xmlStr())->item(0), SimulationCore::s_params.postprocessor);
     if(root->getElementsByTagName(TAG_loadhistory.xmlStr())->getLength() > 0)
          initParamsFromDOMNodeList(root->getElementsByTagName(TAG_loadhistory.xmlStr()), SimulationCore::s_params.loadhistory);
     if(root->getElementsByTagName(TAG_crustaldecay.xmlStr())->getLength() > 0)
          initParamsFromDOMNodeList(root->getElementsByTagName(TAG_crustaldecay.xmlStr()), SimulationCore::s_params.crustaldecay);
}
示例#17
0
DOMElement* CGProblem::FindParameterXML()
{
  DOMElement* solverXML = GetSolverXML();
  DOMElement* parameterXML;
  DOMNodeList* nodeList;
  DOMNode* tmpNode;

  if((nodeList =
      solverXML->getElementsByTagName(XMLString::transcode("CGvar")))->getLength() > 0)
    {
      tmpNode = nodeList->item(0);
      parameterXML = (DOMElement *) tmpNode;
    }

  return parameterXML;
}
示例#18
0
文件: Metadata.cpp 项目: Cyan3/oodt
Metadata::Metadata(DOMDocument *doc)
{
   DOMElement *metadataRootElem = doc->getDocumentElement();
   
   if(metadataRootElem == NULL){
   	return;
   }
   
   XMLCh *keyValStr = XMLString::transcode("keyval");
   DOMNodeList *keyValElems = metadataRootElem->getElementsByTagName(keyValStr);
   
   const XMLSize_t nodeCount = keyValElems->getLength();
   
   //cout << "Metadata::constructor:  Found " << nodeCount << " keyval elements" << endl;
   
   for(XMLSize_t i = 0; i < nodeCount; i++){
     DOMNode* currentNode = keyValElems->item(i) ;
        
     if(currentNode == NULL){
       	  continue;
     }
     	
     if( xercesc::DOMNode::ELEMENT_NODE != currentNode->getNodeType() ){
       // not an element node -> not of interest here
        continue ;
     }

     DOMElement* metadataElem = dynamic_cast< xercesc::DOMElement* >(currentNode);

     
     string key;
     read(metadataElem, "key", key);
     vector<string> values;
     readMany(metadataElem, "val", values);
     
     /*cout << "Processing DOMElement (key, values): (" << key << ", ";
     
     for(int j=0; j < values.size(); j++){
     	cout << values[j] << ", ";
     }
     
     cout << ")" << endl;*/
     
     elementMap[key] = values;
        	
   }	
}
void DsaDataLoader::initializeTalente(DOMElement* rootTalente)
{
    if (rootTalente == NULL)
        return;

    DOMNodeList* talentGruppen = rootTalente->getElementsByTagName(XMLString::transcode("Talentgruppe"));
    for (unsigned int gruppe = 0; gruppe < talentGruppen->getLength(); gruppe++)
    {
        DOMElement* gruppeData = reinterpret_cast<DOMElement*>(talentGruppen->item(gruppe));
        DOMNodeList* talenteXml = gruppeData->getElementsByTagName(XMLString::transcode("Talent"));
        int numTalent = 0;
        for (unsigned int talentIdx = 0; talentIdx < talenteXml->getLength(); talentIdx++)
        {
            Talent* t = processTalent(gruppe, reinterpret_cast<DOMElement*>(talenteXml->item(talentIdx)));
            numTalent++;
            DsaManager::getSingleton()._addTalent(t);
        }
    }
}
	void ItemDataLoader::initializeItems(DOMElement* rootItems)
    {
		if (rootItems == NULL)
			return;

		DOMNodeList* itemGroups =
            rootItems->getElementsByTagName(AutoXMLCh("Gegenstandsgruppe").data());
		for (unsigned int group = 0; group < itemGroups->getLength(); group++)
		{
			DOMElement* groupData = reinterpret_cast<DOMElement*>(itemGroups->item(group));
			DOMNodeList* itemsXml =
                groupData->getElementsByTagName(AutoXMLCh("Gegenstand").data());
			//int numKampftechnik = 0;
			for (unsigned int itemIdx = 0; itemIdx < itemsXml->getLength(); itemIdx++)
			{
				Item* i = processItem(reinterpret_cast<DOMElement*>(itemsXml->item(itemIdx)));
				ItemManager::getSingleton()._addItem(i);
			}
		}
	}
示例#21
0
string XmlDomDocument::getChildValue(const char* parentTag, int parentIndex, const char* childTag, int childIndex)
{
	XMLCh* temp = XMLString::transcode(parentTag);
	DOMNodeList* list = m_doc->getElementsByTagName(temp);
	XMLString::release(&temp);

	DOMElement* parent = dynamic_cast<DOMElement*>(list->item(parentIndex));
	DOMElement* child = 
        dynamic_cast<DOMElement*>(parent->getElementsByTagName(XMLString::transcode(childTag))->item(childIndex));
	string value;
	if (child) {
		char* temp2 = XMLString::transcode(child->getTextContent());
		value = temp2;
        XMLString::release(&temp2);
	}
	else {
		value = "";
	}
	return value;
}
void DsaDataLoader::initializeKampftechniken(DOMElement* rootKampftechniken)
{
    if (rootKampftechniken == NULL)
        return;

    DOMNodeList* kampfarten = rootKampftechniken->getElementsByTagName(XMLString::transcode("Kampfart"));
    for (unsigned int art = 0; art < kampfarten->getLength(); art++)
    {
        DOMElement* artData = reinterpret_cast<DOMElement*>(kampfarten->item(art));
        DOMNodeList* kampftechnikenXml = artData->getElementsByTagName(XMLString::transcode("Kampftechnik"));
        int numKampftechnik = 0;
        for (unsigned int kampftechnikIdx = 0; kampftechnikIdx < kampftechnikenXml->getLength(); kampftechnikIdx++)
        {
            Kampftechnik* k = processKampftechnik(reinterpret_cast<DOMElement*>(kampftechnikenXml->item(kampftechnikIdx)));
            numKampftechnik++;
            DsaManager::getSingleton()._addKampftechnik(k);
        }
    }

}
    void ItemDataLoader::initializeArmors(DOMElement* rootArmors)
    {
		if (rootArmors == NULL)
			return;

		DOMNodeList* armorGroups =
            rootArmors->getElementsByTagName(AutoXMLCh("Rüstungsgruppe").data());
		for (unsigned int group = 0; group < armorGroups->getLength(); group++)
		{
			DOMElement* groupData = reinterpret_cast<DOMElement*>(armorGroups->item(group));
			DOMNodeList* armorsXml =
                groupData->getElementsByTagName(AutoXMLCh("Rüstung").data());
			//int numKampftechnik = 0;
			for (unsigned int armorIdx = 0; armorIdx < armorsXml->getLength(); armorIdx++)
			{
				Armor* a = processArmor(reinterpret_cast<DOMElement*>(armorsXml->item(armorIdx)));
				//numKampftechnik++;
				ItemManager::getSingleton()._addItem(a);
			}
		}
	}
    void ItemDataLoader::initializeWeapons(DOMElement* rootWeapons)
    {
		if (rootWeapons == NULL)
			return;

	    DOMNodeList* weaponGroups =
            rootWeapons->getElementsByTagName(AutoXMLCh("Waffengruppe").data());
        for (unsigned int group = 0; group < weaponGroups->getLength(); group++)
		{
			DOMElement* groupData = reinterpret_cast<DOMElement*>(weaponGroups->item(group));
			DOMNodeList* weaponsXml =
                groupData->getElementsByTagName(AutoXMLCh("Waffe").data());
            //int numTalent = 0;
            for (unsigned int weaponIdx = 0; weaponIdx < weaponsXml->getLength(); weaponIdx++)
            {
                Weapon* w = processWeapon(group, reinterpret_cast<DOMElement*>(weaponsXml->item(weaponIdx)));
                //numTalent++;
				ItemManager::getSingleton()._addItem(w);
            }
		}
    }
XERCES_CPP_NAMESPACE_USE 

std::vector<DgFileTile> DgFileTile::getTiles(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* pDocument,
   const std::string& filename,
   unsigned int& height,
   unsigned int& width)
{
   std::vector<DgFileTile> tiles;
   DOMElement* pRoot = pDocument->getDocumentElement();
   if (pRoot == NULL || !XMLString::equals(pRoot->getNodeName(), X("isd")))
   {
      return tiles;
   }

   DOMNodeList* pTilList = pRoot->getElementsByTagName(X("TIL"));
   if (pTilList == NULL || pTilList->getLength() != 1)
   {
      return tiles;
   }
   DOMNode* pTil = pTilList->item(0);
   if (pTil == NULL || pTil->getNodeType() != DOMNode::ELEMENT_NODE)
   {
      return tiles;
   }
   DOMElement* pTilElement = static_cast<DOMElement*>(pTil);
   DOMNodeList* pTilesList = pTilElement->getElementsByTagName(X("TILE"));
   if (pTilesList == NULL)
   {
      return tiles;
   }
   height = 0;
   width = 0;
   bool error = false;
   QFileInfo fileInfo(QString::fromStdString(filename));
   QDir fileDir = fileInfo.dir();
   for (unsigned int i = 0; i < pTilesList->getLength(); ++i)
   {
      DgFileTile curTile;
      DOMNode* pNode = pTilesList->item(i);
      if (pNode == NULL || pNode->getNodeType() != DOMNode::ELEMENT_NODE)
      {
         continue;
      }
      DOMElement* pElement = static_cast<DOMElement*>(pNode);
      DOMElement* pChildElement = pElement->getFirstElementChild();
      while (pChildElement != NULL)
      {
         std::string textContent = A(pChildElement->getTextContent());
         if (XMLString::equals(pChildElement->getNodeName(), X("FILENAME")))
         {
            curTile.mTilFilename = fileDir.filePath(QString::fromStdString(textContent)).toStdString();
         }
         if (XMLString::equals(pChildElement->getNodeName(), X("ULCOLOFFSET")))
         {
            curTile.mStartCol = StringUtilities::fromXmlString<unsigned int>(textContent, &error);
         }
         if (XMLString::equals(pChildElement->getNodeName(), X("ULROWOFFSET")))
         {
            curTile.mStartRow = StringUtilities::fromXmlString<unsigned int>(textContent, &error);
         }
         if (XMLString::equals(pChildElement->getNodeName(), X("LRCOLOFFSET")))
         {
            curTile.mEndCol = StringUtilities::fromXmlString<unsigned int>(textContent, &error);
         }
         if (XMLString::equals(pChildElement->getNodeName(), X("LRROWOFFSET")))
         {
            curTile.mEndRow = StringUtilities::fromXmlString<unsigned int>(textContent, &error);
         }
         pChildElement = pChildElement->getNextElementSibling();
      }
      tiles.push_back(curTile);
      if (curTile.mEndCol > width)
      {
         width = curTile.mEndCol;
      }
      if (curTile.mEndRow > height)
      {
         height = curTile.mEndRow;
      }
   }
   return tiles;
}
示例#26
0
std::string 
CSDReader::getCCD(std::string id)
throw(CSDReadException)
{
	if (!package_) abort();
	//
	// find and extract the software package descriptor
	//
    std::string csdfile_name = package_->getFileNameWithSuffix( ".csd" );
	std::string csdfile = path_ + getFileName( csdfile_name );
    if ( csdfile_name == std::string( "" ) )
	{
		NORMAL_ERR( "CSDReader: missing a csd file!" );
        throw CSDReadException();
	}
    if (package_->extractFile(csdfile_name, csdfile) != 0)
	{
		NORMAL_ERR2( "CSDReader: error during extracting the descriptor file", csdfile_name );
		throw CSDReadException();
	}

	//
	// parse the software package descriptor file
    //
	DOMXMLParser parser;
    if ( parser.parse( const_cast<char*>(csdfile.c_str()) ) != 0 )
	{
		NORMAL_ERR2( "CSDReader: error during parsing ", csdfile );
        throw CSDReadException();
	}

	csd_document_ = parser.getDocument();
	DOMElement* element = csd_document_->getDocumentElement();
	DOMNodeList* nodeList;
	DOMNodeList* nodeList2;
	DOMElement* elem;
	unsigned int len = 0;
	unsigned int len2 = 0;
	unsigned int i = 0;

    //
	// implementation
	//
	nodeList = element->getElementsByTagName(X("implementation"));
	len = nodeList->getLength();
	bool impl_found = false;
    for( i = 0; i < len; ++i )
    {
		elem = (DOMElement*)(nodeList->item(i));
		if (!XMLString::compareString(elem->getAttribute(X("id")), X(id.c_str())))
		{
			impl_found = true;

			//
			// search for descriptor
			//
			nodeList2 = elem->getElementsByTagName(X("descriptor"));
			len2 = nodeList2->getLength();
			if(len2 == 1)
			{
				ccd_file_ = descriptor((DOMElement*)(nodeList2->item(0)));
			}
			else if(len > 1)
			{
				ccd_file_ = descriptor((DOMElement*)(nodeList2->item(0)));
				NORMAL_ERR( "CSDReader: multiple descriptors" );
			}

			break;
		}
    }
	if( !impl_found )
	{
		NORMAL_ERR3( "CSDReader: implementation for ", id, " missing!" );
		throw CSDReadException();
	}

    //
	// corba component descriptor
	//
    if( ccd_file_.empty() )
    {
		nodeList = element->getElementsByTagName(X("descriptor"));
		len = nodeList->getLength();
		if(len == 1)
		{
			ccd_file_ = descriptor((DOMElement*)(nodeList->item(0)));
		}
		else if(len > 1)
		{
			NORMAL_ERR( "CSDReader: multiple descriptor elements!" );
		}

		if (ccd_file_.empty())
        {
			NORMAL_ERR2( "CSDReader: missing component descriptor for ", id );
	        throw CSDReadException();
        }
    }

	return path_ + ccd_file_;
}
示例#27
0
void pop_monteTest::testReportML()
{
  printf( "\n--- %s ---\n", "Report Test" );
  const double scale = 0.05;

  //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  // Parse the generated reportML document.
  //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  xercesc::XercesDOMParser *reportParser = new xercesc::XercesDOMParser;
  reportParser->setValidationScheme( XercesDOMParser::Val_Auto );
  reportParser->setDoNamespaces( true );
  reportParser->setDoSchema( true );
  reportParser->setValidationSchemaFullChecking( true );
  reportParser->setCreateEntityReferenceNodes( true );
  
  try{
    reportParser->parse( fSavedReportML );
  }
  catch( const XMLException& e )
    {
      XMLPlatformUtils::Terminate();
      char buf[MAXCHARS + 1];
      snprintf( buf, MAXCHARS, "An error occurred during parsing %s.\n   Message: %s\n",
	       fReportML, XMLString::transcode(e.getMessage() ) );
      
      CPPUNIT_ASSERT_MESSAGE( buf, false );
    }
  catch( const DOMException& e )
    {
      
      XMLCh errText[MAXCHARS + 1]; 
      if (DOMImplementation::loadDOMExceptionMsg(e.code, errText, MAXCHARS))
	{
          XMLPlatformUtils::Terminate();
          char buf[MAXCHARS + 1];
          snprintf( buf, MAXCHARS, "DOM Error during parsing \"%s\".\nDOMException code is: %d.\nMessage is: %s.\n",
                   fReportML, e.code, XMLString::transcode(errText) );
          CPPUNIT_ASSERT_MESSAGE( buf, false );
	}
    }
  catch( ... )
    {
      XMLPlatformUtils::Terminate();
      char buf[MAXCHARS + 1];
      snprintf( buf, MAXCHARS, "An unknown error occurred during parsing %s.\n", fSavedReportML );
      
      CPPUNIT_ASSERT_MESSAGE( buf, false );
    }
  
  report = reportParser->getDocument();
  CPPUNIT_ASSERT( report );

  //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  // Verify if any error was caught during the runtime.
  // The <eroor_list> tag should appear even when there's no error.
  // However, it should not contain any error message.
  //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  DOMNodeList *error_list;
  error_list = report->getElementsByTagName( XML.X_ERROR_LIST );
  CPPUNIT_ASSERT_EQUAL( 1, (int)error_list->getLength() );
  DOMElement* error = dynamic_cast<DOMElement*>( error_list->item(0) );
  if( error->hasChildNodes() )
  {
     const XMLCh* error_message = error->getFirstChild()->getNodeValue();
     CPPUNIT_ASSERT_MESSAGE( "<error_list> should have been empty.", XMLString::isAllWhiteSpace( error_message ) );
  }
  else
  {
     CPPUNIT_ASSERT( true );
  }
   
  //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  // Verify the objective value.
  //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  double obj_out = 0.0;
  DOMNodeList * objOut_list = report->getElementsByTagName( XML.X_POP_OBJ_OUT );
  if( objOut_list->getLength() > 0 )
    {
      DOMElement* objOut = dynamic_cast<DOMElement*>( objOut_list->item(0) );
      DOMNodeList* value_list = objOut->getElementsByTagName( XML.X_VALUE );
      int n = value_list->getLength();
      CPPUNIT_ASSERT_EQUAL( 1, n );
      obj_out = atof( XMLString::transcode( value_list->item(0)->getFirstChild()->getNodeValue() ) );      
      // CPPUNIT_ASSERT_DOUBLES_EQUAL( nm_obj, obj_out, scale * nm_obj );
    }

  //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  // Verify the final estimate for theta
  //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  double theta_out[thetaLen];
  DOMNodeList * thetaOut_list = report->getElementsByTagName( XML.X_THETA_OUT );
  if( thetaOut_list->getLength() > 0 )
    {
      DOMElement* thetaOut = dynamic_cast<DOMElement*>( thetaOut_list->item(0) );
      DOMNodeList* value_list = thetaOut->getElementsByTagName( XML.X_VALUE );
      int n = value_list->getLength();
      CPPUNIT_ASSERT_EQUAL( thetaLen, n );
      for( int i=0; i<n; i++ )
	{
	  theta_out[i] = atof( XMLString::transcode( value_list->item(i)->getFirstChild()->getNodeValue() ) );
	  //CPPUNIT_ASSERT_DOUBLES_EQUAL( nm_theta[i], theta_out[i], scale * nm_theta[i] );
	}
    }

  //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  // Verify the final estimate for Omega
  //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  double omega_out[omegaOrder];
  DOMNodeList * omegaOut_list = report->getElementsByTagName( XML.X_OMEGA_OUT );
  if( omegaOut_list->getLength() > 0 )
    {
      DOMElement* omegaOut = dynamic_cast<DOMElement*>( omegaOut_list->item(0) );
      DOMNodeList* value_list = omegaOut->getElementsByTagName( XML.X_VALUE );
      int n = value_list->getLength();
      CPPUNIT_ASSERT_EQUAL( omegaOrder, n );
      for( int i=0; i<+n; i++ )
	{
	  omega_out[i] = atof( XMLString::transcode( value_list->item(i)->getFirstChild()->getNodeValue() ) );
	  //CPPUNIT_ASSERT_DOUBLES_EQUAL( nm_omega[i], omega_out[i], scale * nm_omega[i] );
	}
    }

  //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  // Grab a pointer to the top of "pop_monte_result" sub-tree.
  //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  DOMNodeList *pop_monte_result = report->getElementsByTagName( XML.X_POP_MONTE_RESULT );
  CPPUNIT_ASSERT( pop_monte_result->getLength() == 1 );
  DOMElement *ind_stat_result = dynamic_cast<DOMElement*>( pop_monte_result->item( 0 ) );
  CPPUNIT_ASSERT( ind_stat_result != NULL );
  okToClean = true;
}
示例#28
0
void CouchRunner::runIR( CouchWorkingMemory *wm ){
  /*
  Module *theM;
  theM = ParseBitcodeFile( MemoryBuffer::getFile("out.bc"), 
			   getGlobalContext(),
			   &error );
  */

  // Loads intermediate representation source
  std::string error;
  SMDiagnostic Err;
  std::auto_ptr<Module> theM(ParseAssemblyFile( fSourceFile, Err, getGlobalContext() ));
  std::cout << "KBVM v1.0 (experimental)\nIntermediate Representation Interpreter\n";  
  std::cout << "Parsing " << fSourceFile << "\n";
  // Verifies module
  try{
    std::string VerifErr;
    if (verifyModule( *theM.get(), ReturnStatusAction, &VerifErr)) {
      errs() << fSourceFile
	     << ": assembly parsed, but does not verify as correct!\n";
      errs() << VerifErr;
      return;
    }
  }
  catch(...){
    std::cerr << "Verification of module failed!\n";
    return;
  }
  // Prepares to execute
  S_wm = wm;

  IRBuilder<>  theBuilder( getGlobalContext() );
  // Create the JIT.
  S_TheExecutionEngine = ExecutionEngine::create(theM.get());

  //ExistingModuleProvider OurModuleProvider( M );
  FunctionPassManager OurFPM( theM.get() );
      
  // Set up the optimizer pipeline.  
  // Start with registering info about how the
  // target lays out data structures.
  OurFPM.add(new TargetData(*S_TheExecutionEngine->getTargetData()));
  // Promote allocas to registers.
  OurFPM.add(createPromoteMemoryToRegisterPass());
  // Do simple "peephole" optimizations and bit-twiddling optzns.
  OurFPM.add(createInstructionCombiningPass());
  // Reassociate expressions.
  OurFPM.add(createReassociatePass());
  // Eliminate Common SubExpressions.
  OurFPM.add(createGVNPass());
  // Simplify the control flow graph (deleting unreachable blocks, etc).
  OurFPM.add(createCFGSimplificationPass());

  // Set the global so the code gen can use this.
  S_TheFPM = &OurFPM;

  // Inital setup of the agenda
  unsigned int i;
  CouchRunner::S_Agenda->reset();

  // Initial setup of the working memory
  S_TheFPM->run( *theM->getFunction("ag_forward") );

  std::string sign, val;
  Function *FFwrd = S_TheExecutionEngine->FindFunctionNamed( "ag_forward" );
  void *FFwrdPtr = S_TheExecutionEngine->getPointerToFunction(FFwrd);
  void (*FFwrdP)(const char*) = (void (*)( const char*))FFwrdPtr;
  DOMElement *elt;

  DOMNodeList *domSuggests = 
    fDom->getElementsByTagName( XMLString::transcode("suggest") );
  for( i = 0; i < domSuggests->getLength(); i++ ){
    CouchRunner::S_Agenda->push( std::string(XMLString::transcode( ((DOMText *)(domSuggests->item(i)->getFirstChild()))->getData() )), S_wm );
  }

  DOMNodeList *domVolunteers = 
    fDom->getElementsByTagName( XMLString::transcode("volunteer") );
  for( i = 0; i < domVolunteers->getLength(); i++ ){
    elt = (DOMElement *)(domVolunteers->item(i));
    sign = std::string( XMLString::transcode( ((DOMText *)(elt->getElementsByTagName(XMLString::transcode("var"))->item(0)->getFirstChild()))->getData() ) );
    val = std::string( XMLString::transcode( ((DOMText *)(elt->getElementsByTagName(XMLString::transcode("const"))->item(0)->getFirstChild()))->getData() ) );
    // TODO: update with type information
    if( std::string("true") == val ){
      S_wm->set( sign.c_str(), (int)1 );
    }
    else if( std::string("false") == val ){
      S_wm->set( sign.c_str(), (int)0 );
    }
    else if( isalpha( *(val.c_str()) ) ){
      S_wm->set( sign.c_str(), val.c_str() );
    }
    else{
      double d = strtod( val.c_str(), NULL );
      S_wm->set( sign.c_str(), d );
    }
    // Update agenda as if forwarded from execution
    FFwrdP( sign.c_str() );
  }


  std::cout << "Session Started\n" << *S_wm << *CouchRunner::S_Agenda;

  {
    // Creates the `entry' function that sets up the Agenda, which
    // also serves as continuation for the postponed calls
    std::vector<Value *> args;
    Function *Main;


    while( !CouchRunner::S_Agenda->empty() ){

      // Erase previous entry function if present
      if( NULL != (Main = theM->getFunction("entry")) ){
	Main->eraseFromParent();
      }
      // Creates code block
      Main = cast<Function>(
			    theM->getOrInsertFunction( "entry", 
						       Type::getInt32Ty(getGlobalContext()), 
						       (Type *)0)
			    );
      BasicBlock *EB = BasicBlock::Create(getGlobalContext(), 
					  "EntryBlock", Main);
      theBuilder.SetInsertPoint(EB);
      // Loops through the current agenda
      Value *res = NULL, *call;
      std::string hypo;

      // Copies agenda to current Agenda
	
      while( !CouchRunner::S_Agenda->empty() ){
	hypo = CouchRunner::S_Agenda->pop();
	if( WorkingMemory::WM_UNKNOWN == S_wm->knownp( hypo.c_str() ) ){
	  call = theBuilder.CreateCall(theM->getFunction( hypo ),
				       args.begin(),
				       args.end(), "suggest");
	  res = 
	    theBuilder.CreateIntCast( call, 
				      Type::getInt32Ty(getGlobalContext()), 
				      false, "cast_tmp" );
	}
      }
      theBuilder.CreateRet( res == NULL ? 
			    ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 2) : 
			    res );
      // Check it
      S_TheFPM->run( *Main );
      // Run it
      Function *F = S_TheExecutionEngine->FindFunctionNamed( "entry" );
      void *FPtr = S_TheExecutionEngine->getPointerToFunction(F);
      typedef int (*PFN)();
      PFN FP = reinterpret_cast<PFN>( FPtr );
      //      int (*FP)() = (int (*)())FPtr;
      printf( "Result = %d\n", FP() );
      std::cout << *S_wm << std::endl;
      std::cout << *CouchRunner::S_Agenda << std::endl;
    }  
    S_wm = NULL;
  }
}
	void InputManager::loadKeyMapping(const Ogre::String& filename)
	{
		using namespace XERCES_CPP_NAMESPACE;
		using XERCES_CPP_NAMESPACE::DOMDocument;
		using std::make_pair;

		XMLPlatformUtils::Initialize();
		XmlHelper::initializeTranscoder();

		XercesDOMParser* parser = new XercesDOMParser();
        parser->setValidationScheme(XercesDOMParser::Val_Always);    // optional.
        parser->setDoNamespaces(true);    // optional

/*        ErrorHandler* errHandler = (ErrorHandler*) new HandlerBase();
        parser->setErrorHandler(errHandler);*/

		XMLCh* ALT = XMLString::transcode("AltChar");
		XMLCh* SHIFT = XMLString::transcode("ShiftChar");
		XMLCh* NORMAL = XMLString::transcode("NormalChar");
		XMLCh* DESCR = XMLString::transcode("KeyDescription");
		XMLCh* CODE = XMLString::transcode("KeyCode");
		XMLCh* KEY = XMLString::transcode("Key");
		
		XmlPtr res = 
			XmlResourceManager::getSingleton().create(
			filename, 
			ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
		res->parseBy(parser);
		DOMDocument* doc = parser->getDocument();
		DOMElement* dataDocumentContent = doc->getDocumentElement();

		DOMNodeList* keymaps = dataDocumentContent->getElementsByTagName(KEY);
		for (unsigned int idx = 0; idx < keymaps->getLength(); idx++)
		{
			DOMElement* key = static_cast<DOMElement*>(keymaps->item(idx));
			int keycode = XMLString::parseInt(key->getAttribute(CODE));

			const XMLCh* xmlch;

			xmlch = key->getAttribute(NORMAL);
			if (xmlch != NULL && XMLString::stringLen(xmlch) > 0)
			{
				CeGuiString s(XmlHelper::transcodeToString(xmlch)); 
				mKeyMapNormal.insert(make_pair(keycode, s[0]));
			}

			xmlch = key->getAttribute(ALT);
			if (xmlch != NULL && XMLString::stringLen(xmlch) > 0)
			{
				CeGuiString s(XmlHelper::transcodeToString(xmlch)); 
				mKeyMapAlt.insert(make_pair(keycode, s[0]));
			}

			xmlch = key->getAttribute(SHIFT);
			if (xmlch != NULL && XMLString::stringLen(xmlch) > 0)
			{
				CeGuiString s(XmlHelper::transcodeToString(xmlch)); 
				mKeyMapShift.insert(make_pair(keycode, s[0]));
			}

			xmlch = key->getAttribute(DESCR);
			mKeyNames.insert(make_pair(keycode, XmlHelper::transcodeToString(xmlch)));
		}

		XMLString::release(&ALT);
		XMLString::release(&SHIFT);
		XMLString::release(&NORMAL);
		XMLString::release(&CODE);
		XMLString::release(&DESCR);
		XMLString::release(&KEY);

		doc->release();
		XMLPlatformUtils::Terminate();

        //XmlResourceManager::getSingleton().remove(filename);
        //res.setNull();
	}
示例#30
0
/**
 *  This function:
 *  - Tests the access and availability of the XML configuration file.
 *  - Configures the xerces-c DOM parser.
 *  - Reads and extracts the pertinent information from the XML config file.
 *
 *  @param in configFile The text string name of the configuration file.
 */
void
AppConfigFileParse::readConfigFile(string& configFile)
throw(std::runtime_error) {
    // Test to see if the file is ok.

    struct stat fileStatus;

    if (stat(configFile.c_str(), &fileStatus)<0) {
        if (errno == ENOENT)
            throw(std::runtime_error("Could not find application(s) configuration file '" + configFile + "'."));
        else if (errno == ENOTDIR)
            throw(std::runtime_error("A component of the path is not a directory."));
#ifndef _WIN32
        else if (errno == ELOOP)
            throw(std::runtime_error("Too many symbolic links encountered while traversing the path."));
#endif
        else if (errno == EACCES)
            throw(std::runtime_error("Permission denied."));
        else if (errno == ENAMETOOLONG)
            throw(std::runtime_error("File can not be read\n"));
    }
    // Configure DOM parser.

    m_ConfigFileParser->setValidationScheme(XercesDOMParser::Val_Never);
    m_ConfigFileParser->setDoNamespaces(false);
    m_ConfigFileParser->setDoSchema(false);
    m_ConfigFileParser->setLoadExternalDTD(false);

    try {
        m_ConfigFileParser->parse(configFile.c_str());

        // no need to free this pointer - owned by the parent parser object
        DOMDocument* xmlDoc = m_ConfigFileParser->getDocument();

        // Get the top-level element: NAme is "root". No attributes for "root"
        DOMElement* elementRoot = xmlDoc->getDocumentElement();
        if (!elementRoot) throw(std::runtime_error("empty XML document"));

        DOMNodeList* applications = elementRoot->getElementsByTagName(TAG_Application);
        XMLSize_t nodeCount = applications->getLength();

        // Loop all <Application> tags
        for (XMLSize_t xx = 0; xx < nodeCount; ++xx) {

            DOMNode* currentNode = applications->item(xx);

            if (currentNode->getNodeType() &&  // true is not NULL
                    currentNode->getNodeType() == DOMNode::ELEMENT_NODE) { // is element

                Application* app = new Application();

                DOMElement* currentElememt = dynamic_cast< xercesc::DOMElement* >(currentNode);

                DOMNodeList* children = currentElememt->getChildNodes();

                for (XMLSize_t yy = 0; yy < children->getLength(); ++yy) {

                    DOMNode* _node = children->item(yy);

                    DOMElement* _element = static_cast< xercesc::DOMElement* >(_node);

                    // Application name
                    if (XMLString::equals(_element->getTagName(), TAG_Name)) {
                        DOMNodeList* children2 = _element->getChildNodes();
                        for (XMLSize_t index = 0; index < children2->getLength(); ++index) {
                            //std::cout << XMLString::transcode(children2->item(index)->getNodeValue()) << std::endl;
                            app->m_name = XMLString::transcode(children2->item(index)->getNodeValue());
                        }
                    }

                    // Application executable
                    if (XMLString::equals(_element->getTagName(), TAG_Executable)) {
                        DOMNodeList* children2 = _element->getChildNodes();
                        for (XMLSize_t index = 0; index < children2->getLength(); ++index) {
                            //std::cout << XMLString::transcode(children2->item(index)->getNodeValue()) << std::endl;
                            app->m_executable = XMLString::transcode(children2->item(index)->getNodeValue());
                        }
                    }

                    // Application IP
                    if (XMLString::equals(_element->getTagName(), TAG_Ip)) {
                        DOMNodeList* children2 = _element->getChildNodes();
                        for (XMLSize_t index = 0; index < children2->getLength(); ++index) {
                            //std::cout << XMLString::transcode(children2->item(index)->getNodeValue()) << std::endl;
                            app->m_ip = XMLString::transcode(children2->item(index)->getNodeValue());
                        }
                    }

                    // Application Port
                    if (XMLString::equals(_element->getTagName(), TAG_Port)) {
                        DOMNodeList* children2 = _element->getChildNodes();
                        for (XMLSize_t index = 0; index < children2->getLength(); ++index) {
                            //std::cout << XMLString::transcode(children2->item(index)->getNodeValue()) << std::endl;
                            app->m_port = XMLString::transcode(children2->item(index)->getNodeValue());
                        }
                    }

                    // Application seed
                    if (XMLString::equals(_element->getTagName(), TAG_Seed)) {
                        DOMNodeList* children2 = _element->getChildNodes();
                        for (XMLSize_t index = 0; index < children2->getLength(); ++index) {
                            //std::cout << XMLString::transcode(children2->item(index)->getNodeValue()) << std::endl;
                            app->m_seed = XMLString::transcode(children2->item(index)->getNodeValue());
                        }
                    }

                    // Application Rate
                    if (XMLString::equals(_element->getTagName(), TAG_Rate)) {
                        DOMNodeList* children2 = _element->getChildNodes();
                        for (XMLSize_t index = 0; index < children2->getLength(); ++index) {
                            //std::cout << XMLString::transcode(children2->item(index)->getNodeValue()) << std::endl;
                            app->m_rate = XMLString::transcode(children2->item(index)->getNodeValue());
                        }
                    }

                    // Application Result Container
                    if (XMLString::equals(_element->getTagName(), TAG_ResultContainer)) {
                        DOMNodeList* children2 = _element->getChildNodes();
                        for (XMLSize_t index = 0; index < children2->getLength(); ++index) {
                            //std::cout << XMLString::transcode(children2->item(index)->getNodeValue()) << std::endl;
                            app->m_resultContainer = XMLString::transcode(children2->item(index)->getNodeValue());
                        }
                    }

                    // Application Service Id
                    if (XMLString::equals(_element->getTagName(), TAG_ServiceId)) {
                        const XMLCh* xmlch_Unicast  = _element->getAttribute(ATTR_Unicast);
                        app->m_unicastServiceId = XMLString::transcode(xmlch_Unicast);
                        const XMLCh* xmlch_Multicast  = _element->getAttribute(ATTR_Multicast);
                        app->m_multicastServiceId = XMLString::transcode(xmlch_Multicast);
                        const XMLCh* xmlch_Broadcast  = _element->getAttribute(ATTR_Broadcast);
                        app->m_broadcastServiceId = XMLString::transcode(xmlch_Broadcast);
                        const XMLCh* xmlch_TopoBroadcast  = _element->getAttribute(ATTR_TopoBroacast);
                        app->m_topoBroadcastServiceId = XMLString::transcode(xmlch_TopoBroadcast);
                        const XMLCh* xmlch_GeoBroadcast  = _element->getAttribute(ATTR_GeoBroacast);
                        app->m_geoBroadcastServiceId = XMLString::transcode(xmlch_GeoBroadcast);
                    }

                    // Applications nodes ID (nodes that will have installed the application regardless of the penetration rates)
                    if (XMLString::equals(_element->getTagName(), TAG_Stations)) {
                        DOMNodeList* children2 = _element->getChildNodes();
                        for (XMLSize_t index = 0; index < children2->getLength(); ++index) {
                            DOMNode* __node = children2->item(index);
                            DOMElement* __element = static_cast< xercesc::DOMElement* >(__node);
                            if (XMLString::equals(__element->getTagName(), TAG_Id)) {
                                DOMNodeList* children3 = __element->getChildNodes();
                                for (XMLSize_t index2 = 0; index2 < children3->getLength(); ++index2) {
                                    //std::cout << XMLString::transcode(children3->item(index2)->getNodeValue()) << std::endl;
                                    app->m_stations.push_back(XMLString::transcode(children3->item(index2)->getNodeValue()));
                                }
                            }
                        }
                    }
                }

                m_ApplicationCollection->push_back(app);
            }
        }
    } catch (xercesc::XMLException& e) {
        char* message = xercesc::XMLString::transcode(e.getMessage());
        ostringstream errBuf;
        errBuf << "Error parsing file: " << message << flush;
        XMLString::release(&message);
    }
}