1 /* 2 * Copyright 2006 Sony Computer Entertainment Inc. 3 * 4 * Licensed under the MIT Open Source License, for details please see license.txt or the website 5 * http://www.opensource.org/licenses/mit-license.php 6 * 7 */ 8 9 #include <sstream> 10 #include <dae.h> 11 #include <dae/daeStandardURIResolver.h> 12 #include <dae/daeDatabase.h> 13 #include <dae/daeURI.h> 14 #include <dae/daeIOPlugin.h> 15 #include <dae/daeErrorHandler.h> 16 17 using namespace std; 18 19 daeStandardURIResolver::daeStandardURIResolver(DAE& dae) 20 : daeURIResolver(dae) { } 21 22 daeStandardURIResolver::~daeStandardURIResolver() { } 23 24 daeString 25 daeStandardURIResolver::getName() 26 { 27 return "XMLResolver"; 28 } 29 30 namespace { 31 void printErrorMsg(const daeURI& uri) { 32 ostringstream msg; 33 msg << "daeStandardURIResolver::resolveElement() - Failed to resolve " << uri.str() << endl; 34 daeErrorHandler::get()->handleError(msg.str().c_str()); 35 } 36 } 37 38 daeElement* daeStandardURIResolver::resolveElement(const daeURI& uri) { 39 daeDocument* doc = uri.getReferencedDocument(); 40 if (!doc) { 41 dae->open(uri.str()); 42 doc = uri.getReferencedDocument(); 43 if (!doc) { 44 printErrorMsg(uri); 45 return NULL; 46 } 47 } 48 49 daeElement* elt = dae->getDatabase()->idLookup(uri.id(), doc); 50 if (!elt) 51 printErrorMsg(uri); 52 53 return elt; 54 } 55