コード例 #1
0
ファイル: triggerconf.cpp プロジェクト: freshbob/worms-attack
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 ();
}
コード例 #2
0
 void findElement(unsigned index) {
    currentElement = NULL;
    while ((elementList != NULL) && (index < elementList->getLength())) {
       DOMNode *node = elementList->item(index);
       if (node == NULL) {
          // Should be impossible
          throw new runtime_error("DOMChildIterator::setIndex() - elementList->item(i) failed");
       }
       if (node->getNodeType() == DOMNode::ELEMENT_NODE) {
          DOMElement *el = dynamic_cast< xercesc::DOMElement* >( node );
          if (el == NULL) {
             // Should be impossible
             throw new runtime_error("DOMChildIterator::setIndex() - casting failed");
          }
          currentElement = el;
          this->index = index;
          break;
       }
       index++;
    }
 }
コード例 #3
0
ファイル: 14-10.cpp プロジェクト: arraytools/C
// Returns the value of the "name" child of an "animal" element.
const XMLCh* getAnimalName(const DOMElement* animal)
{
    static XercesString name = fromNative("name");

    // Iterate though animal's children
    DOMNodeList* children = animal->getChildNodes( );
    for ( size_t i = 0,
                 len = children->getLength( ); 
          i < len; 
          ++i ) 
    {
        DOMNode* child = children->item(i);
        if ( child->getNodeType( ) == DOMNode::ELEMENT_NODE &&
             static_cast<DOMElement*>(child)->getTagName( ) == name )
        {
            // We've found the "name" element.
            return child->getTextContent( );
        }
    }
    return 0;
}
コード例 #4
0
ファイル: DOMElementImpl.cpp プロジェクト: AmesianX/Sigil
DOMElement * DOMElementImpl::getPreviousElementSibling() const
{
    DOMNode* n = getPreviousLogicalSibling(this);
    while (n != NULL) {
        switch (n->getNodeType()) {
            case DOMNode::ELEMENT_NODE:
                return (DOMElement*) n;
            case DOMNode::ENTITY_REFERENCE_NODE:
                {
                    DOMElement* e = getLastElementChild(n);
                    if (e != NULL)
                        return e;
                }
                break;
            default:
                break;
        }
        n = getPreviousLogicalSibling(n);
    }
    return NULL;
}
コード例 #5
0
ファイル: DOMNodeImpl.cpp プロジェクト: JohnWilliam1988/TCIDE
const XMLCh* DOMNodeImpl::lookupPrefix(const XMLCh* namespaceURI) const {
    // REVISIT: When Namespaces 1.1 comes out this may not be true
    // Prefix can't be bound to null namespace
    if (namespaceURI == 0) {
        return 0;
    }

    DOMNode *thisNode = castToNode(this);

    short type = thisNode->getNodeType();

    switch (type) {
    case DOMNode::ELEMENT_NODE: {
        return lookupPrefix(namespaceURI, (DOMElement*)thisNode);
    }
    case DOMNode::DOCUMENT_NODE:{
        return ((DOMDocument*)thisNode)->getDocumentElement()->lookupPrefix(namespaceURI);
    }

    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->lookupPrefix(namespaceURI);
        }
        return 0;
    }
    default:{
        DOMNode *ancestor = getElementAncestor(thisNode);
        if (ancestor != 0) {
            return ancestor->lookupPrefix(namespaceURI);
        }
        return 0;
    }
    }
}
コード例 #6
0
void XmlPropertyReader::parseGameObjectFile(Ogre::DataStreamPtr &stream, const Ogre::String &groupName)
{
    initializeXml();

    XERCES_CPP_NAMESPACE::DOMDocument* doc = loadDocument(stream);

    DOMNodeList* godefsXml = doc->getDocumentElement()->getElementsByTagName(AutoXMLCh("gameobjectclass").data());
    for (unsigned int idx = 0; idx < godefsXml->getLength(); idx++)
    {
		PropertyRecordPtr ps(new PropertyRecord());
		DOMElement* curNode = static_cast<DOMElement*>(godefsXml->item(idx));
		
		const DOMNamedNodeMap* godefAttrs = curNode->getAttributes();
		for (XMLSize_t attrIdx = 0; attrIdx < godefAttrs->getLength(); attrIdx++)
		{
			PropertyEntry entry = processProperty(static_cast<DOMAttr*>(godefAttrs->item(attrIdx)));
            if (entry.first != "")
            {
                ps->setProperty(entry.first, entry.second);
            }
		}

        DOMNodeList* godefChildren = curNode->getChildNodes();
        for (XMLSize_t childIdx = 0; childIdx < godefChildren->getLength(); childIdx++)
        {
            DOMNode* curChild = godefChildren->item(childIdx);
            if (curChild->getNodeType() == DOMNode::ELEMENT_NODE)
            {
                PropertyEntry entry = processProperty(static_cast<DOMElement*>(curChild));
                if (entry.first != "")
                {
                    ps->setProperty(entry.first, entry.second);
                }
            }
        }
        mPropertyRecords.push_back(ps);
    }
	
    shutdownXml();
}
コード例 #7
0
ファイル: DSIGKeyInfoName.cpp プロジェクト: okean/cpputils
void DSIGKeyInfoName::load(void) {

	// Assuming we have a valid DOM_Node to start with, load the signing key so that it can
	// be used later on

	if (mp_keyInfoDOMNode == NULL) {

		// Attempt to load an empty signature element
		throw XSECException(XSECException::LoadEmptyInfoName);

	}

	if (!strEquals(getDSIGLocalName(mp_keyInfoDOMNode), "KeyName")) {

		throw XSECException(XSECException::LoadNonInfoName);

	}

	// Now find the text node containing the name

	DOMNode *tmpElt = mp_keyInfoDOMNode->getFirstChild();

	while (tmpElt != 0 && tmpElt->getNodeType() != DOMNode::TEXT_NODE)
		tmpElt = tmpElt->getNextSibling();

	if (tmpElt != 0) {

		mp_keyNameTextNode = tmpElt;
		mp_name = tmpElt->getNodeValue();

	}

	else {

		throw XSECException(XSECException::ExpectedDSIGChildNotFound,
			MAKE_UNICODE_STRING("Expected TEXT node as child to <KeyName> element"));

	}

}
コード例 #8
0
int attNodeCount(DOMElement * d) {

	int ret;

	ret = d->getAttributes()->getLength();

	DOMNode *c;

	c = d->getFirstChild();

	while (c != NULL) {

		if (c->getNodeType() == DOMNode::ELEMENT_NODE)
			ret += attNodeCount((DOMElement *) c);

		c = c->getNextSibling();

	}

	return ret;

}
コード例 #9
0
DOMNode *WrapXerces::getNextLogicalSibling (
	const DOMNode* n )
{
	// Copied from Xerces-C
	DOMNode* next = n->getNextSibling();
	// If "n" has no following sibling and its parent is an entity reference node we
	// need to continue the search through the following siblings of the entity
	// reference as these are logically siblings of the given node.
	if ( !next ) {
		DOMNode* parent = n->getParentNode();
		while ( parent
				&& parent->getNodeType() == DOMNode::ENTITY_REFERENCE_NODE )
		{
			next = parent->getNextSibling();
			if ( next )
				break;

			parent = parent->getParentNode();
		}
	}
	return next;
}
コード例 #10
0
Implementation
CSDReader4qxml::implementation (DOMElement* element)
throw(CSDReadException)
{
	Implementation impl;
	impl.id = Qedo::transcode(element->getAttribute(X("id")));

	std::string element_name;
    DOMNode* child = element->getFirstChild();
    while (child != 0)
    {
		if (child->getNodeType() == DOMNode::ELEMENT_NODE)
		{
			element_name = Qedo::transcode(child->getNodeName());

			//
			// os
			//
			if (element_name == "os")
			{
				impl.os_name=os((DOMElement*)child);
			}

			//
			// fileinarchive
			//
			else if (element_name == "descriptor")
			{
				impl.descriptor=descriptor((DOMElement*)child);
			}
		}

        // get next child
	    child = child->getNextSibling();
	}

	//throw CSDReadException();
	return impl;
}
コード例 #11
0
void
CSDReader4qxml::softpkgref (DOMElement* element)
throw(CSDReadException)
{
	std::string element_name;
	std::string idref;
    DOMNode* child = element->getFirstChild();
	while (child != 0)
	{
		if (child->getNodeType() == DOMNode::ELEMENT_NODE)
		{
			element_name = Qedo::transcode(child->getNodeName());

			//
			// fileinarchive
			//
			if (element_name == "fileinarchive")
			{
				// todo
//				fileinarchive( (DOMElement*)child );
			}

			
			//
			// implref
			//
			else if (element_name == "implref")
			{
//				idref = implref( (DOMElement*)child );
			}
		}

		// get next child
		child = child->getNextSibling();
    }

//	data_->softpkg_dependencies.push_back( idref );
}
コード例 #12
0
ファイル: DOMNodeImpl.cpp プロジェクト: JohnWilliam1988/TCIDE
bool DOMNodeImpl::isEqualNode(const DOMNode* arg) const
{
    if (!arg)
        return false;

    if (isSameNode(arg)) {
        return true;
    }

    DOMNode* thisNode = castToNode(this);

    if (arg->getNodeType() != thisNode->getNodeType()) {
        return false;
    }

    // the compareString will check null string as well
    if (!XMLString::equals(thisNode->getNodeName(), arg->getNodeName())) {
        return false;
    }

    if (!XMLString::equals(thisNode->getLocalName(),arg->getLocalName())) {
        return false;
    }

    if (!XMLString::equals(thisNode->getNamespaceURI(), arg->getNamespaceURI())) {
        return false;
    }

    if (!XMLString::equals(thisNode->getPrefix(), arg->getPrefix())) {
        return false;
    }

    if (!XMLString::equals(thisNode->getNodeValue(), arg->getNodeValue())) {
        return false;
    }

    return true;
}
コード例 #13
0
Descriptor
CSDReader4qxml::descriptor (DOMElement* element)
throw(CSDReadException)
{
	Descriptor descr;
	descr.type = Qedo::transcode(element->getAttribute(X("type")));
	std::string element_name;
    DOMNode* child = element->getFirstChild();
    while (child != 0)
    {
		if (child->getNodeType() == DOMNode::ELEMENT_NODE)
		{
			element_name = Qedo::transcode(child->getNodeName());

			//
			// link
			//
			if (element_name == "link")
			{
//				return link((DOMElement*)child).file;
			}

			//
			// fileinarchive
			//
			else if (element_name == "fileinarchive")
			{
				descr.filearchive=fileinarchive((DOMElement*)child);
			}
		}

        // get next child
	    child = child->getNextSibling();
	}

	return descr;
	//throw CSDReadException();
}
コード例 #14
0
ファイル: NclLayoutParser.cpp プロジェクト: lince/ginga-srpp
	void *NclLayoutParser::parseRegion(
		    DOMElement *parentElement, void *objGrandParent) {

		wclog << "parseRegion" << endl;
		void *parentObject;
		DOMNodeList *elementNodeList;
		DOMElement *element;
		DOMNode *node;
		string elementTagName;
		void *elementObject;

		parentObject = createRegion(parentElement, objGrandParent);
		if (parentObject == NULL) {
			return NULL;
		}

		elementNodeList = parentElement->getChildNodes();
		for (int i = 0; i < (int)elementNodeList->getLength(); i++) {
			node = elementNodeList->item(i);
			if (node->getNodeType()==DOMNode::ELEMENT_NODE) {
				element = (DOMElement*)node;
				elementTagName = XMLString::transcode(element->getTagName());
				wclog << ">>" << elementTagName.c_str() << ": ";
				wclog << XMLString::transcode(element->getAttribute(XMLString::transcode("id")));

				if (XMLString::compareIString(
					    elementTagName.c_str(), "region") == 0) {

					elementObject = parseRegion(element, parentObject);
					if (elementObject != NULL) {
						addRegionToRegion(parentObject, elementObject);
					}
				}
			}
		}

		return parentObject;
	}
