10 #include <pugixml.hpp>
17 const char*
level,
const char* suite,
const char*
version) {
21 xml_document rootNode;
26 if ((dataRoot = getenv(
"OCDATAROOT")) ==
NULL) {
27 printf(
"-E- OCDATAROOT environment variable is not defined.\n");
30 string doiXMLFileName = (
string) dataRoot +
"/common/doi.xml";
32 xml_parse_result xmlResult = rootNode.load_file(doiXMLFileName.c_str());
35 printf(
"-E- %s Line %d: Can not load %s. %s\n", __FILE__, __LINE__,
36 doiXMLFileName.c_str(), xmlResult.description());
40 dacNode = rootNode.child(
"EID");
42 printf(
"-E- %s Line %d: could not find EID tag in XML file = %s\n",
43 __FILE__, __LINE__, doiXMLFileName.c_str());
47 dacStr = dacNode.attribute(
"name").value();
50 transform(platformStr.begin(), platformStr.end(), platformStr.begin(), ::toupper);
53 if (platformStr ==
"ADEOS")
54 platformStr =
"ADEOS-I";
55 else if (platformStr ==
"SUOMI-NPP")
59 xml_node platformNode = dacNode.find_child_by_attribute(
"platform",
"name", platformStr.c_str());
65 transform(sensorStr.begin(), sensorStr.end(), sensorStr.begin(), ::toupper);
68 xml_node sensorNode = platformNode.find_child_by_attribute(
"sensor",
"name", sensorStr.c_str());
73 string levelStr =
level;
74 transform(levelStr.begin(), levelStr.end(), levelStr.begin(), ::toupper);
77 xml_node levelNode = sensorNode.find_child_by_attribute(
"level",
"name", levelStr.c_str());
82 string suiteStr = suite;
83 transform(suiteStr.begin(), suiteStr.end(), suiteStr.begin(), ::toupper);
86 xml_node suiteNode = levelNode.find_child_by_attribute(
"suite",
"name", suiteStr.c_str());
93 size_t pos = versionStr.find_first_of(
'.');
94 if (
pos != string::npos)
95 versionStr.erase(
pos);
98 versionStr.erase(0,1);
101 xml_node versionNode = suiteNode.find_child_by_attribute(
"version",
"name", versionStr.c_str());
106 xml_node aliasNode = versionNode.child(
"alias");
108 doiStr = aliasNode.child_value();
110 doiStr = dacStr +
"/" + platformStr +
"/" + sensorStr +
"/" + levelStr +
111 "/" + suiteStr +
"/" + versionStr;
114 return doiStr.c_str();