Example #1
0
int addSegmentedParagraphToSection(vector<string> par, DOMElement* sect, const char* pid){
  DOMElement* aPar = NULL;
  int sid = 1;
  aPar =
  (sect->getOwnerDocument())->createElement(XMLString::transcode("paragraph"));

  aPar->setAttribute(XMLString::transcode("id"),
                     XMLString::transcode(pid));

  if ( aPar != NULL ) {
    for (vector<string>::iterator it = par.begin(); it != par.end(); it++) {
      if (verbose) cerr << "s";
      DOMElement* aSent = NULL;
      DOMElement* aSentText = NULL;
      aSent = (sect->getOwnerDocument())->createElement(XMLString::transcode("sentence"));
      aSentText = (sect->getOwnerDocument())->createElement(XMLString::transcode("text"));
      if ( (aSent != NULL) && (aSentText != NULL) ) {
        aSentText->setTextContent(XMLString::transcode((*it).c_str()));
        aSent->appendChild(aSentText);
        aPar->appendChild(aSent);
        stringstream sentId;
        sentId << pid << _ID_PREFIX_SENTENCE << sid;
        aSent->setAttribute(XMLString::transcode("id"),
                            XMLString::transcode(sentId.str().c_str()));
        sid++;
      }
    }
    sect->appendChild(aPar);
  }
  if (verbose) cerr << " ";
  return sid-1;
}
void EntityXMLFileWriter::WriteEntity(World* world, EntityID entity)
{
    using namespace xercesc;
    DOMDocument* doc = m_DOMImplementation->createDocument(nullptr, X("Entity"), nullptr);
    DOMElement* root = doc->getDocumentElement();
    root->setAttribute(X("xmlns:xsi"), X("http://www.w3.org/2001/XMLSchema-instance"));
    root->setAttribute(X("xsi:noNamespaceSchemaLocation"), X("../Types/Entity.xsd"));
    root->setAttribute(X("xmlns:c"), X("components"));
    const std::string& name = world->GetName(entity);
    if (!name.empty()) {
        root->setAttribute(X("name"), X(name));
    }
    
    DOMElement* componentsElement = doc->createElement(X("Components"));
    root->appendChild(componentsElement);
    appentEntityComponents(componentsElement, world, entity);

    DOMElement* childrenElement = doc->createElement(X("Children"));
    root->appendChild(childrenElement);
    appendEntityChildren(childrenElement, world, entity);

    try {
        LocalFileFormatTarget* target = new LocalFileFormatTarget(X(m_FilePath.string()));
        DOMLSOutput* output = static_cast<DOMImplementationLS*>(m_DOMImplementation)->createLSOutput();
        output->setByteStream(target);
        m_DOMLSSerializer->write(doc, output);
        delete target;
    } catch (const std::runtime_error& e) {
        LOG_ERROR("Failed to save \"%s\": %s", m_FilePath.c_str(), e.what());
    }

    doc->release();
}
Example #3
0
File: XCube.cpp Project: mydw/mydw
bool XCube::wrapXML(xercesc::DOMDocument *doc,xercesc::DOMElement *tempElem)
{
	DOMElement *cubeElem = doc->createElement(XMLString::transcode("Cube"));

	if(this->_name != "")
		cubeElem->setAttribute(XMLString::transcode("name"),XMLString::transcode(this->_name.c_str()));
	if(this->_fact != "")
		cubeElem->setAttribute(XMLString::transcode("tablename"),XMLString::transcode(this->_fact.c_str()));

	cubeElem->appendChild(tempElem);

	XSchema *tempschema = this->getSchema();
	
	DOMElement* schemaElem = doc->getDocumentElement();//create root
	
		
	if(DataSource *tempDS = tempschema->getDataSource())
	{				
			schemaElem -> appendChild(tempDS->recursiveXML(doc));
	}
	schemaElem -> appendChild(cubeElem);
	return true;
		

}
Example #4
0
void saveItemsBranch(DOMNode* node, CTibiaTree* parent, xercesc::DOMDocument *doc)
{
	int size = parent->children.size();
	for (int i = 0; i < size; i++)
	{
		CTibiaTree* child = parent->children[i];
		if (child->HasChildren() && child->data->GetType() == TT_BRANCH_NODE)
		{
			CTibiaTreeBranchData* data = (CTibiaTreeBranchData*)(child->data);

			DOMElement* itemElem = doc->createElement(XMLString::transcode("branch"));
			itemElem->setAttribute(XMLString::transcode("name"), XMLString::transcode(data->GetName()));
			node->appendChild(itemElem);
			saveItemsBranch(itemElem, child, doc);
		}
		else if (!child->HasChildren() && child->data->GetType() == TT_ITEM_NODE)
		{
			CTibiaTreeItemData* data = (CTibiaTreeItemData*)(child->data);
			char buf[512];

			int id                = data->GetId();
			int type              = data->GetItemType();
			bool looted           = data->IsLooted();
			DOMElement*  itemElem = doc->createElement(XMLString::transcode("item"));
			itemElem->setAttribute(XMLString::transcode("name"), XMLString::transcode(data->GetName()));
			sprintf(buf, "0x%x", id);
			itemElem->setAttribute(XMLString::transcode("id"), XMLString::transcode(buf));
			sprintf(buf, "%d", looted ? 1 : 0);
			itemElem->setAttribute(XMLString::transcode("looted"), XMLString::transcode(buf));
			sprintf(buf, "%d", type);
			itemElem->setAttribute(XMLString::transcode("type"), XMLString::transcode(buf));
			node->appendChild(itemElem);
		}
	}
}
Example #5
0
// 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);
}
/*
 * Add an empty table (required by the DTD).
 */
