From eb6f97bd77e790c396a03d89bb941e6a94481d78 Mon Sep 17 00:00:00 2001 From: Ralph Marschall Date: Thu, 11 Oct 2018 10:46:38 +0200 Subject: [PATCH] Fix issue where DPI was not parsed, due to wrong AMD parser --- project/metsparser.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/project/metsparser.cpp b/project/metsparser.cpp index 9f9dbb6..5d748de 100644 --- a/project/metsparser.cpp +++ b/project/metsparser.cpp @@ -75,6 +75,7 @@ class StateParserScanResolution : public StateParserRootamdSecState{ virtual void endElement (const char* const name){ boost::algorithm::trim(cData); CTX.amdsec.dpi = atoi(cData.c_str()); + //printf("DPI FOUND: %d\n", CTX.amdsec.dpi); }; }; @@ -124,14 +125,14 @@ void StateParseramdSecState::startElement (const char* const name, const xercesc CTX.mandatoryField.insert("imageWidth"); CTX.mandatoryField.insert("imageHeight"); } - + }; /** MixContainerNotDefine stores the keys of mandatoryField that have not been found. Improvement: MixContainerNotDefine should be a set. The value for key is not used. */ void StateParseramdSecState::endElement (const char* const name){ - CTX.dfMets->set(CTX.amdsec.amdSecId,CTX.amdsec); // TODO: Should this be moved to RootGeneralAmdSecState.endElement ?? + //CTX.dfMets->set(CTX.amdsec.amdSecId,CTX.amdsec); // TODO: Should this be moved to RootGeneralAmdSecState.endElement ?? if ( CTX.flagMix ) { if ( CTX.mandatoryField.size() != 0 ) { @@ -250,15 +251,18 @@ class StateParserGeneralAmdSecState : public StateParserRootGeneralAmdSecState { if (attribute_id != 0) { CTX.amdsec.amdSecId = attribute_id; } + + //std::cout << "StateParserGeneralAmdSecState: START ELEMENT : " << attribute_id << std::endl; }; virtual void endElement (const char* const name) { - // N + CTX.dfMets->set(CTX.amdsec.amdSecId,CTX.amdsec); + + //std::cout << "StateParserGeneralAmdSecState: END ELEMENT" << std::endl; + } }; -// - // TODO: NEED ATTRIBUTES IN getNext PARAMETER ??? // My guess is no, because (1) GetNext will return this one, then (2) start element is called, then (3) the next getNext will return the mix or odrl // Step (2) is where the AMDSec ID is read @@ -693,7 +697,7 @@ StateParserState* StateParserMetsRootState::getNext(const char* const name) { static StateParserState* root = new StateParserMetsRootState(); StateParserState* ret = root; - + static struct _onlyOnes { _onlyOnes(std::map& map) { // Define sub-state-machines for each major tag @@ -708,7 +712,7 @@ StateParserState* StateParserMetsRootState::getNext(const char* const name) { map["controlfield"] = new StateParsermodStateInventoryMarc("BIBREC_SYS_NUM"); // could be better if children of dmdsec // amd -> has his sub state //map["amdSec"] = new StateParseramdSecState(); - map["amdSec"] = new StateParserRootGeneralAmdSecState(); + map["amdSec"] = new StateParserGeneralAmdSecState(); //new StateParserRootGeneralAmdSecState(); // TODO: // 1) amdSec will focus on MIX data only