Ejemplo n.º 1
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;
}
bool CConfigParser::ParseGesture(DOMNode* node, TActionByNameMap actions, CDeviceContext* device)
{
	TGestureList gestures;
	wstring actionName = node->getAttributes()->getNamedItem(L"action")->getNodeValue();
	unsigned long length = node->getChildNodes()->getLength();
	for(unsigned long i = 0; i < length; i++)
	{
		DOMNode* gestNode = node->getChildNodes()->item(i);
		wstring nodeType = gestNode->getNodeName();
		if(nodeType.compare(L"#text") == 0)
			continue;
		if(nodeType.compare(L"motion") == 0)
		{
			wstring position = gestNode->getAttributes()->getNamedItem(L"position")->getNodeValue();
			wstring axe = gestNode->getAttributes()->getNamedItem(L"axe")->getNodeValue();
			EGesturePosition pos;
			if(position.compare(L"positive") == 0)
				pos = EGesturePosition::POSITIVE;
			if(position.compare(L"negative") == 0)
				pos = EGesturePosition::NEGATIVE;
			if(position.compare(L"center") == 0)
				pos = EGesturePosition::CENTER;
			gestures.push_back(new CMotion(pos, _wtoi(axe.c_str())));
		}
		if(nodeType.compare(L"wait") == 0)
			gestures.push_back(new CTimeFrame(_wtoi(gestNode->getAttributes()->getNamedItem(L"length")->getNodeValue())));
	}
	device->_gestureProcessor.addMacro(gestures, actions[actionName]);
	return true;
}
bool CConfigParser::ParseContexts(DOMNodeList* contextNodes, ADeviceListener& configClass)
{
	ASSERT(contextNodes->getLength() == 1);
	DOMNode* contextNode = contextNodes->item(0);
	DOMNodeList* contexts = contextNode->getChildNodes();
	for(unsigned long idx = 0; idx < contexts->getLength(); idx++)
	{
		DOMNode* currentContext = contexts->item(idx);
		wstring contextNodeName = currentContext->getNodeName();
		if(contextNodeName.compare(L"#text") == 0)
			continue;
		wstring contextName = currentContext->getAttributes()->getNamedItem(L"name")->getNodeValue();
		CContext* contextToAdd = new CContext();
		unsigned long attrLen = currentContext->getAttributes()->getLength();
		for(unsigned long attr = 0; attr < attrLen; attr++)
		{
			DOMNode* deviceContextAttr = currentContext->getAttributes()->item(attr);
			if(wcscmp(deviceContextAttr->getNodeName(), L"deviceContext") == 0)
			{
				wstring deviceContextName = deviceContextAttr->getNodeValue();
				CDeviceContext* deviceContext = configClass.GetDeviceContexts()[deviceContextName];
				IDeviceCapture* device = configClass.GetDevices()[deviceContext->GetDeviceName()];
				contextToAdd->AddDeviceContext(device, deviceContext);
			}
		}
		configClass.AddContext(contextName, contextToAdd);
	}
	return true;
}
bool CConfigParser::ParseHIDDeviceCommands(DOMNodeList* commandNodeList, CWin32SpaceNavigatorHIDCapture* device)
{
	if(commandNodeList == NULL)
		return true;

	for(unsigned long idx = 0; idx < commandNodeList->getLength(); idx++)
	{
		DOMNode* currentCommand = commandNodeList->item(idx);
		wstring commandNodeName = currentCommand->getNodeName();
		if(commandNodeName.compare(L"command") != 0)
			continue;
		wstring commandName = currentCommand->getAttributes()->getNamedItem(L"name")->getNodeValue();
		wstring commandReport = currentCommand->getAttributes()->getNamedItem(L"report")->getNodeValue();
		wstring commandValue = currentCommand->getAttributes()->getNamedItem(L"value")->getNodeValue();

		unsigned int report = NULL;
		unsigned int value = NULL;
		
		swscanf(commandReport.c_str(), L"0x%04X", &report);
		swscanf(commandValue.c_str(), L"0x%04X", &value);

		device->AddCommand(commandName, report, value);
	}
	return true;
}
bool CConfigParser::ParseDeviceContexts(DOMNodeList* deviceContextNodes, ADeviceListener& configClass)
{
	ASSERT(deviceContextNodes->getLength() == 1);
	DOMNode* deviceContextNode = deviceContextNodes->item(0);
	DOMNodeList* deviceContexts = deviceContextNode->getChildNodes();
	for(unsigned long idx = 0; idx < deviceContexts->getLength(); idx++)
	{
		DOMNode* currentDeviceContext = deviceContexts->item(idx);
		wstring deviceContextNodeName = currentDeviceContext->getNodeName();
		if(deviceContextNodeName.compare(L"#text") == 0)
			continue;
		if(deviceContextNodeName.compare(L"#comment") == 0)
			continue;
		wstring deviceContextName = currentDeviceContext->getAttributes()->getNamedItem(L"name")->getNodeValue();
		wstring deviceName = currentDeviceContext->getAttributes()->getNamedItem(L"device")->getNodeValue();
		bool gestures = false;
		if(currentDeviceContext->getAttributes()->getNamedItem(L"gestures") != NULL)
			gestures = true;
		// Create the device context to add
		CDeviceContext* deviceContextToAdd = NULL;
		if(configClass.GetDevices()[deviceName]->GetType().compare("mouse") == 0)
			deviceContextToAdd = new CMouseDeviceContext(gestures, deviceName);
		else
			deviceContextToAdd = new CDeviceContext(gestures, deviceName);

		// Get the device contexts axis and buttons added
		if(currentDeviceContext->hasChildNodes())
		{
			unsigned char axeIdx = 0;
			DOMNodeList* children = currentDeviceContext->getChildNodes();
			unsigned long childCount = children->getLength();
			for(unsigned long idx = 0; idx < childCount; idx++)
			{
				DOMNode* childNode = children->item(idx);			
				wstring nodeName = childNode->getNodeName();

				if(nodeName.compare(L"axe") == 0)
				{
					ParseAxe(childNode, configClass.GetActions(), deviceContextToAdd, axeIdx);
					axeIdx++;
				}
				if(nodeName.compare(L"buttons") == 0)
					ParseButtons(childNode, configClass.GetActions(), deviceContextToAdd);
				if(nodeName.compare(L"gesture") == 0)
					ParseGesture(childNode, configClass.GetActions(), deviceContextToAdd);
			}
		}
		configClass.AddDeviceContext(deviceContextName, deviceContextToAdd);
		TRACE("Device Context <%S> is 0x%X\r\n", deviceContextName.c_str(), deviceContextToAdd);
	}
	return true;
}
static MSPInstance extractMSPInstance(DOMDocument * domDocument, DOMTreeWalker * domTreeWalker) {
    MSPInstance mspInstance;
    map<string, ParameterGroup> parameterGroupMap;

    DOMNode * node = domTreeWalker->getCurrentNode();
    DOMNamedNodeMap * nodeMap = node->getAttributes();

    DOMNode * nameAttribute = nodeMap->getNamedItem(XMLString::transcode("name"));
    if (nameAttribute) {
        mspInstance.setName(XMLString::transcode(nameAttribute->getNodeValue()));
    }

    DOMNode * typeNameAttribute = nodeMap->getNamedItem(XMLString::transcode("typename"));

    if (typeNameAttribute) {
        //TFDEBUG(XMLString::transcode(typeNameAttribute->getNodeValue()));
        mspInstance.setTypeName(XMLString::transcode(typeNameAttribute->getNodeValue()));
    }

    while (node) {
        if (XMLString::compareString(XMLString::transcode(node->getNodeName()), "ParameterGroup") == 0) {
            DOMNamedNodeMap * nodeMap = node->getAttributes();
            string name;
            DOMNode * nameAttribute = nodeMap->getNamedItem(XMLString::transcode("name"));
            if (nameAttribute) {
               name = XMLString::transcode(nameAttribute->getNodeValue());
            }

            XMLNodeFilter * nodeFilter = new XMLNodeFilter();
            DOMTreeWalker * d = domDocument->createTreeWalker(node, DOMNodeFilter::SHOW_ALL, nodeFilter, true);
            ParameterGroup pg = extractParameterGroup(domDocument, d);
            pg.setName(name);
            parameterGroupMap[name] = pg;
            d->release();
            delete nodeFilter;
        } else if (XMLString::compareString(XMLString::transcode(node->getNodeName()), "Description") == 0) {
            XMLCh * textContent = XMLString::replicate(node->getTextContent());
            XMLString::trim(textContent);
            mspInstance.setDescription(XMLString::transcode(textContent));
            XMLString::release(&textContent);
        }
        node = domTreeWalker->nextNode();
    }

    ParameterGroup parameterGroup;
    parameterGroup.setName("root");
    parameterGroup.setParameterGroupMap(parameterGroupMap);
    mspInstance.setParameterGroup(parameterGroup);

    return mspInstance;
}
static ParameterGroup extractParameterGroup(DOMDocument * domDocument, DOMTreeWalker * domTreeWalker) {

    map<string, string> parameterMap;
    map<string, ParameterGroup> parameterGroupMap;

    DOMNode * node = domTreeWalker->nextNode();
    while (node) {
        if (XMLString::compareString(XMLString::transcode(node->getNodeName()), "Parameter") == 0) {
            DOMNamedNodeMap * nodeMap = node->getAttributes();

            string name;
            DOMNode * nameAttribute = nodeMap->getNamedItem(XMLString::transcode("name"));
            if (nameAttribute) {
                name = XMLString::transcode(nameAttribute->getNodeValue());
            }
            string value;
            DOMNode * valueAttribute = nodeMap->getNamedItem(XMLString::transcode("value"));
            if (valueAttribute) {
                value = XMLString::transcode(valueAttribute->getNodeValue());
            }
            parameterMap[name] = value;

            //TFINFO("Parameter: " << name << " -> " << value);
        } else if (XMLString::compareString(XMLString::transcode(node->getNodeName()), "ParameterGroup") == 0) {

            DOMNamedNodeMap * nodeMap = node->getAttributes();
            string name;
            DOMNode * nameAttribute = nodeMap->getNamedItem(XMLString::transcode("name"));
            if (nameAttribute) {
                name = XMLString::transcode(nameAttribute->getNodeValue());
            }

            XMLNodeFilter * nodeFilter = new XMLNodeFilter();
            DOMTreeWalker * d = domDocument->createTreeWalker(node, DOMNodeFilter::SHOW_ALL, nodeFilter, true);
            ParameterGroup pg = extractParameterGroup(domDocument, d);
            pg.setName(name);
            parameterGroupMap[name] = pg;
            d->release();
            delete nodeFilter;
        }
        node = domTreeWalker->nextNode();
    }

    ParameterGroup parameterGroup;
    parameterGroup.setParameterMap(parameterMap);
    parameterGroup.setParameterGroupMap(parameterGroupMap);

    return parameterGroup;
}
bool CConfigParser::ParseDevices(DOMNodeList* deviceNodeList, ADeviceListener& configClass)
{
	ASSERT(deviceNodeList->getLength() >= 1);
	DOMNode* deviceNode = deviceNodeList->item(0);
	DOMNodeList* devices = deviceNode->getChildNodes();
	for(unsigned long idx = 0; idx < devices->getLength(); idx++)
	{
		DOMNode* currentDevice = devices->item(idx);
		wstring deviceNodeName = currentDevice->getNodeName();
		if(deviceNodeName.compare(L"#text") == 0)
			continue;
		wstring deviceName = currentDevice->getAttributes()->getNamedItem(L"name")->getNodeValue();
		//wstring deviceType = currentDevice->getAttributes()->getNamedItem(L"type")->getNodeValue();
		wstring deviceType = deviceNodeName;
		if(deviceType.compare(L"mouse") == 0)
		{
			configClass.AddDevice(deviceName, new CMouseProc());
		}
		else
		{
			CWin32SpaceNavigatorHIDCapture* deviceToAdd = new CWin32SpaceNavigatorHIDCapture();
			if(currentDevice->hasChildNodes())
			{
				if(!ParseHIDDeviceCommands(currentDevice->getChildNodes(), deviceToAdd))
					return false;
			}
			configClass.AddDevice(deviceName, deviceToAdd);
		}
	}
	return true;
}
static TUIObjectInstance extractTUIObjectInstance(DOMDocument * domDocument, DOMTreeWalker * domTreeWalker) {

    TUIObjectInstance tuiObjectInstance;
    DOMNode * node = domTreeWalker->getCurrentNode();
    DOMNamedNodeMap * nodeMap = node->getAttributes();

    DOMNode * nameAttribute = nodeMap->getNamedItem(XMLString::transcode("name"));
    if (nameAttribute) {
        tuiObjectInstance.setName(XMLString::transcode(nameAttribute->getNodeValue()));
    }

    DOMNode * tuiTypeNameAttribute = nodeMap->getNamedItem(XMLString::transcode("typename"));
    if (tuiTypeNameAttribute) {
        tuiObjectInstance.setTypeName(XMLString::transcode(tuiTypeNameAttribute->getNodeValue()));
    }

    while (node) {
        if (XMLString::compareString(XMLString::transcode(node->getNodeName()), "Description") == 0) {
            XMLCh * textContent = XMLString::replicate(node->getTextContent());
            XMLString::trim(textContent);
            tuiObjectInstance.setDescription(XMLString::transcode(textContent));
            XMLString::release(&textContent);
        }
        node = domTreeWalker->nextNode();
    }

    return tuiObjectInstance;
}
Ejemplo n.º 10
0
static TUIObjectType extractTUIObjectType(DOMDocument * domDocument, DOMTreeWalker * domTreeWalker) {
    TUIObjectType tuiObjectType;
    DOMNode * node = domTreeWalker->getCurrentNode();
    DOMNamedNodeMap * nodeMap = node->getAttributes();
    DOMNode * nameAttribute = nodeMap->getNamedItem(XMLString::transcode("name"));
    if (nameAttribute) {
        tuiObjectType.setName(XMLString::transcode(nameAttribute->getNodeValue()));
    }

    while (node) {
        if (XMLString::compareString(XMLString::transcode(node->getNodeName()), "PortTypeSequence") == 0) {
            XMLNodeFilter * nodeFilter = new XMLNodeFilter();
            DOMTreeWalker * d = domDocument->createTreeWalker(node, DOMNodeFilter::SHOW_ALL, nodeFilter, true);
            tuiObjectType.setPortMap(extractPortMap(domDocument, d));
            d->release();
            delete nodeFilter;
        } else if (XMLString::compareString(XMLString::transcode(node->getNodeName()), "Description") == 0) {
            XMLCh * textContent = XMLString::replicate(node->getTextContent());
            XMLString::trim(textContent);
            tuiObjectType.setDescription(XMLString::transcode(textContent));
            XMLString::release(&textContent);
        }
        node = domTreeWalker->nextNode();
    }
    return tuiObjectType;
}
Ejemplo n.º 11
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();
}
Ejemplo n.º 12
0
std::string DeltaApplyEngine::getDestinationURI(XID_DOMDocument *IncDeltaDoc) {
	DOMNode* deltaElement = DeltaApplyEngine::getDeltaElement(IncDeltaDoc);
	DOMNode* toItem = deltaElement->getAttributes()->getNamedItem(XMLString::transcode("to"));
	if (toItem==NULL) THROW_AWAY(("attribute 'to' not found"));
	
        return std::string(XyLatinStr(toItem->getNodeValue()));
	}
