DOMElement* EppCommandTransferDomain::toXML( DOMDocument& doc, const DOMString& tag )
{
	DOMElement* body = toXMLPoll(doc, tag);

	DOMAttr* attr = doc.createAttribute(XS("op"));
	attr->setValue(this->getOperation());
	ValueVectorOf<DOMAttr*> attrList(1);
	attrList.addElement(attr);

	return toXMLCommon(doc, tag, body, &attrList);
}
DOMXPathResult* DOMXPathExpressionImpl::evaluate(const DOMNode *contextNode,
                                                 DOMXPathResult::ResultType type,
                                                 DOMXPathResult* result) const
{
    if(type!=DOMXPathResult::FIRST_ORDERED_NODE_TYPE && type!=DOMXPathResult::ORDERED_NODE_SNAPSHOT_TYPE &&
       type!=DOMXPathResult::ANY_UNORDERED_NODE_TYPE && type!=DOMXPathResult::UNORDERED_NODE_SNAPSHOT_TYPE)
        throw DOMXPathException(DOMXPathException::TYPE_ERR, 0, fMemoryManager);

    if(contextNode==NULL || contextNode->getNodeType()!=DOMNode::ELEMENT_NODE)
        throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0, fMemoryManager);

    JanitorMemFunCall<DOMXPathResultImpl> r_cleanup (
      0, &DOMXPathResultImpl::release);
    DOMXPathResultImpl* r=(DOMXPathResultImpl*)result;
    if(r==NULL)
    {
      r=new (fMemoryManager) DOMXPathResultImpl(type, fMemoryManager);
      r_cleanup.reset (r);
    }
    else
        r->reset(type);

    XPathMatcher matcher(fParsedExpression, fMemoryManager);
    matcher.startDocumentFragment();

    if(fMoveToRoot)
    {
        contextNode=contextNode->getOwnerDocument();
        if(contextNode==NULL)
            throw DOMException(DOMException::NOT_SUPPORTED_ERR, 0, fMemoryManager);

        QName qName(contextNode->getNodeName(), 0, fMemoryManager);
        SchemaElementDecl elemDecl(&qName);
        RefVectorOf<XMLAttr> attrList(0, true, fMemoryManager);
        matcher.startElement(elemDecl, 0, XMLUni::fgZeroLenString, attrList, 0);
        DOMNode* child=contextNode->getFirstChild();
        while(child)
        {
            if(child->getNodeType()==DOMNode::ELEMENT_NODE)
                testNode(&matcher, r, (DOMElement*)child);
            child=child->getNextSibling();
        }
        matcher.endElement(elemDecl, XMLUni::fgZeroLenString);
    }
    else
        testNode(&matcher, r, (DOMElement*)contextNode);

    r_cleanup.release ();
    return r;
}
bool DOMXPathExpressionImpl::testNode(XPathMatcher* matcher, DOMXPathResultImpl* result, DOMElement *node) const
{
    int uriId=fStringPool->addOrFind(node->getNamespaceURI());
    QName qName(node->getNodeName(), uriId, fMemoryManager);
    SchemaElementDecl elemDecl(&qName);
    DOMNamedNodeMap* attrMap=node->getAttributes();
    XMLSize_t attrCount = attrMap->getLength();
    RefVectorOf<XMLAttr> attrList(attrCount, true, fMemoryManager);
    for(XMLSize_t i=0;i<attrCount;i++)
    {
        DOMAttr* attr=(DOMAttr*)attrMap->item(i);
        attrList.addElement(new (fMemoryManager) XMLAttr(fStringPool->addOrFind(attr->getNamespaceURI()),
                                                         attr->getNodeName(),
                                                         attr->getNodeValue(),
                                                         XMLAttDef::CData,
                                                         attr->getSpecified(),
                                                         fMemoryManager,
                                                         NULL,
                                                         true));
    }
    matcher->startElement(elemDecl, uriId, node->getPrefix(), attrList, attrCount);
    unsigned char nMatch=matcher->isMatched();
    if(nMatch!=0 && nMatch!=XPathMatcher::XP_MATCHED_DP)
    {
        result->addResult(node);
        if(result->getResultType()==DOMXPathResult::ANY_UNORDERED_NODE_TYPE || result->getResultType()==DOMXPathResult::FIRST_ORDERED_NODE_TYPE)
            return true;    // abort navigation, we found one result
    }

    if(nMatch==0 || nMatch==XPathMatcher::XP_MATCHED_D || nMatch==XPathMatcher::XP_MATCHED_DP)
    {
        DOMNode* child=node->getFirstChild();
        while(child)
        {
            if(child->getNodeType()==DOMNode::ELEMENT_NODE)
                if(testNode(matcher, result, (DOMElement*)child))
                    return true;
            child=child->getNextSibling();
        }
    }
    matcher->endElement(elemDecl, XMLUni::fgZeroLenString);
    return false;
}
t_rc SSQLM_DDL_Manager::CreateTable(char * t_Name, char * attrNames) {
	
	t_rc rc;
	size_t foundComma, foundParenthesis, stringLength, nameEndsAt;
	int attributeAsStringLength;

	std::string attrList(attrNames);
	t_attrType attrTypeAsStruct;	//attributes type
	int attrSize=0;					//atributes size
	int recordSize=0;				//records total size
	int numOfAttributes=0;			//the number of attributes
	
	//handle the attributes list and extract metadata.
	do{
		foundComma = attrList.find(" , ");
		
		numOfAttributes++;

		char attributeAsChar[ATTR_NAME_SIZE];
		if (foundComma != string::npos){	//get the arguments
			stringLength = attrList.copy(attributeAsChar, foundComma, 0);
		}else{		//handle the last attr that is not followed by ","
			stringLength = attrList.copy(attributeAsChar, attrList.length(), 0);
		}
		attributeAsChar[stringLength] = '\0';
		std::string attributeAsString(attributeAsChar);
		attributeAsStringLength = attributeAsString.length();
			
		nameEndsAt = attributeAsString.find(" ");
		if (nameEndsAt != string::npos){
			char attrName[50], attrType[15];
			stringLength = attributeAsString.copy(attrName, nameEndsAt, 0);
			attrName[stringLength] = '\0';

			stringLength = attributeAsString.copy(attrType, attrList.length(), nameEndsAt+1);
			attrType[stringLength] = '\0';

			//check the kind of type and calculate size
			rc = checkAttrType(attrType, &attrTypeAsStruct, &attrSize);
			if (rc != OK) return rc;

			//add entry to attr.met
			rc = this->smm->InsertAttributeMetadata(t_Name, attrName,recordSize,attrTypeAsStruct,attrSize,-1);
			if (rc != OK) return SSQLM_DML_FAIL_TO_INSERT_RECORD_ATTR_MET;

			//add to total record size
			recordSize+=attrSize;

		} else {
			return SSQLM_DDL_ATTR_IN_WRONG_FORMAT;
		}
		attrList.replace(0, attributeAsStringLength+3, "");		//+2 in order to erase ", "
	}while(attrList.compare("") != 0);

	//add new entry at rel.met
	rc = this->smm->InsertRelationMetadata(t_Name,recordSize,numOfAttributes,0);
	if (rc != OK) return SSQLM_DML_FAIL_TO_INSERT_RECORD_REL_MET;
	
	std::string t_path = this->path + t_Name;
	rc = this->rfm->CreateRecordFile(t_path.c_str(), recordSize);
	if (rc != OK) return rc;

	return (OK);
}