コード例 #15
0
ファイル: NclImportParser.cpp プロジェクト: lince/ginga-srpp
	void *NclImportParser::parseImportedDocumentBase(
		    DOMElement *parentElement, void *objGrandParent) {

		void *parentObject;
		DOMNodeList *elementNodeList;
		DOMElement *element;
		DOMNode *node;
		string elementTagName;
		void *elementObject;

		//pre-compile attributes
		parentObject = createImportedDocumentBase(
			    parentElement, objGrandParent);

		if (parentObject == NULL) {
			return NULL;
		}

		elementNodeList = parentElement->getChildNodes();
		for (int i = 0; i < (int)elementNodeList->getLength(); i++) {
			node = elementNodeList->item(i);
			if(node->getNodeType()==DOMNode::ELEMENT_NODE){
				element = (DOMElement*)node;
				elementTagName = XMLString::transcode( element->getTagName() );
				if (XMLString::compareIString(
					     elementTagName.c_str(), "importNCL") == 0) {

					elementObject = parseImportNCL(element, parentObject);
					if (elementObject != NULL) {
						addImportNCLToImportedDocumentBase(
							    parentObject, elementObject);
					}
				}
			}
		}

		return parentObject;
	}
コード例 #16
0
ファイル: ClsSettingsReader.cpp プロジェクト: jeez/iqr
list<string> ClsSettingsReader::getListLastFiles() {
#ifdef DEBUG_CLSSETTINGSREADER
    cout << "ClsSettingsReader::getListLastFiles()" << endl;
#endif
    list<string> lstLFO;

    if(iSysSettingReaderState !=  PARSER_BUFFER_PARSED){
	ClsSettingsReaderException clsSettingsReaderException(ClsSettingsReaderException::BUFFER_NOT_PARSED);
	throw clsSettingsReaderException;
    }


    DOMNodeList* dnlstTemp = ddocIqrSetting->getElementsByTagName(XMLString::transcode(ClsTagLibrary::lastFilesOpen()));
    DOMNode* dnTemp=NULL;

    if ( dnlstTemp->getLength() == 1){
	dnTemp = dnlstTemp->item(0);
    } else if ( dnlstTemp->getLength() < 1)	{
	ClsSettingsReaderException clsSettingsReaderException(ClsSettingsReaderException::ENTITY_NOT_FOUND);
	throw clsSettingsReaderException;
    }

    DOMNodeList* dnlstFiles = dnTemp->getChildNodes();
    unsigned int ii = 0;
    while( ii< dnlstFiles->getLength()){
	DOMNode* dnTempTemp = dnlstFiles->item(ii);
	if(dnTempTemp->getNodeType() == 1){
	    DOMNode* dnValue = dnTempTemp->getFirstChild();
	    if(dnValue!=NULL){
		string strValue = XMLString::transcode(dnValue->getNodeValue());
		lstLFO.push_back(strValue);
	    }
	}
	ii++;
    }

    return lstLFO;
};
コード例 #17
0
ファイル: triggerconf.cpp プロジェクト: freshbob/worms-attack
DOMNode* Triggerconf::getChildOfType (DOMNode* root, short type, unsigned int index)
{
	if (root == NULL) return NULL;
	if (! root->hasChildNodes ()) return NULL;

	DOMNodeList* childs = root->getChildNodes ();
	if (childs == NULL) return NULL;

	unsigned int idx = 0;

	for (unsigned int i=0; i<childs->getLength (); i++) {
		DOMNode* child = childs->item (i);

		if (child->getNodeType () == type) {
			if (idx == index)
				return child;
			else
				idx++;
		}
	} // for (unsigned int i=0; i<childs->getLength (); i++)

	return NULL;
}
コード例 #18
0
ファイル: triggerconf.cpp プロジェクト: freshbob/worms-attack
string Triggerconf::getSubmoduleAttributeValue (string module, string submodule, string attributename)
{
	if (! existsSubmodule (module, submodule)) {
		setError ("invalid submodule");
		return "";
	}

	DOMNode* node = selectSubmodule (module, submodule);
	assert (node->getNodeType () == DOMNode::ELEMENT_NODE);
	DOMElement* elem = (DOMElement*) node;
	
	XMLCh*	xattrname	= XMLString::transcode (attributename.c_str ());
	const XMLCh* xattrval	= elem->getAttribute (xattrname);
	char*	charstring	= XMLString::transcode (xattrval);
	string	ret		= charstring;

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

	resetError		();

	return ret;
}
コード例 #19
0
ファイル: triggerconf.cpp プロジェクト: freshbob/worms-attack
Triggerconf::STRING_LIST Triggerconf::getConfigAttributeNames (string module, string submodule, string configname)
{
	STRING_LIST ret;

	if (! existsConfigElement (module, submodule, configname)) return ret;

	DOMNode* node = selectConfigElement (module, submodule, configname);
	if (node == NULL || node->getNodeType () != DOMNode::ELEMENT_NODE) return ret;

	DOMElement* elem = (DOMElement*) node;
	DOMNamedNodeMap* attributes = elem->getAttributes ();

	for (unsigned int i=0; i<attributes->getLength (); i++) {
		DOMNode* attr = attributes->item (i);
		const XMLCh* xname = attr->getNodeName ();	
		char* cname = XMLString::transcode (xname);

		ret.push_back (cname);	
		XMLString::release (&cname);
	}

	return ret;
}
コード例 #20
0
void docSetup(DOMDocument *doc) {

	// Print out the doc

	DOMPrintFormatTarget* formatTarget = new DOMPrintFormatTarget();
	
    const XMLCh* encNameStr = XMLString::transcode("UTF-8");
    DOMNode *aNode = doc->getFirstChild();
    if (aNode->getNodeType() == DOMNode::ENTITY_NODE)
    {
        const XMLCh* aStr = ((DOMEntity *)aNode)->
#if defined XSEC_XERCES_DOMENTITYINPUTENCODING
            getInputEncoding();
#else
            getEncoding();
#endif

        if (!strEquals(aStr, ""))
        {
            encNameStr = aStr;
        }
    }
    xsecsize_t lent = XMLString::stringLen(encNameStr);
    gEncodingName = new XMLCh[lent + 1];
    XMLString::copyNString(gEncodingName, encNameStr, lent);
    gEncodingName[lent] = 0;

	
	
#if defined(XSEC_XERCES_FORMATTER_REQUIRES_VERSION)
	gFormatter = new XMLFormatter("UTF-8", 0, formatTarget,
                                          XMLFormatter::NoEscapes, gUnRepFlags);
#else
	gFormatter = new XMLFormatter("UTF-8", formatTarget,
                                          XMLFormatter::NoEscapes, gUnRepFlags);
#endif
}
コード例 #21
0
ReferenceData
CADReader::homeinterface (DOMElement* element)
throw(CADReadException)
{
	std::string element_name;
	ReferenceData data;
	DOMNode* child = element->getFirstChild();
	while (child != 0)
	{
		if (child->getNodeType() == DOMNode::ELEMENT_NODE)
		{
			element_name = XMLString::transcode(child->getNodeName());

			//
			// homeplacementref
			//
			if (element_name == "homeplacementref")
			{
				data.kind = HOMEID;
				data.name = homeplacementref((DOMElement*)(child));
			}

			//
			// findby
			//
			else if (element_name == "findby")
			{
				data = findby((DOMElement*)(child));
			}
		}

        // get next child
	    child = child->getNextSibling();
	}

	return data;
}
コード例 #22
0
std::string
DTMReader::readConnection(std::string descriptor)
	throw(DTMReadException)
{
	strConn_ = "";
	DOMXMLParser parser;
	
    if ( parser.parse( ((char*)descriptor.c_str()) ) != 0 )
	{
		std::cerr << "Error during XML parsing" << std::endl;
        throw DTMReadException();
	}

	dtm_document_ = parser.getDocument();

	DOMNode* child = dtm_document_->getDocumentElement()->getFirstChild();
	while (child != 0)
	{
		if (child->getNodeType() == DOMNode::ELEMENT_NODE)
			// handle connection
			if ( !XMLString::compareString(child->getNodeName(), X("connection")) )
				connection((DOMElement*)child);
		
        // get next child
		child = child->getNextSibling();
    }

	for(unsigned int i=0; i<vName_.size(); i++)
	{
		strConn_ += vName_[i];
		strConn_ += "=";
		strConn_ += vValue_[i];
		strConn_ += ";";
	}

	return strConn_;
}
コード例 #23
0
ScriptData 
CADReader::action (DOMElement* element)
throw(CADReadException)
{
	ScriptData data;
	data.language = Qedo::transcode(element->getAttribute(X("language")));

	std::string element_name;
	DOMNode* child = element->getFirstChild();
	while (child != 0)
	{
		if (child->getNodeType() == DOMNode::ELEMENT_NODE)
		{
			element_name = Qedo::transcode(child->getNodeName());

			//
			// fileinarchive
			//
			if (element_name == "fileinarchive")
			{
				FileData file_data = fileinarchive( (DOMElement*)child );
				std::ifstream file;
				file.open( file_data.name.c_str() );
				if (!file)
				{
					NORMAL_ERR2( "CADReader: cannot open file ", file_data.name );
					throw CADReadException();
				}
				file >> data.code;
				file.close();
				// todo what to do with the extracted file?
			}

			//
			// scriptcode
			//
			else if (element_name == "scriptcode")
コード例 #24
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();
}
コード例 #25
0
void 
CCDReader4qxml::componentfeatures (DOMElement* element)
throw(CCDReadException)
{
	DOMNode* child = element->getFirstChild();
	while (child != 0)
	{
		if (child->getNodeType() == DOMNode::ELEMENT_NODE)
		{
			//
			// ports
			//
			if (!XMLString::compareString(child->getNodeName(), X("ports")))
			{
				ports((DOMElement*)child);
			}

		}

        // get next child
		child = child->getNextSibling();
    }

}
コード例 #26
0
ファイル: XercesUtils.cpp プロジェクト: usnistgov/QIF
// Look at Xerces XSModel to parse XSD into tree SCMPrint
void CXercesUtils::NagivateParseTree(xercesc::DOMElement* p, std::string tabs)
{
	string name;
	short age;
	tabs+="    ";
	for (DOMNode* n = p->getFirstChild ();	n != 0;	n = n->getNextSibling ())
	{
		if (n->getNodeType () != DOMNode::ELEMENT_NODE)
			continue;
		DOMElement*  e = (DOMElement* ) n;
		std::string el_name =  XMLString::transcode(n->getNodeName());

		std::string el_value;
		if(e->getTextContent () && e->getChildElementCount() == (XMLSize_t) 0)
			el_value = XMLString::transcode(e->getTextContent ());

		std::cerr <<  tabs.c_str() << el_name.c_str()<< "=" << el_value.c_str()<< endl;
		//DOMNode* node = n->getFirstChild ();

		NagivateParseTree((DOMElement*) n,tabs);
	}
	tabs=tabs.substr(1);

}
コード例 #27
0
std::string
CADReader::homeproperties (DOMElement* element)
throw(CADReadException)
{
	std::string element_name;
	std::string file;
	DOMNode* child = element->getFirstChild();
	while (child != 0)
	{
		if (child->getNodeType() == DOMNode::ELEMENT_NODE)
		{
			element_name = XMLString::transcode(child->getNodeName());

			//
			// fileinarchive
			//
			if (element_name == "fileinarchive")
			{
				file = fileinarchive((DOMElement*)(child));
			}

			//
			// codebase
			//
			else if (element_name == "codebase")
			{
				// todo
			}
		}

        // get next child
	    child = child->getNextSibling();
	}

	return file;
}
コード例 #28
0
ファイル: XUtil.cpp プロジェクト: mydw/mydw
// Finds and returns the first child node with the given name.
DOMElement* XUtil::getFirstChildElementNS(const DOMNode* const parent
                                          , const XMLCh** const elemNames
                                          , const XMLCh* const uriStr
                                          , unsigned int        length)
{
    // search for node
    DOMNode* child = parent->getFirstChild();
    while (child != 0)
	{
        if (child->getNodeType() == DOMNode::ELEMENT_NODE)
		{
            for (unsigned int i = 0; i < length; i++)
			{
                if (XMLString::equals(child->getNamespaceURI(), uriStr) &&
                    XMLString::equals(child->getLocalName(), elemNames[i]))
                    return (DOMElement*)child;
			}
		}
        child = child->getNextSibling();
    }

    // not found
    return 0;
}
コード例 #29
0
ファイル: XUtil.cpp プロジェクト: mydw/mydw
// Finds and returns the next sibling element node with the give name.
DOMElement* XUtil::getNextSiblingElementNS(const DOMNode* const node
                                           , const XMLCh** const elemNames
                                           , const XMLCh* const uriStr
									       , unsigned int        length)
{
    // search for node
    DOMNode* sibling = node->getNextSibling();
    while (sibling != 0)
	{
        if (sibling->getNodeType() == DOMNode::ELEMENT_NODE)
		{
            for (unsigned int i = 0; i < length; i++)
			{
                if (XMLString::equals(sibling->getNamespaceURI(), uriStr) &&
                    XMLString::equals(sibling->getLocalName(), elemNames[i]))
                    return (DOMElement*)sibling;
			}
		}
        sibling = sibling->getNextSibling();
    }

    // not found
    return 0;
}
コード例 #30
0
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;
}