static void AddBlankReportTable(DOMDocument* doc, DOMElement* parentElement)
{
    DOMElement* element = doc->createElement(ToXMLCh(REPORT_RESULTS_ELEMENT_NAME));
    element->setAttribute(ToXMLCh(NAME_ATTRIBUTE), ToXMLCh("NA"));
    element->setAttribute(ToXMLCh(ROWS_ATTRIBUTE), ToXMLCh("0"));
    element->setAttribute(ToXMLCh(COLS_ATTRIBUTE), ToXMLCh("0"));
    parentElement->appendChild(element);
}
/* Create a root element */
static DOMElement *CreateGenericReportElement(DOMDocument* doc)
{
    DOMElement* element = doc->createElement(ToXMLCh(GENERIC_REPORT_ELEMENT_NAME));
    element->setAttribute(ToXMLCh(TYPE_ATTRIBUTE), ToXMLCh(REPORT_TYPE));
    element->setAttribute(ToXMLCh(TITLE_ATTRIBUTE), ToXMLCh(REPORT_TITLE));
    DateTime now = DateTime::GetCurrentDateTime();
    element->setAttribute(ToXMLCh(DATE_ATTRIBUTE), ToXMLCh(now.ToString()));
    return element;
}
void EntityXMLFileWriter::appendEntityChildren(xercesc::DOMElement* parentElement, const World* world, EntityID entity)
{
    using namespace xercesc;
    DOMDocument* doc = parentElement->getOwnerDocument();

    auto childrenRange = world->GetEntityChildren().equal_range(entity);
    for (auto it = childrenRange.first; it != childrenRange.second; ++it) {
        EntityID childEntity = it->second;

        DOMElement* entityElement = doc->createElement(X("Entity"));
        const std::string& name = world->GetName(childEntity);
        if (!name.empty()) {
            entityElement->setAttribute(X("name"), X(name));
        }
        parentElement->appendChild(entityElement);

        DOMElement* componentsElement = doc->createElement(X("Components"));
        entityElement->appendChild(componentsElement);
        appentEntityComponents(componentsElement, world, childEntity);

        DOMElement* childrenElement = doc->createElement(X("Children"));
        entityElement->appendChild(childrenElement);
        appendEntityChildren(childrenElement, world, childEntity);
    }
}
Example #9
0
void Triggerconf::createConfigElement (string module, string submodule, string configname)
{
	if (rootnode == NULL) return;
	
	if (existsConfigElement (module, submodule, configname)) {
		resetError ();	
		return;
	}

	DOMNode* currentSubmodule = selectSubmodule (module, submodule);
	if (currentSubmodule == NULL) return;

	XMLCh* xitemname	= XMLString::transcode (ELEMENT_CONFIGITEM_NAME);
	DOMElement* node	= rootnode->getOwnerDocument ()->createElement	(xitemname);
	XMLString::release	(&xitemname);

	XMLCh* xattrname	= XMLString::transcode (ATTRIBUTE_NAME);
	XMLCh* xconfigname	= XMLString::transcode (configname.c_str ());
	node->setAttribute	(xattrname, xconfigname);
	XMLString::release	(&xattrname);
	XMLString::release	(&xconfigname);

	currentSubmodule->appendChild (node);

	resetError ();
}
Example #10
0
void Triggerconf::createSubmodule (string module, string submodule)
{
	if (rootnode == NULL) return;
	
	if (existsSubmodule (module, submodule)) {
		resetError ();	
		return;
	}

	DOMNode* currentModule	= selectModule (module);
	if (currentModule == NULL) return;
	
	XMLCh* xsubmodule	= XMLString::transcode (ELEMENT_SUBMODULE_NAME);
	DOMElement* node	= rootnode->getOwnerDocument ()->createElement	(xsubmodule);
	XMLString::release	(&xsubmodule);

	XMLCh* xattrname	= XMLString::transcode (ATTRIBUTE_NAME);
	XMLCh* xsubmodulename	= XMLString::transcode (submodule.c_str ());
	node->setAttribute	(xattrname, xsubmodulename);
	XMLString::release	(&xattrname);
	XMLString::release	(&xsubmodulename);

	currentModule->appendChild (node);

	resetError ();
}
void appendElementWithText( DOMNode* cur, DOMNode* reply,
                            const char* name, const char* text,
                            int indentLevel, bool indent,
                            attrVect* attribute ) {

   MC2String indentStr( indentLevel*3, ' ' );
   indentStr.insert( 0, "\n" );   
   DOMDocument* doc = XMLTool::getOwner( reply );
   DOMElement* textElement = doc->createElement( X( name ) );
   if ( text != NULL ) {
      textElement->appendChild( doc->createTextNode( X( text ) ) );
   }

   if ( attribute != NULL ) {
      for ( uint32 i = 0 ; i < attribute->size() ; ++i ) {
         textElement->setAttribute( X( (*attribute)[ i ].first ), 
                                    X( (*attribute)[ i ].second ) );
      }
   }

   // Add textElement to cur
   if ( indent ) {
      cur->appendChild( doc->createTextNode( X( indentStr.c_str() ) ) );
   }
   cur->appendChild( textElement );
}
Example #12
0
void ILI2Handler::startElement(
    CPL_UNUSED const XMLCh* const uri,
    CPL_UNUSED const XMLCh* const localname,
    const XMLCh* const qname,
    const Attributes& attrs
    ) {
  // start to add the layers, features with the DATASECTION
  char *tmpC = NULL;
  m_nEntityCounter = 0;
  if ((level >= 0) || (cmpStr(ILI2_DATASECTION, tmpC = XMLString::transcode(qname)) == 0)) {
    level++;

    if (level >= 2) {

      // create the dom tree
      DOMElement *elem = (DOMElement*)dom_doc->createElement(qname);
      
      // add all attributes
      unsigned int len = attrs.getLength();
      for (unsigned int index = 0; index < len; index++)
        elem->setAttribute(attrs.getQName(index), attrs.getValue(index));
      dom_elem->appendChild(elem);
      dom_elem = elem;
    }
  }
  XMLString::release(&tmpC);
}
Example #13
0
DOMElement* EppAuthInfo::toXML( DOMDocument& doc, const DOMString& tag )
{
	DOMElement* body = doc.createElement(tag);
	DOMElement* elm;
	if( (type.isNotNull()) && type.equals(TYPE_PW) )
	{
		elm = doc.createElement(XS("pw"));
		body->appendChild(elm);
		if( roid.isNotNull() && roid.length() > 0 )
		{
			elm->setAttribute(XS("roid"), roid);
		}
		if( value.isNotNull() )
		{
			elm->appendChild(doc.createTextNode(value));
		}
	}
	else if( (type.isNotNull()) && type.equals(TYPE_EXT) )
	{
		elm = doc.createElement(XS("ext"));
		body->appendChild(elm);
	}

	return body;
}
Example #14
0
XERCES_CPP_NAMESPACE_USE

	
void SaveFileTreeToXML(const XMLCh* RootPath, DOMNode* RootNode, XERCES_CPP_NAMESPACE::DOMDocument* Document)
{
	WIN32_FIND_DATA FindData;
	ZeroMemory( &FindData, sizeof(WIN32_FIND_DATA));
	XMLSize_t SearchPatternLen = XMLString::stringLen( RootPath ) + 1 +  1;
	XMLCh* SearchPattern = new XMLCh[SearchPatternLen];
	ZeroMemory(SearchPattern, sizeof(XMLCh)*SearchPatternLen );
	XMLString::catString( SearchPattern, RootPath );
	XMLString::catString( SearchPattern, L"*");
	
	HANDLE hSearch = FindFirstFile(SearchPattern, &FindData);
	delete[] SearchPattern;
	if( INVALID_HANDLE_VALUE == hSearch )
		return;
	do
	{
		XMLCh* FileName = FindData.cFileName;
		if( FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
		{
			if( (XMLString::compareIString(FileName,L".")!=0) &&
				(XMLString::compareIString(FileName,L"..")!=0) )
			{
				DOMElement* dir = Document->createElement(L"directory");
				dir->setAttribute(L"name", FileName );
				RootNode->appendChild(dir);
				XMLSize_t SubDirPathLen = XMLString::stringLen( RootPath ) + XMLString::stringLen( FileName ) + 1  + 1;
				XMLCh* SubDir = new XMLCh[ SubDirPathLen ];
				ZeroMemory( SubDir, sizeof(XMLCh)*SubDirPathLen );
				XMLString::catString( SubDir, RootPath );
				XMLString::catString( SubDir, FileName);
				XMLString::catString( SubDir, L"\\" );
				SaveFileTreeToXML( SubDir, dir, Document );
				delete[] SubDir;
			}
		}
		else
		{
			DOMElement* file = Document->createElement(L"file");
			file->setAttribute(L"name", FileName );
			RootNode->appendChild(file);
		}
	}while( FindNextFile( hSearch, &FindData) != 0 );
	FindClose( hSearch );
}
Example #15
0
File: XCube.cpp Project: mydw/mydw
xercesc::DOMElement *XCube::recursiveXML(xercesc::DOMDocument* doc)
{
	DOMElement *cubeElem = doc->createElement(XMLString::transcode("Cube"));

	if(this->_name != "")
		cubeElem->setAttribute(XMLString::transcode("name"),XMLString::transcode(this->_name.c_str()));
	if(this->_fact != "")
		cubeElem->setAttribute(XMLString::transcode("tablename"),XMLString::transcode(this->_fact.c_str()));

	if(this->_dimensions.size() > 0)
	{
		Dimension *tempdimension;
		for(int i = 0;i < this->_dimensions.size() ;i++)
		{
			tempdimension = this->getDimension(_dimensions[i]->getName());
			cubeElem->appendChild(tempdimension->recursiveXML(doc));

		}

	}

	if(this->_measures.size() > 0)
	{
		Measure *tempMeasures;
		for(int i = 0;i < this->_measures.size() ;i++)
		{
			tempMeasures = this->getMeasure(_measures[i]->getName());
			cubeElem->appendChild(tempMeasures->recursiveXML(doc));

		}

	}

	if(this->_calcmembers.size() > 0)
	{
		calcMember *tempCalcmember;
		for(int i = 0;i < this->_calcmembers.size() ;i++)
		{
			tempCalcmember = this->getCalMember(_calcmembers[i]->getName());
			cubeElem->appendChild(tempCalcmember->recursiveXML(doc));

		}

	}

	return cubeElem;
}
/* Add the name/value pairs to the document. */
static void AddNameValuePairs(const char *title, ParameterNameValuePairList &params, DOMDocument* doc, DOMElement* parentElement)
{
    if (params.size() == 0)
        return;

    DOMElement* element = doc->createElement(ToXMLCh(NAME_VALUE_PAIRS_ELEMENT_NAME));
    element->setAttribute(ToXMLCh(NAME_ATTRIBUTE), ToXMLCh(title));
    for (ParameterNameValuePairList::iterator it=params.begin(); it!=params.end(); it++)
    {
        ParameterNameValuePair &pair = *it;
        DOMElement* pairElement = doc->createElement(ToXMLCh(NAME_VALUE_PAIR_ELEMENT_NAME));
        pairElement->setAttribute(ToXMLCh(NAME_ATTRIBUTE), ToXMLCh(pair.Name));
        pairElement->setAttribute(ToXMLCh(VALUE_ATTRIBUTE), ToXMLCh(pair.Value));
        element->appendChild(pairElement);
    }
    parentElement->appendChild(element);
}
Example #17
0
// 2006/12/16
void handleFile(char* filein, char* fileout, int mode)
{
  if (mode==_TXT2TXTMODE) {
    int result;
    if (filein == NULL) {
      if (fileout == NULL) result = seg->segmentStream(cin,cout);
      else {
        ofstream* fout = new ofstream(fileout);
        result = seg->segmentStream(cin,*fout);
        fout->close();
      }
    } else {
      ifstream* fin = new ifstream(filein);
      ofstream* fout = new ofstream(fileout);
      result = seg->segmentStream(*fin,*fout);
      fin->close();
      fout->close();
    } 
    // BROKEN, result is false 2006/11/07
    //if (verbose) 
    //  cerr << "> Segmented in " << result << " sentences." << endl;
  } 
  else if (mode==_TXT2XMLMODE) {

    DOMDocument* out = xmlInterface->createDocument("document");
    DOMElement* root = out->getDocumentElement();
    if (filein != NULL)
      root->setAttribute(XMLString::transcode("filename"),
                         XMLString::transcode(filein));
    DOMElement* contents = out->createElement(XMLString::transcode("content"));
    DOMElement* body = out->createElement(XMLString::transcode("body"));
    DOMElement* section = out->createElement(XMLString::transcode("section"));
    section->setAttribute(XMLString::transcode("analyze"),
                          XMLString::transcode("yes"));
    DOMText* text = 
      out->createTextNode(XMLString::transcode(getFileContents(filein).c_str()));
    section->appendChild(text);
    body->appendChild(section);
    contents->appendChild(body);
    root->appendChild(contents);
    handleDocument(out,fileout);
  } 
  else if  (mode==_XML2XMLMODE) {
    handleDocument(xmlInterface->parse(filein),fileout);
  }
}
Example #18
0
void  ParameterGrp::SetBool(const char* Name, bool bValue)
{
    // find or create the Element
    DOMElement *pcElem = FindOrCreateElement(_pGroupNode,"FCBool",Name);
    // and set the vaue
    pcElem->setAttribute(XStr("Value").unicodeForm(), XStr(bValue?"1":"0").unicodeForm());
    // trigger observer
    Notify(Name);
}
Example #19
0
void  ParameterGrp::SetUnsigned(const char* Name, unsigned long lValue)
{
    char cBuf[256];
    // find or create the Element
    DOMElement *pcElem = FindOrCreateElement(_pGroupNode,"FCUInt",Name);
    // and set the vaue
    sprintf(cBuf,"%lu",lValue);
    pcElem->setAttribute(XStr("Value").unicodeForm(), XStr(cBuf).unicodeForm());
    // trigger observer
    Notify(Name);
}
Example #20
0
void  ParameterGrp::SetFloat(const char* Name, double dValue)
{
    char cBuf[256];
    // find or create the Element
    DOMElement *pcElem = FindOrCreateElement(_pGroupNode,"FCFloat",Name);
    // and set the value
    sprintf(cBuf,"%.12f",dValue); // use %.12f instead of %f to handle values < 1.0e-6
    pcElem->setAttribute(XStr("Value").unicodeForm(), XStr(cBuf).unicodeForm());
    // trigger observer
    Notify(Name);
}
DOMElement* EppFeeCredit::toXML( DOMDocument& doc, const DOMString& tag )
{
	DOMElement* body = doc.createElement(tag);

	if( this->description.length() > 0 )
	{
		body->setAttribute(XS("description"), this->description);
	}
	body->appendChild(doc.createTextNode(this->credit));

	return body;

}
Example #22
0
void serializer::create_node(DOMElement * parent, EObject_ptr parent_obj,
        EObject_ptr child_obj, EStructuralFeature_ptr ef)
{
    DOMElement * child = m_doc->createElement(W(ef->getName()));
    EClass_ptr child_cl = child_obj->eClass();

    // May be a subtype
    if (child_cl != ef->getEType())
        child->setAttribute(X("xsi:type"), W(get_type(child_obj)));

    parent->appendChild(child);

    serialize_node(child, child_obj);
}
Example #23
0
DOMElement* Serializer::ToString(const std::string& value, const char* name, XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* doc)
{
   // make the element
   XMLCh* NAME = XMLString::transcode(name);
   DOMElement* element = doc->createElement(NAME);
   XMLString::release(&NAME);

   // make the attribute
   XMLCh* TYPE_STRING = XMLString::transcode("string");
   XMLCh* VALUE = XMLString::transcode(dtUtil::ToString<std::string>(value).c_str());
   element->setAttribute(TYPE_STRING, VALUE);
   XMLString::release(&VALUE);
   XMLString::release(&TYPE_STRING);

   return element;
}
DOMElement* EppChangePollOperation::toXML( DOMDocument& doc, const DOMString& tag )
{
	DOMElement* elm = null;

	if ( this->operation.isNotNull() )
	{
		elm = doc.createElement(tag);
		elm->appendChild(doc.createTextNode(this->operation));

		if ( this->subOperation.isNotNull() )
		{
			elm->setAttribute(XS("op"), this->subOperation);
		}
	}

	return elm;
}
Example #25
0
void Triggerconf::setConfigAttributeValue (string module, string submodule, string configname, string attributename, string value)
{
	DOMNode* currentConfigElement = selectConfigElement (module, submodule, configname);
	if (currentConfigElement == NULL) return;

	assert (currentConfigElement->getNodeType () == DOMNode::ELEMENT_NODE);
	DOMElement* elem = (DOMElement*) currentConfigElement;

	XMLCh* xattrname	= XMLString::transcode (attributename.c_str ());
	XMLCh* xval		= XMLString::transcode (value.c_str ());

	elem->setAttribute (xattrname, xval);

	XMLString::release (&xattrname);
	XMLString::release (&xval);

	resetError ();
}
Example #26
0
/*=========================================================================+
	Add_Element:
		Add a "<tag> value </tag>" element to an XML block.  If the
		optional tag attribute and value are provided, then the element
		will look like "<tag attribute=value> value </tag>" instead.

+=========================================================================*/
int
ExitXMLBlock::Add_Element(
			DOMDocument*	pDocument,
			DOMElement*		pParentElement,
			string			sTag,
			string			sValue,
			string			sTagAttribute,		//		= "",
			string			sTagAttributeValue	//		= ""
	)
{
	DOMElement*			pElement	= NULL;
	STATUS_T			tStatus		= E_SUCCESS;
	XMLCh*				pxcValue	= NULL;
	int					iRc			= -1;		// FailureS
	
	// Create element.
	if (pDocument && pParentElement && !sTag.empty() && !sValue.empty()) {
		pxcValue = UTF8toUTF16(sTag);
		DOMElement* pChild = pDocument->createElement(pxcValue);
		delete pxcValue;

		pxcValue = UTF8toUTF16(sValue);
		DOMText* pText = pDocument->createTextNode(pxcValue);
		delete pxcValue;

		pChild->appendChild(pText);

		// Add the tag attribute if specified.
		if (!sTagAttribute.empty() && !sTagAttributeValue.empty()) {
			XMLCh* pxcAttr	= UTF8toUTF16(sTagAttribute);
			XMLCh* pxcValue	= UTF8toUTF16(sTagAttributeValue);
			pChild->setAttribute(pxcAttr, pxcValue);
			delete pxcAttr;
			delete pxcValue;
		}

		pParentElement->appendChild(pChild);
		iRc = 0;
	} 
	return iRc;
}
Example #27
0
void Triggerconf::createConfigAttribute	(string module, string submodule, string configname, string attributename)
{
	//
	// attributes are always created, no matter if they exists or not
	// dublication is prevented by xercesc
	//

	DOMNode* currentConfigElement = selectConfigElement (module, submodule, configname);
	if (currentConfigElement == NULL) return;
	
	assert (currentConfigElement->getNodeType () == DOMNode::ELEMENT_NODE);
	DOMElement* elem = (DOMElement*) currentConfigElement;

	XMLCh* xattrname	= XMLString::transcode (attributename.c_str ());
	XMLCh* xempty		= XMLString::transcode ("");
	elem->setAttribute	(xattrname, xempty);
	XMLString::release	(&xattrname);
	XMLString::release	(&xempty);

	resetError ();
}
Example #28
0
void SNote::align( PNote *note, bool correct ){

    DOMNodeList *list = m_element->getElementsByTagName(XS("align"));
    DOMElement *align;

    if( list->getLength() == 0 ){
        DOMDocument *doc = m_element->getOwnerDocument();
        align = doc->createElement(XS("align"));
        m_element->appendChild(align);
    }
    else{
        align = (DOMElement*)list->item(0);
    }


    align->setAttribute( XS("note"), XS(note->getID().c_str()) );
		       
    if( correct )
        setText( align, "correct" );
    else
        setText( align, "wrong" );
}
Example #29
0
void Triggerconf::createModule (string module)
{
	if (rootnode == NULL) return;
	
	if (existsModule (module)) {
		resetError ();	
		return;
	}

	XMLCh* xmodulename	= XMLString::transcode (ELEMENT_MODULE_NAME);
	DOMElement* node	= rootnode->getOwnerDocument ()->createElement	(xmodulename);
	XMLString::release	(&xmodulename);

	XMLCh* xattrname	= XMLString::transcode (ATTRIBUTE_NAME);
	XMLCh* xmodule		= XMLString::transcode (module.c_str ());
	node->setAttribute	(xattrname, xmodule);

	XMLString::release	(&xattrname);
	XMLString::release	(&xmodule);

	rootnode->appendChild (node);

	resetError ();
}
Example #30
0
DOMElement* EppUtil::createElementNS( DOMDocument& doc, const DOMString ns, const DOMString tag, bool flag , char *_version)
{
	DOMElement* elm;
	DOMString prefix(EPP_NAME_SPACE);
	char *use_version = version;

	if( NULL != _version ) /*param provided*/
		use_version = _version;

	if( tag.isNull() )
	{
		elm = doc.createElementNS(prefix + ns + use_version , ns);
		elm->setAttribute(XS("xmlns"), XS(EPP_NAME_SPACE) + ns + use_version );
		if( use_version[0] == 0 )
		{
			// old EPP-02 schema
			elm->setAttribute(XS("xmlns:xsi"), XS("http://www.w3.org/2000/10/XMLSchema-instance"));
		}
		else
		{
			elm->setAttribute(XS("xmlns:xsi"), XS("http://www.w3.org/2001/XMLSchema-instance"));
		}
	}
	else
	{
		elm = doc.createElementNS(prefix + ns + use_version, tag);
		elm->setPrefix(ns);
		if( flag )
		{
			elm->setAttribute(XS("xmlns"), prefix + ns + use_version);
		}
		elm->setAttribute(XS("xmlns:") + ns, prefix + ns + use_version);
	}
	elm->setAttribute(XS("xsi:schemaLocation"), prefix + ns + use_version + " " + ns + use_version + ".xsd");

	return elm;
}