Ejemplo n.º 13
0
set<string>* EpiMCMCConfig::getParameterNames()
{
  /** Returns a pointer to an STL set of parameter names.
  Throws a ConfigException if duplicate names are found in the DOM **/
  
  XMLCh* buff;  // Character buffer.  Used to delete objects mainly.
  
  buff = XMLString::transcode("parameter");
  DOMNodeList* parmList = doc->getElementsByTagName(buff);
  XMLString::release(&buff);
  
  set<string>* parmNames = new set<string>;
  pair<set<string>::iterator,bool> isInserted;
  
  for(size_t i = 0; i<parmList->getLength(); ++i) {
    DOMNode* parm = parmList->item(i);
    
    buff = XMLString::transcode("id");
    DOMNode* idAttr = parm->getAttributes()->getNamedItem(buff);
    XMLString::release(&buff);
    
    char* id = XMLString::transcode(idAttr->getNodeValue()) ;
    isInserted = parmNames->insert(id);
    if(isInserted.second == false) {
      string msg("Duplicate string inserted: ");
      msg += id;
      XMLString::release(&id);
      throw ConfigException(msg.c_str());
    }
    XMLString::release(&id);
  }
  
  return parmNames;
  
}
Ejemplo n.º 14
0
static DeviceInstance extractDeviceInstance(DOMDocument * domDocument, DOMTreeWalker * domTreeWalker) {
    DeviceInstance deviceInstance;
    map<string, ParameterGroup> parameterGroupMap;

    DOMNode * node = domTreeWalker->getCurrentNode();
    DOMNamedNodeMap * nodeMap = node->getAttributes();

    DOMNode * nameAttribute = nodeMap->getNamedItem(XMLString::transcode("name"));
    if (nameAttribute) {
        deviceInstance.setName(XMLString::transcode(nameAttribute->getNodeValue()));
    }

    DOMNode * typenameAttribute = nodeMap->getNamedItem(XMLString::transcode("typename"));
    if (typenameAttribute) {
        deviceInstance.setDeviceTypeName(XMLString::transcode(typenameAttribute->getNodeValue()));
    }

    while (node) {
        if (XMLString::compareString(XMLString::transcode(node->getNodeName()), "ParameterGroup") == 0) {
            DOMNamedNodeMap * nodeMap = node->getAttributes();
            string name;
            DOMNode * nameAttribute = nodeMap->getNamedItem(XMLString::transcode("name"));
            if (nameAttribute) {
               name = XMLString::transcode(nameAttribute->getNodeValue());
            }

            XMLNodeFilter * nodeFilter = new XMLNodeFilter();
            DOMTreeWalker * d = domDocument->createTreeWalker(node, DOMNodeFilter::SHOW_ALL, nodeFilter, true);

            ParameterGroup pg = extractParameterGroup(domDocument, d);
            pg.setName(name);
            parameterGroupMap[name] = pg;

            d->release();
            delete nodeFilter;
        }
        node = domTreeWalker->nextNode();
    }

    ParameterGroup parameterGroup;
    parameterGroup.setName("root");
    parameterGroup.setParameterGroupMap(parameterGroupMap);
    deviceInstance.setParameterGroup(parameterGroup);

    return deviceInstance;
}
Ejemplo n.º 15
0
void AcsAlarmTestCase::verifyFaultStateElement(DOMDocument * doc, bool propertiesAndTimestampPopulated)
{
	// Verify that the fault-state element exists
	DOMNodeList * faultStateNodes = doc->getElementsByTagName(FAULT_STATE_TAG_NAME);
	CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; no fault-state element found",
		(NULL != faultStateNodes && faultStateNodes->getLength() == 1));

	// verify that there are the expected attributes (family, member, code) on the fault-state element
	DOMNode * faultStateItem = faultStateNodes->item(0);
	if(NULL != faultStateItem)
	{
		// verify that there are 3 attributes in total
		DOMNamedNodeMap * attributesMap = faultStateItem->getAttributes();
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; fault-state does not contain 3 attributes",
			(NULL!= attributesMap && attributesMap->getLength() == 3));

		// check that the fault-state element has a "family" attribute
		DOMNode * familyNode = attributesMap->getNamedItem(FAMILY_TAG_NAME);
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; fault-state does not contain 'family' attribute",
			(NULL!= familyNode));

		// verify that the value of family attribute is correct
		const XMLCh * familyNodeValue = familyNode->getNodeValue();
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; value of fault-state 'family' is not correct",
			(NULL != familyNodeValue && XMLString::equals(familyNodeValue, FAMILY_VALUE_XMLCH)));

		// check that the fault-state element has a "member" attribute
		DOMNode * memberNode = attributesMap->getNamedItem(MEMBER_TAG_NAME);
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; fault-state does not contain 'member' attribute",
			(NULL!= memberNode));

		// verify that the value of member attribute is correct
		const XMLCh * memberNodeValue = memberNode->getNodeValue();
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; value of fault-state 'member' is not correct",
			(NULL != memberNodeValue && XMLString::equals(memberNodeValue, MEMBER_VALUE_XMLCH)));

		// check that the fault-state element has a "code" attribute
		DOMNode * codeNode = attributesMap->getNamedItem(CODE_TAG_NAME);
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; fault-state does not contain 'code' attribute",
			(NULL!= codeNode));

		// verify that the value of code attribute is correct
		const XMLCh * codeNodeValue = codeNode->getNodeValue();
		char *codeNodeCharValue = XMLString::transcode(codeNodeValue);
		int codeNodeValueInt = atoi(codeNodeCharValue);
		XMLString::release(&codeNodeCharValue);
		CPPUNIT_ASSERT_MESSAGE("FaultState::toXML appears to be broken; value of fault-state 'code' is not correct",
			(NULL != codeNodeValue && codeNodeValueInt == CODE_VALUE));
	}

	verifyDescriptorElement(doc);
	if(propertiesAndTimestampPopulated)
	{
		verifyUserPropertiesElement(doc);
		verifyUserTimestampElement(doc);
	}
}
Ejemplo n.º 16
0
set<StringTable::countryCode>
XMLIndata::parseCountryList(const DOMNode* cntrListTopNode){
   set<StringTable::countryCode> countryList;
   mc2dbg << "Parsing country list" << endl;


   const XMLCh* name = cntrListTopNode->getNodeName();
   if ( ! WFXMLStr::equals(name, "country_list") ){
      mc2log << error << "Strange country list element name: " << name 
             << endl;
      MC2_ASSERT(false);
   }

   const DOMNodeList* countryNodes = cntrListTopNode->getChildNodes();
   for (XMLSize_t i=0; i<countryNodes->getLength(); i++){
      DOMNode* countryNode = countryNodes->item(i);
      DOMNode::NodeType nodeType = 
         static_cast<DOMNode::NodeType>(countryNode->getNodeType());
      const XMLCh* name = countryNode->getNodeName();
      if ( nodeType == DOMNode::ELEMENT_NODE ){
         if ( WFXMLStr::equals(name,"country") ){
            DOMNamedNodeMap* attributes = countryNode->getAttributes();
            DOMNode* attribute = 
               attributes->getNamedItem( X( "id_string" ) );
            MC2_ASSERT( attribute != NULL );
            MC2String gmsName = 
               XMLString::transcode( attribute->getNodeValue() );
            StringTable::countryCode countryCode = 
               MapGenUtil::getCountryCodeFromGmsName( gmsName );
            mc2dbg << "   Country: " << gmsName << " " 
                   << countryCode << endl;
            if ( countryCode == StringTable::NBR_COUNTRY_CODES ){
               mc2log << error << "Strange GMS name: " 
                      << gmsName << endl;
               MC2_ASSERT(false);
            }
            countryList.insert(countryCode);
         }
         else {
            mc2log << error << "Strange element name: " << name << endl;
            MC2_ASSERT(false);
         }
      }
      else if ( nodeType == DOMNode::COMMENT_NODE ){
         // Don't bother with comments.
      }
      else {
         mc2log << error << "Strange node type: " << nodeType << endl;
         MC2_ASSERT(false);
      }
   }

   return countryList;
} // parseCountryList
Ejemplo n.º 17
0
void
OptionValueParser::parse_category(OptionCategory* category, DOMNode* node)
{
  DOMNodeList* children = node->getChildNodes();

  // Traverse the children
  for (size_t i = 0; i < children->getLength(); ++i)
  {
    DOMNode* item = children->item(i);
 
    if (item->getNodeType() != DOMNode::ELEMENT_NODE)
        continue;
 
    XMLUnicodeString node_name =
      item->getNodeName();

    DOMNamedNodeMap* attributes = item->getAttributes();
 
    XMLUnicodeString name =
      attributes->getNamedItem(XMLUnicodeString("name"))->getNodeValue();

    if (node_name.str() == std::string("OptionCategory"))
      {
        // Parsing a category node
        parse_category(category->category(name.str().c_str()), item);
      }
    else
      {
        // Parsing an option node
        Option* option = category->option(name.str().c_str());

        if (option && (node_name.str() == std::string("BooleanOption")))
          {
            parse_boolean_option((BooleanOption*) option, item);
          }
        else if (option && (node_name.str() == std::string("StringOption")))
          {
            parse_string_option((StringOption*) option, item);
          }
        else if (option && (node_name.str() == std::string("IntegerOption")))
          {
            parse_integer_option((IntegerOption*) option, item);
          }
        else if (option && (node_name.str() == std::string("EnumOption")))
          {
            parse_enum_option((EnumOption*) option, item);
          }
/*
        else
          throw UnknownOptionKind(name.str());
*/
      }
  }
}
Ejemplo n.º 18
0
XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *ParameterGrp::FindElement(XERCES_CPP_NAMESPACE_QUALIFIER DOMElement *Start, const char* Type, const char* Name) const
{
    for (DOMNode *clChild = Start->getFirstChild(); clChild != 0;  clChild = clChild->getNextSibling()) {
        if (clChild->getNodeType() == DOMNode::ELEMENT_NODE) {
            // the right node Type
            if (!strcmp(Type,StrX(clChild->getNodeName()).c_str())) {
                if (clChild->getAttributes()->getLength() > 0) {
                    if (Name) {
                        if (!strcmp(Name,StrX(clChild->getAttributes()->getNamedItem(XStr("Name").unicodeForm())->getNodeValue()).c_str()))
                            return (DOMElement*)clChild;
                    }
                    else
                        return (DOMElement*)clChild;

                }
            }
        }
    }
    return NULL;
}
Ejemplo n.º 19
0
// initially set up the default attribute information based on doctype information
void DOMElementImpl::setupDefaultAttributes()
{
    DOMDocument *tmpdoc = getOwnerDocument();
    if ((fNode.fOwnerNode == 0) || (tmpdoc == 0) || (tmpdoc->getDoctype() == 0))
        return;

    DOMNode *eldef = ((DOMDocumentTypeImpl*)tmpdoc->getDoctype())->getElements()->getNamedItem(getNodeName());
    DOMAttrMapImpl* defAttrs = (eldef == 0) ? 0 : (DOMAttrMapImpl *)(eldef->getAttributes());

    if (defAttrs)
        fDefaultAttributes = new (getOwnerDocument()) DOMAttrMapImpl(this, defAttrs);
}
Ejemplo n.º 20
0
const XMLCh* DOMNodeImpl::lookupNamespacePrefix(const XMLCh* const namespaceURI, bool useDefault, DOMElement *el) const {
    DOMNode *thisNode = castToNode(this);

    const XMLCh* ns = thisNode->getNamespaceURI();
    // REVISIT: if no prefix is available is it null or empty string, or
    //          could be both?
    const XMLCh* prefix = thisNode->getPrefix();

    if (ns != 0 && XMLString::equals(ns,namespaceURI)) {
        if (useDefault || prefix != 0) {
            const XMLCh* foundNamespace =  el->lookupNamespaceURI(prefix);
            if (foundNamespace != 0 && XMLString::equals(foundNamespace, namespaceURI)) {
                return prefix;
            }
        }
    }
    if (thisNode->hasAttributes()) {
        DOMNamedNodeMap *nodeMap = thisNode->getAttributes();

        if(nodeMap != 0) {
            int length = nodeMap->getLength();

            for (int i = 0;i < length;i++) {
                DOMNode *attr = nodeMap->item(i);
                const XMLCh* attrPrefix = attr->getPrefix();
                const XMLCh* value = attr->getNodeValue();

                ns = attr->getNamespaceURI();

                if (ns != 0 && XMLString::equals(ns, XMLUni::fgXMLNSURIName)) {
                    // DOM Level 2 nodes
                    if ((useDefault && XMLString::equals(attr->getNodeName(), XMLUni::fgXMLNSString)) ||
                        (attrPrefix != 0 && XMLString::equals(attrPrefix, XMLUni::fgXMLNSString)) &&
                        XMLString::equals(value, namespaceURI)) {
                        const XMLCh* localname= attr->getLocalName();
                        const XMLCh* foundNamespace = el->lookupNamespaceURI(localname);
                        if (foundNamespace != 0 && XMLString::equals(foundNamespace, namespaceURI)) {
                            return localname;
                        }
                    }
                }
            }
        }
    }
    DOMNode *ancestor = getElementAncestor(thisNode);
    if (ancestor != 0) {
        return castToNodeImpl(ancestor)->lookupNamespacePrefix(namespaceURI, useDefault, el);
    }
    return 0;
}
bool CConfigParser::ParseButtons(DOMNode* node, TActionByNameMap actions, CDeviceContext* device)
{
	if(node->hasChildNodes())
	{
		DOMNodeList* buttonNodes = node->getChildNodes();
		unsigned long length = buttonNodes->getLength();
		for(unsigned long idx = 0; idx < length; idx++)
		{
			DOMNode* buttonNode = buttonNodes->item(idx);
			wstring nodeName = buttonNode->getNodeName();
			if(buttonNode->hasAttributes())
			{
				DOMNode* mouseSim = buttonNode->getAttributes()->getNamedItem(L"simulateMouseButton");
				if(mouseSim != NULL)
				{
					wstring mouseSimBtn = mouseSim->getNodeValue();
					if(mouseSimBtn.compare(L"left") == 0)
						device->AddButton(new CLeftMouseButtonAction());
					if(mouseSimBtn.compare(L"right") == 0)
						device->AddButton(new CRightMouseButtonAction());
				}
				else
				{
					wstring downAction = buttonNode->getAttributes()->getNamedItem(L"downAction")->getNodeValue();
					wstring upAction = buttonNode->getAttributes()->getNamedItem(L"upAction")->getNodeValue();
					device->AddButton(new CActionButton(actions[downAction], actions[upAction]));
				}
			}
			else if (nodeName.compare(L"button") == 0)
			{
				device->AddButton((IButton*)NULL);
			}
		}
	}
	return false;
}
Ejemplo n.º 22
0
bool ConfigurationFileHandler::getSubAlgorithm(std::string algorithm, std::string subalgorithm, std::string* result){
#ifdef BRICS_XERCES_ENABLE
	if (errorsOccured) {
		return false;
	}

    DOMNode* current = NULL;
    DOMNode* attributeNode = NULL;
    XMLCh* algorithmName = XMLString::transcode(algorithm.c_str());
    XMLCh* subAlgorithmName = XMLString::transcode(subalgorithm.c_str());
    XMLCh* implementationString = XMLString::transcode("implementation");
    bool subAlgorithmFound = false;

    DOMDocument* doc = parser->getDocument();
    DOMNodeList* root = doc->getElementsByTagName(algorithmName);
    if (root->getLength() > 1) {
    	LOG(WARNING) << "More than one " << algorithm << " found, taking the first one";
    } else if(root->getLength() < 1) {
    	LOG(WARNING) << "No algorithm called " << algorithm << " found.";
		return false; //TODO release resouces
    }

    current = root->item(0);

    //search in children notes
	for (current = current->getFirstChild()->getNextSibling(); current!=NULL; current = current->getNextSibling()) {
		string nodeName = XMLString::transcode(current->getNodeName());
		if (nodeName.compare(subalgorithm) == 0) {
		    DOMNamedNodeMap* attributesList =  current->getAttributes();
		    attributeNode = attributesList->getNamedItem(implementationString);
		    if (attributeNode != 0) {
		    	*result = XMLString::transcode(attributeNode->getNodeValue());
		    	subAlgorithmFound = true;
		    	break; //take only first found
		    }
		}
	}

    XMLString::release(&algorithmName);
    XMLString::release(&subAlgorithmName);
    XMLString::release(&implementationString);

    return subAlgorithmFound;
#else
    return false;
#endif
}
Ejemplo n.º 23
0
static ServerStartupConfig extractServerStartupConfig(DOMDocument * domDocument, DOMTreeWalker * domTreeWalker) {
    ServerStartupConfig serverStartupConfig;
    DOMNode * node = domTreeWalker->getCurrentNode();
    while (node) {
        if (XMLString::compareString(XMLString::transcode(node->getNodeName()), "Network") == 0) {
            DOMNamedNodeMap * nodeMap = node->getAttributes();
            DOMNode * portAttribute = nodeMap->getNamedItem(XMLString::transcode("port"));
            if (portAttribute) {
                
                serverStartupConfig.setPortNr(XMLString::parseInt(portAttribute->getNodeValue()));
            }
        }
        node = domTreeWalker->nextNode();
    }

    return serverStartupConfig;
}
Ejemplo n.º 24
0
void DeltaApplyEngine::Attribute_Insert( XID_t nodeXID, const XMLCh* attr, const XMLCh* value ) {
	vddprintf(("        insert attr at xid=%d\n",(int)nodeXID));
	DOMNode* node = xiddoc->getXidMap().getNodeWithXID( nodeXID );
	if (node==NULL) THROW_AWAY(("node with XID=%d not found",(int)nodeXID));
	DOMAttr* attrNode = xiddoc->createAttribute( attr );
	attrNode->setNodeValue( value );
	DOMNamedNodeMap *attrs = node->getAttributes();
	if (attrs == NULL) {
		if (node->getNodeType() != DOMNode::ELEMENT_NODE) {
			THROW_AWAY(("Attempted to insert an attribute on a non-element node. Perhaps xidmap was corrupted?"));
		} else {
			THROW_AWAY(("Unexpected error encountered: getAttributes() returned NULL for element"));
		}
	} else {
		attrs->setNamedItem( attrNode );
	}
	
}
Ejemplo n.º 25
0
static PortAddress extractPortAddress(DOMDocument * domDocument, DOMTreeWalker * domTreeWalker) {
    PortAddress portAddress;

    DOMNode * node = domTreeWalker->getCurrentNode();
    DOMNamedNodeMap * nodeMap = node->getAttributes();

    // entityType = DEV | TUI | MSP
    DOMNode * entityTypeAttribute = nodeMap->getNamedItem(XMLString::transcode("entityType"));
    if (entityTypeAttribute) {
        if (XMLString::compareString(XMLString::transcode(entityTypeAttribute->getNodeValue()), "DEV") == 0) {
            //TFINFO("DEV");
            portAddress.setOwnerType(PortAddress::DEVICE);
        } else if (XMLString::compareString(XMLString::transcode(entityTypeAttribute->getNodeValue()), "TUI") == 0) {
            //TFINFO("TUI");
            portAddress.setOwnerType(PortAddress::TUIOBJECT);
        } else if (XMLString::compareString(XMLString::transcode(entityTypeAttribute->getNodeValue()), "MSP") == 0) {
            //TFINFO("MSP");
            portAddress.setOwnerType(PortAddress::MSP);
        } else {
            // TODO throw Exception
            TFERROR("");
        }
    } else {
        TFERROR("No entityType found")
    }

    DOMNode * entityNameAttribute = nodeMap->getNamedItem(XMLString::transcode("entityName"));
    if (entityNameAttribute) {
        portAddress.setName(XMLString::transcode(entityNameAttribute->getNodeValue()));
    } else {
        TFERROR("No entityName found")
    }
    DOMNode * portNameAttribute = nodeMap->getNamedItem(XMLString::transcode("portName"));
    if (portNameAttribute) {
        portAddress.setPortName(XMLString::transcode(portNameAttribute->getNodeValue()));
    } else {
        TFERROR("No portName found")
    }

    return portAddress;
}
Ejemplo n.º 26
0
static void removeBaseAttr(DOMDocument * domDocument) {

    XMLNodeFilter * nodeFilter = new XMLNodeFilter();
    DOMTreeWalker * domTreeWalker = domDocument->createTreeWalker(domDocument, DOMNodeFilter::SHOW_ALL, nodeFilter, true);

    DOMNode * node = domTreeWalker->getCurrentNode();
    while (node) {
        DOMNamedNodeMap * nodeMap = node->getAttributes();
        if (nodeMap != 0) {
            DOMNode * attr = nodeMap->getNamedItem(XMLString::transcode("xml:base"));
            if (attr) {
                DOMNode * node = nodeMap->removeNamedItem(XMLString::transcode("xml:base"));

                TFINFO("[Server Config] filtered attribute: " << XMLString::transcode(node->getNodeName()) << "=" << XMLString::transcode(node->getNodeValue()));
                node->release();
            }
        }
        node = domTreeWalker->nextNode();
    }
    delete nodeFilter;
}
Ejemplo n.º 27
0
bool ConfigurationFileHandler::getAttribute(std::string algorithm, std::string attribute, int* result) {
#ifdef BRICS_XERCES_ENABLE
	if (errorsOccured) {
		return false;
	}

    DOMNode* current = NULL;
    DOMNode* attributeNode = NULL;
    XMLCh* algorithmName = XMLString::transcode(algorithm.c_str());
    XMLCh* attributeName = XMLString::transcode(attribute.c_str());
    string tmpResult;
    bool attributeFound = false;

    DOMDocument* doc = parser->getDocument();
    DOMNodeList* root = doc->getElementsByTagName(algorithmName);
    if (root->getLength() > 1) {
    	LOG(WARNING) << "More than one " << algorithm << " found, taking the first one";
    } else if(root->getLength() < 1) {
    	LOG(WARNING) << "No algorithm called " << algorithm << " found.";
		return false; //TODO release resouces
    }

    current = root->item(0);
    DOMNamedNodeMap* attributesList =  current->getAttributes();
    attributeNode = attributesList->getNamedItem(attributeName);

    if (attributeNode != 0) {
		    tmpResult = XMLString::transcode(attributeNode->getNodeValue());
		    *result = atoi(tmpResult.c_str());
		    attributeFound = true;
	}

    XMLString::release(&algorithmName);
    XMLString::release(&attributeName);

    return attributeFound;
#else
    return false;
#endif
}
Ejemplo n.º 28
0
string InputHandler::getAttributeValueByName(const XMLCh* elementNode, const XMLCh* attribute, const XMLCh* name)
{

     crusde_debug("%s, line: %d, InputHandler::getAttributeValueByName(%s) name = %s ", __FILE__, __LINE__, XMLString::transcode(elementNode),
     XMLString::transcode(name));
     assert(doc);

     DOMElement *root = doc->getDocumentElement();
     DOMNode *child = root->getFirstChild();
     DOMNamedNodeMap *attributes = NULL;
		
     while (child)
     {
          if(child != NULL)
               if( child->getNodeType() == DOMNode::ELEMENT_NODE )
               {
                    if(child->hasAttributes())
                    {
                         attributes = child->getAttributes();

                         if( XMLString::compareIString( child->getNodeName(), elementNode) == 0 && 
                             XMLString::compareIString( attributes->getNamedItem(ATTR_name.xmlStr())->getNodeValue(), name) == 0 )
                         {
                              char *val = XMLString::transcode(attributes->getNamedItem(attribute)->getNodeValue());
                              string value(val);
                              XMLString::release(&val);
                              return value;
                         }
                    }
               }

          child = child->getNextSibling();
     }
	
     return string();
}
Ejemplo n.º 29
0
const XMLCh* DOMNodeImpl::lookupNamespaceURI(const XMLCh* specifiedPrefix) const  {
    DOMNode *thisNode = castToNode(this);

    short type = thisNode->getNodeType();
    switch (type) {
    case DOMNode::ELEMENT_NODE : {
        const XMLCh* ns = thisNode->getNamespaceURI();
        const XMLCh* prefix = thisNode->getPrefix();
        if (ns != 0) {
            // REVISIT: is it possible that prefix is empty string?
            if (specifiedPrefix == 0 && prefix == specifiedPrefix) {
                // looking for default namespace
                return ns;
            } else if (prefix != 0 && XMLString::equals(prefix, specifiedPrefix)) {
                // non default namespace
                return ns;
            }
        }
        if (thisNode->hasAttributes()) {
            DOMNamedNodeMap *nodeMap = thisNode->getAttributes();
            if(nodeMap != 0) {
                int length = nodeMap->getLength();
                for (int i = 0;i < length;i++) {
                    DOMNode *attr = nodeMap->item(i);
                    const XMLCh *attrPrefix = attr->getPrefix();
                    const XMLCh *value = attr->getNodeValue();
                    ns = attr->getNamespaceURI();

                    if (ns != 0 && XMLString::equals(ns, XMLUni::fgXMLNSURIName)) {
                        // at this point we are dealing with DOM Level 2 nodes only
                        if (specifiedPrefix == 0 &&
                            XMLString::equals(attr->getNodeName(), XMLUni::fgXMLNSString)) {
                            // default namespace
                            return value;
                        } else if (attrPrefix != 0 &&
                                   XMLString::equals(attrPrefix, XMLUni::fgXMLNSString) &&
                                   XMLString::equals(attr->getLocalName(), specifiedPrefix)) {
                            // non default namespace
                            return value;
                        }
                    }
                }
            }
        }
        DOMNode *ancestor = getElementAncestor(thisNode);
        if (ancestor != 0) {
            return ancestor->lookupNamespaceURI(specifiedPrefix);
        }
        return 0;
    }
    case DOMNode::DOCUMENT_NODE : {
        return((DOMDocument*)thisNode)->getDocumentElement()->lookupNamespaceURI(specifiedPrefix);
    }
    case DOMNode::ENTITY_NODE :
    case DOMNode::NOTATION_NODE:
    case DOMNode::DOCUMENT_FRAGMENT_NODE:
    case DOMNode::DOCUMENT_TYPE_NODE:
        // type is unknown
        return 0;
    case DOMNode::ATTRIBUTE_NODE:{
        if (fOwnerNode->getNodeType() == DOMNode::ELEMENT_NODE) {
            return fOwnerNode->lookupNamespaceURI(specifiedPrefix);
        }
        return 0;
    }
    default:{
        DOMNode *ancestor = getElementAncestor(castToNode(this));
        if (ancestor != 0) {
            return ancestor->lookupNamespaceURI(specifiedPrefix);
        }
        return 0;
    }
    }
}
Ejemplo n.º 30
0
// ---------------------------------------------------------------------------
//  This method assumes that currentNode is an xinclude element and parses
//   it accordingly, acting on what it finds.
// ---------------------------------------------------------------------------
bool
XIncludeUtils::doDOMNodeXInclude(DOMNode *xincludeNode, DOMDocument *parsedDocument, XMLEntityHandler* entityResolver){
    bool modifiedNode = false;
    /* the relevant attributes to look for */
    const XMLCh *href = NULL;
    const XMLCh *parse = NULL;
    const XMLCh *xpointer = NULL;
    const XMLCh *encoding = NULL;
    const XMLCh *accept = NULL;
    const XMLCh *acceptlanguage = NULL;
    DOMNode *includeParent = xincludeNode->getParentNode();


    if(xincludeNode->hasAttributes()) {
        /* get all the attributes of the node */
        DOMNamedNodeMap *pAttributes = xincludeNode->getAttributes();
        XMLSize_t nSize = pAttributes->getLength();
        for(XMLSize_t i=0;i<nSize;++i) {
            DOMAttr *pAttributeNode = (DOMAttr*) pAttributes->item(i);
            const XMLCh *attrName = pAttributeNode->getName();
            /* check each attribute against the potential useful names */
            if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeHREFAttrName)){
                href = pAttributeNode->getValue();
            } else if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeParseAttrName)){
                parse = pAttributeNode->getValue();
            } else if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeXPointerAttrName)){
                xpointer = pAttributeNode->getValue();
            } else if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeEncodingAttrName)){
                encoding = pAttributeNode->getValue();
            } else if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeAcceptAttrName)){
                accept = pAttributeNode->getValue();
            } else if (XMLString::equals(attrName, XIncludeUtils::fgXIIncludeAcceptLanguageAttrName)){
                acceptlanguage = pAttributeNode->getValue();
            } else {
                /* if any other attribute is in the xi namespace, it's an error */
                const XMLCh *attrNamespaceURI = pAttributeNode->getNamespaceURI();
                if (attrNamespaceURI && XMLString::equals(attrNamespaceURI, XIncludeUtils::fgXIIIncludeNamespaceURI)){
                } else {
                    /* ignore - any other attribute is allowed according to spec,
                       and must be ignored */
                }
            }
        }
    }
    // 3.1 xi:include Element
    // The children property of the xi:include element may include a single xi:fallback element;
    // the appearance of more than one xi:fallback element, an xi:include element,
    // or any other element from the XInclude namespace is a fatal error.
    DOMNode *child;
    DOMElement *fallback = NULL;
    for (child = xincludeNode->getFirstChild(); child != 0; child=child->getNextSibling()){
        if(child->getNodeType()!=DOMNode::ELEMENT_NODE)
            continue;
        if ( isXIFallbackDOMNode(child) ){
            if (fallback != NULL){
                /* fatal error - there are more than one fallback children */
                XIncludeUtils::reportError(xincludeNode, XMLErrs::XIncludeMultipleFallbackElems,
                    parsedDocument->getDocumentURI(), parsedDocument->getDocumentURI());
                return false;
            }
            fallback = (DOMElement*)child;
        }
        else if(isXIIncludeDOMNode(child) || XMLString::equals(child->getNamespaceURI(), XIncludeUtils::fgXIIIncludeNamespaceURI)) {
            /* fatal error - an xi element different from xi:fallback is a child of xi:include */
            XIncludeUtils::reportError(xincludeNode, XMLErrs::XIncludeDisallowedChild,
                child->getNodeName(), parsedDocument->getDocumentURI());
            return false;
        }
    }

    if (href == NULL){
        /* this is an unrecoverable error until we have xpointer support -
           if there is an xpointer, the current document is assumed
           however, there is no xpointer support yet */
        XIncludeUtils::reportError(xincludeNode, XMLErrs::XIncludeNoHref,
            NULL, parsedDocument->getDocumentURI());
        return false;
    }

    /* set up the accept and accept-language values */
    if (accept != NULL){

    }

    if (parse == NULL){
        /* use the default, as specified */
        parse = XIncludeUtils::fgXIIncludeParseAttrXMLValue;
    }

    if (xpointer != NULL){
        /* not supported yet */
        /* Note that finding an xpointer attr along with parse="text" is a Fatal Error
         *  - http://www.w3.org/TR/xinclude/#include-location */
        XIncludeUtils::reportError(xincludeNode, XMLErrs::XIncludeXPointerNotSupported,
            NULL, href);
        return false;
    }

    /* set up the href according to what has gone before */
    XIncludeLocation hrefLoc(href);
    XIncludeLocation relativeLocation(href);
    const XMLCh *includeBase = xincludeNode->getBaseURI();
    if (includeBase != NULL){
        hrefLoc.prependPath(includeBase);
    }

    if (getBaseAttrValue(xincludeNode) != NULL){
        relativeLocation.prependPath(getBaseAttrValue(xincludeNode));
    }

    /*  Take the relevant action - we need to retrieve the target as a whole before
        we can know if it was successful or not, therefore the do* methods do
        not modify the parsedDocument. Swapping the results in is left to the
        caller (i.e. here) */
    DOMText *includedText = NULL;
    DOMDocument *includedDoc = NULL;
    if (XMLString::equals(parse, XIncludeUtils::fgXIIncludeParseAttrXMLValue)){
        /* including a XML element */
        includedDoc = doXIncludeXMLFileDOM(hrefLoc.getLocation(), relativeLocation.getLocation(), xincludeNode, parsedDocument, entityResolver);
    } else if (XMLString::equals(parse, XIncludeUtils::fgXIIncludeParseAttrTextValue)){
        /* including a text value */
        includedText = doXIncludeTEXTFileDOM(hrefLoc.getLocation(), relativeLocation.getLocation(), encoding, xincludeNode, parsedDocument, entityResolver);
    } else {
        /* invalid parse attribute value - fatal error according to the specification */
        XIncludeUtils::reportError(xincludeNode, XMLErrs::XIncludeInvalidParseVal,
            parse, parsedDocument->getDocumentURI());
        return false;
    }

    RefVectorOf<DOMNode> delayedProcessing(12,false);
    if (includedDoc == NULL && includedText == NULL){
        /* there was an error - this is now a resource error
           let's see if there is a fallback */
        XIncludeUtils::reportError(xincludeNode, XMLErrs::XIncludeIncludeFailedResourceError,
            hrefLoc.getLocation(), parsedDocument->getDocumentURI());

        if (includeParent == NULL){
            includeParent = parsedDocument;
        }

        // we could be getting errors trying to insert elements at the root of the document, so we should use replaceChild;
        // in order to handle multiple nodes, add them to a document fragment and use that to replace the original node
        if (fallback){
            /* baseURI fixups - see http://www.w3.org/TR/xinclude/#base for details. */
            XMLUri parentURI(includeParent->getBaseURI());
            XMLUri includedURI(fallback->getBaseURI());

            if (fallback->hasChildNodes()){
                DOMDocumentFragment* frag = parsedDocument->createDocumentFragment();
                DOMNode *child = fallback->getFirstChild();
                /* add the content of the fallback element, and remove the fallback elem itself */
                for ( ; child != NULL ; child=child->getNextSibling()){
                    if (child->getNodeType() == DOMNode::DOCUMENT_TYPE_NODE){
                        continue;
                    }
                    DOMNode *newNode = parsedDocument->importNode(child, true);
                    /* if the paths differ we need to add a base attribute */
                    if (newNode->getNodeType()==DOMNode::ELEMENT_NODE && !XMLString::equals(parentURI.getPath(), includedURI.getPath())){
                        if (getBaseAttrValue(newNode) == NULL){
                            /* need to calculate the proper path difference to get the relativePath */
                            ((DOMElement*)newNode)->setAttribute(fgXIBaseAttrName, getBaseAttrValue(fallback->getParentNode()));
                        } else {
                            /* the included node has base of its own which takes precedence */
                            XIncludeLocation xil(getBaseAttrValue(newNode));
                            if (getBaseAttrValue(fallback->getParentNode()) != NULL){
                                /* prepend any specific base modification of the xinclude node */
                                xil.prependPath(getBaseAttrValue(fallback->getParentNode()));
                            }
                            ((DOMElement*)newNode)->setAttribute(fgXIBaseAttrName, xil.getLocation());
                        }
                    }
                    DOMNode *newChild = frag->appendChild(newNode);
                    // don't process the node now, wait until it is placed in the final position
                    delayedProcessing.addElement(newChild);
                    //parseDOMNodeDoingXInclude(newChild, parsedDocument, entityResolver);
                }
                includeParent->replaceChild(frag, xincludeNode);
                frag->release();

                for(XMLSize_t i=0;i<delayedProcessing.size();i++)
                {
                    DOMNode* childNode=delayedProcessing.elementAt(i);
                    parseDOMNodeDoingXInclude(childNode, parsedDocument, entityResolver);
                }
                modifiedNode = true;
            } else {
                /* empty fallback element - simply remove it! */
                includeParent->removeChild(xincludeNode);
                modifiedNode = true;
            }
        } else {
            XIncludeUtils::reportError(xincludeNode, XMLErrs::XIncludeIncludeFailedNoFallback,
                parsedDocument->getDocumentURI(), parsedDocument->getDocumentURI());
            return false;
        }
    } else {
        if (includedDoc){
            /* record the successful include while we process the children */
            addDocumentURIToCurrentInclusionHistoryStack(hrefLoc.getLocation());

            DOMDocumentFragment* frag = parsedDocument->createDocumentFragment();
            /* need to import the document prolog here */
            DOMNode *child = includedDoc->getFirstChild();
            for (; child != NULL; child = child->getNextSibling()) {
                if (child->getNodeType() == DOMNode::DOCUMENT_TYPE_NODE)
                    continue;
                // check for NOTATION or ENTITY clash
                if(child->getNodeType()==DOMNode::ELEMENT_NODE && includedDoc->getDoctype()!=NULL) {
                    DOMNamedNodeMap *pAttributes = child->getAttributes();
                    XMLSize_t nSize = pAttributes->getLength();
                    for(XMLSize_t i=0;i<nSize;++i) {
                        DOMAttr *pAttributeNode = (DOMAttr*) pAttributes->item(i);
                        const DOMTypeInfo * typeInfo=pAttributeNode->getSchemaTypeInfo();
                        if(typeInfo && XMLString::equals(typeInfo->getTypeNamespace(), XMLUni::fgInfosetURIName)) {
                            if(XMLString::equals(typeInfo->getTypeName(), XMLUni::fgNotationString)) {
                                const XMLCh* notationName=pAttributeNode->getNodeValue();
                                DOMNotation* notat=(DOMNotation*)includedDoc->getDoctype()->getNotations()->getNamedItem(notationName);
                                // ensure we have a DTD
                                if(parsedDocument->getDoctype()==NULL)
                                    parsedDocument->insertBefore(parsedDocument->createDocumentType(parsedDocument->getDocumentElement()->getNodeName(), NULL,NULL), parsedDocument->getFirstChild());
                                DOMNotation* myNotation=(DOMNotation*)parsedDocument->getDoctype()->getNotations()->getNamedItem(notationName);
                                if(myNotation==NULL)
                                {
                                    // it's missing, add it
                                    parsedDocument->getDoctype()->getNotations()->setNamedItem(parsedDocument->importNode(notat, true));
                                }
                                else if(XMLString::equals(myNotation->getPublicId(), notat->getPublicId()) &&
                                        XMLString::equals(myNotation->getSystemId(), notat->getSystemId()) &&
                                        XMLString::equals(myNotation->getBaseURI(), notat->getBaseURI()))
                                {
                                    // it's duplicate, ignore it
                                }
                                else
                                {
                                    // it's a conflict, report it
                                    XIncludeUtils::reportError(xincludeNode, XMLErrs::XIncludeConflictingNotation,
                                        notationName, parsedDocument->getDocumentURI());
                                }
                            }
                            else if(XMLString::equals(typeInfo->getTypeName(), XMLUni::fgEntityString)) {
                                const XMLCh* entityName=pAttributeNode->getNodeValue();
                                DOMEntity* ent=(DOMEntity*)includedDoc->getDoctype()->getEntities()->getNamedItem(entityName);
                                // ensure we have a DTD
                                if(parsedDocument->getDoctype()==NULL)
                                    parsedDocument->insertBefore(parsedDocument->createDocumentType(parsedDocument->getDocumentElement()->getNodeName(), NULL,NULL), parsedDocument->getFirstChild());
                                DOMEntity* myEnt=(DOMEntity*)parsedDocument->getDoctype()->getEntities()->getNamedItem(entityName);
                                if(myEnt==NULL)
                                {
                                    // it's missing, add it
                                    parsedDocument->getDoctype()->getEntities()->setNamedItem(parsedDocument->importNode(ent, true));
                                }
                                else if(XMLString::equals(myEnt->getPublicId(), ent->getPublicId()) &&
                                        XMLString::equals(myEnt->getSystemId(), ent->getSystemId()) &&
                                        XMLString::equals(myEnt->getBaseURI(), ent->getBaseURI()))
                                {
                                    // it's duplicate, ignore it
                                }
                                else
                                {
                                    // it's a conflict, report it
                                    XIncludeUtils::reportError(xincludeNode, XMLErrs::XIncludeConflictingEntity,
                                        entityName, parsedDocument->getDocumentURI());
                                }
                            }
                        }
                    }
                }
                DOMNode *newNode = parsedDocument->importNode(child, true);
                DOMNode *newChild = frag->appendChild(newNode);
                // don't process the node now, wait until it is placed in the final position
                delayedProcessing.addElement(newChild);
                //parseDOMNodeDoingXInclude(newChild, parsedDocument, entityResolver);
            }
            includeParent->replaceChild(frag, xincludeNode);
            frag->release();

            for(XMLSize_t i=0;i<delayedProcessing.size();i++)
            {
                DOMNode* childNode=delayedProcessing.elementAt(i);
                parseDOMNodeDoingXInclude(childNode, parsedDocument, entityResolver);
            }
            popFromCurrentInclusionHistoryStack(NULL);
            modifiedNode = true;
        } else if (includedText){
            includeParent->replaceChild(includedText, xincludeNode);
            modifiedNode = true;
        }
    }

    if (includedDoc)
        includedDoc->release();

    return modifiedNode;
}