57 #ifdef NO_STD_CHEADERS 78 #include <xercesc/util/XMLString.hpp> 79 using XERCES_CPP_NAMESPACE::XMLString;
112 DOMNode *child = mathMLExpr->getFirstChild();
113 for (; child !=
NULL; child = child->getNextSibling()) {
114 if (child->getNodeType() == DOMNode::TEXT_NODE) {
118 else if (child->getNodeType() == DOMNode::COMMENT_NODE) {
125 IFTRACE << child->getNodeType() << endl;
151 static const XMLCh*
NUMBER = XMLString::transcode(
"cn");
152 static const XMLCh* IDENTIFIER = XMLString::transcode(
"ci");
154 static const XMLCh* APPLY = XMLString::transcode(
"apply");
155 static const XMLCh* SUBTRACTION = XMLString::transcode(
"minus");
156 static const XMLCh* ADDITION = XMLString::transcode(
"plus");
157 static const XMLCh* DIVISION = XMLString::transcode(
"divide");
158 static const XMLCh* MULTIPLICATION = XMLString::transcode(
"times");
159 static const XMLCh* EXPONENTIATION = XMLString::transcode(
"power");
160 static const XMLCh* MAXML = XMLString::transcode(
"max");
161 static const XMLCh* MINML = XMLString::transcode(
"min");
162 static const XMLCh* MEAN = XMLString::transcode(
"mean");
163 static const XMLCh* STDDEV = XMLString::transcode(
"sdev");
166 const XMLCh* nodeName = node->getNodeName();
167 const XMLCh* nodeValue = node->getNodeValue();
169 switch (node->getNodeType()) {
171 case DOMNode::TEXT_NODE:
176 IFTRACE <<
"str --" << str <<
"--" << endl;
179 IFTRACE <<
"number is --" << val <<
"--" << endl;
183 IFTRACE <<
"str --" << str <<
"--" << endl;
187 MathML_Throw(
"Undefined metric '" + str +
"' encountered");
190 IFTRACE <<
"index --" << m->
id() <<
"--" << endl;
196 case DOMNode::ELEMENT_NODE: {
198 DOMNode *child = node->getFirstChild();
201 if (XMLString::equals(nodeName, APPLY)) {
207 while (op !=
NULL && op->getNodeType() != DOMNode::ELEMENT_NODE)
208 op = op->getNextSibling();
217 while ((child = child->getNextSibling()) !=
NULL) {
219 if (child->getNodeType() == DOMNode::TEXT_NODE) {
221 }
else if (child->getNodeType() == DOMNode::COMMENT_NODE) {
232 IFTRACE << numChildren <<
" children" << endl;
234 if (numChildren == 0) {
242 for (
int i = 0; i < numChildren; i++) {
244 child = child->getNextSibling();
246 IFTRACE <<
"child " << i <<
" " << child << endl;
251 for (
int j = 0; j < i; j++)
259 nodeName = op->getNodeName();
260 if (XMLString::equals(nodeName,SUBTRACTION) && numChildren <= 2) {
261 if (numChildren == 1)
265 else if (XMLString::equals(nodeName,ADDITION)) {
268 else if (XMLString::equals(nodeName,MULTIPLICATION)) {
271 else if (XMLString::equals(nodeName,DIVISION) && numChildren == 2) {
274 else if (XMLString::equals(nodeName,EXPONENTIATION) && numChildren == 2) {
277 else if (XMLString::equals(nodeName,MAXML)) {
280 else if (XMLString::equals(nodeName,MINML)) {
283 else if (XMLString::equals(nodeName,MEAN)) {
286 else if (XMLString::equals(nodeName,STDDEV)) {
291 for (
int i = 0; i < numChildren; i++)
298 if (XMLString::equals(nodeName,NUMBER)) {
299 IFTRACE <<
"--" << child <<
"--" << endl;
310 if (XMLString::equals(nodeName,IDENTIFIER)) {
311 IFTRACE <<
"--" << child <<
"--" << endl;
326 case DOMNode::ENTITY_REFERENCE_NODE:
331 case DOMNode::CDATA_SECTION_NODE:
336 case DOMNode::COMMENT_NODE:
352 MathMLExprParser::toString()
const 354 std::ostringstream os;
361 MathMLExprParser::dump(std::ostream& os)
const 379 static const XMLCh* DIVISION = XMLString::transcode(
"divide");
380 static const XMLCh* SUBTRACTION = XMLString::transcode(
"minus");
381 static const XMLCh* ADDITION = XMLString::transcode(
"plus");
382 static const XMLCh* MAXML = XMLString::transcode(
"max");
383 static const XMLCh* MINML = XMLString::transcode(
"min");
384 static const XMLCh* EXPONENTIATION = XMLString::transcode(
"power");
385 static const XMLCh* MULTIPLICATION = XMLString::transcode(
"times");
387 const XMLCh* nodeName = node->getNodeName();
389 return (XMLString::equals(nodeName,DIVISION) || XMLString::equals(nodeName,SUBTRACTION) ||
390 XMLString::equals(nodeName,ADDITION) || XMLString::equals(nodeName,EXPONENTIATION) ||
391 XMLString::equals(nodeName,MULTIPLICATION) || XMLString::equals(nodeName,MAXML) ||
392 XMLString::equals(nodeName,MINML));
398 static const XMLCh* APPLY = XMLString::transcode(
"apply");
399 static const XMLCh*
NUMBER = XMLString::transcode(
"cn");
400 static const XMLCh* IDENTIFIER = XMLString::transcode(
"ci");
402 const XMLCh* nodeName = node->getNodeName();
404 return (XMLString::equals(nodeName,APPLY) ||
405 XMLString::equals(nodeName,NUMBER) || XMLString::equals(nodeName,IDENTIFIER));
double toDbl(const char *str, unsigned *endidx)
static Prof::Metric::AExpr * parse(DOMNode *mathMLExpr, const Prof::Metric::Mgr &mMgr)
static Prof::Metric::AExpr * buildEvalTree(DOMNode *node, const Prof::Metric::Mgr &mMgr, bool isNum)
static bool isOperandNode(DOMNode *node)
static std::string make_string(const XMLCh *const xmlStr)
#define MathML_Throw(streamArgs)
#define NUMBER(label, num)
static bool isOperatorNode(DOMNode *node)
Metric::ADesc * metric(uint i)