Project

Profile

Help

Revision 339c45ee

Added by Dave Delpratt 5 months ago

Saxon/C development - fixes for testXQuery

View differences:

src/main/c/samples/cppTests/testXSLT30.cpp
565 565
        try {
566 566

  
567 567
            XdmValue *valuei = parMap.at(name1.str());
568
            if (valuei != NULL) {
568
            if (valuei != nullptr) {
569 569
                cout << name1.str();
570
                if (valuei->itemAt(0) != NULL)
570
                if (valuei->itemAt(0) != nullptr)
571 571
                    cout << "= " << valuei->itemAt(0)->getStringValue();
572 572
                cout << endl;
573 573
            }
......
595 595
    XsltExecutable * executable = trans->compileFromString(
596 596
            "<?xml version='1.0'?><xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'                 xmlns:xs='http://www.w3.org/2001/XMLSchema' version='3.0' exclude-result-prefixes='#all'>     <xsl:import-schema><xs:schema><xs:element name='x' type='xs:int'/></xs:schema></xsl:import-schema> <xsl:template name='main'>          <xsl:result-document validation='strict'> <x>3</x>   </xsl:result-document>    </xsl:template>    </xsl:stylesheet>");
597 597

  
598

  
599
    if(executable== nullptr) {
600
        sresult->failure++;
601
        sresult->failureList.push_back("testValidation");
602
        if (trans->exceptionOccurred()) {
603
            cerr <<"Error message: "<< trans->getErrorMessage() << endl;
604
        }
605
        trans->exceptionClear();
606
        return;
607
    }
608

  
609

  
610

  
598 611
    const char *rootValue = executable->callTemplateReturningString("main");
599 612

  
600 613

  
......
617 630
    std::cout << "testXdmNodeOutput" << std::endl;
618 631
    XsltExecutable * executable = trans->compileFromString(
619 632
            "<xsl:stylesheet version='2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'><xsl:template name='go'><a/></xsl:template></xsl:stylesheet>");
633

  
634

  
635
    if(executable== nullptr) {
636
        sresult->failure++;
637
        sresult->failureList.push_back("testXdmNodeOutput");
638
        if (trans->exceptionOccurred()) {
639
            cerr <<"Error message: "<< trans->getErrorMessage() << endl;
640
        }
641
        trans->exceptionClear();
642
        return;
643
    }
644

  
620 645
    XdmValue *rootValue = executable->callTemplateReturningValue("go");
621 646
    if (rootValue== nullptr) {
622 647
        cout << "Result is null ====== FAIL ====== " << endl;
......
811 836
    if(executable == nullptr) {
812 837
        cout << "executable is NULL" <<endl;
813 838
        if(proc->exceptionOccurred()) {
814
            cout << proc->getErrorMessage() <<endl;
839
            cout << "Error : " << proc->getErrorMessage() <<endl;
815 840

  
816 841
        }
817 842
        sresult->failure++;
818 843
        sresult->failureList.push_back("exampleParam");
844
	proc->exceptionClear();
819 845
        return;
820 846

  
821 847
    }
......
979 1005

  
980 1006
    executable->clearProperties();
981 1007

  
982
    if(result2 != NULL) {
1008
    if(result2 != nullptr) {
983 1009
        cout<<result2<<endl;
984 1010
        sresult->success++;
985 1011

  
......
991 1017
    executable->setParameter("a-param", (XdmValue*)xdmValue2);
992 1018

  
993 1019
    const char *result3 = executable->applyTemplatesReturningString();
994
    if(result3 != NULL) {
1020
    if(result3 != nullptr) {
995 1021
        cout<<"Output ="<<result3<<endl;
996 1022

  
997 1023
        sresult->success++;
......
1010 1036
    proc->setJustInTimeCompilation(true);
1011 1037

  
1012 1038
    XdmValue *result = proc->transformFileToValue("xmark100k.xml", "q12.xsl");
1013
    if (result != NULL) {
1039
    if (result != nullptr && !proc->exceptionOccurred()) {
1014 1040
        cout << "XdmNode returned" << endl;
1015 1041
        sresult->success++;
1016 1042
        delete result;
......
1018 1044
        printf("result is null \nCheck For errors:");
1019 1045
        sresult->failure++;
1020 1046
        sresult->failureList.push_back("xmarkTest1");
1021
        cerr << "xmarkTest1 cp0" << endl;
1022 1047
        if (proc->exceptionOccurred()) {
1023
            cerr << "xmarkTest1 cp1" << endl;
1024 1048
            const char * message = proc->getErrorMessage();
1025
            cerr << "xmarkTest1 cp2" << endl;
1026 1049
            if(message != nullptr) {
1027
                cerr << "xmarkTest1 cp2-1" << endl;
1028 1050
                cerr << proc->getErrorMessage() << endl;
1051
		proc->exceptionClear();
1029 1052
            } else {
1030 1053
                cerr << "Message is nullptr" << endl;
1031 1054
                SaxonProcessor::sxn_environ->env->ExceptionDescribe();
1055
		SaxonProcessor::sxn_environ->env->ExceptionClear();
1032 1056
            }
1033 1057
        }
1034
        cerr << "xmarkTest1 cp3" << endl;
1035 1058
    }
1036

  
1059
    proc->setJustInTimeCompilation(false);
1037 1060

  
1038 1061
}
1039 1062

  
......
1042 1065
void xmarkTest2(Xslt30Processor *proc, sResultCount *sresult) {
1043 1066
    cout << "Test: xmarkTest2 - XMarkbench mark test q12.xsl (JIT=true):" << endl;
1044 1067

  
1068
    proc->setJustInTimeCompilation(true);
1045 1069

  
1046 1070
    XdmValue *result = proc->transformFileToValue("xmark100k.xml", "q12.xsl");
1047
    if (result != NULL) {
1071
    if (result != nullptr && !proc->exceptionOccurred()) {
1048 1072
        cout << "XdmNode returned" << endl;
1049 1073
        sresult->success++;
1050 1074
        delete result;
......
1058 1082
            if(exception != nullptr) {
1059 1083
                const char *message = exception->getMessage();
1060 1084
                if (message != nullptr) {
1061
                    cerr << "xmarkTest2 cp2-1" << endl;
1062 1085
                    cerr << message << endl;
1086
		    proc->exceptionClear();
1063 1087
                }
1064 1088
                delete exception;
1065 1089
            } else {
1066 1090
                cerr << "Exception object is nullptr" << endl;
1067 1091
                SaxonProcessor::sxn_environ->env->ExceptionDescribe();
1092
		SaxonProcessor::sxn_environ->env->ExceptionClear();
1068 1093
            }
1069 1094
        }
1070 1095
    }
1071 1096

  
1097
    proc->setJustInTimeCompilation(false);
1072 1098

  
1073 1099
}
1074 1100

  
......
1079 1105
    proc->setJustInTimeCompilation(true);
1080 1106

  
1081 1107
    XdmValue *result = proc->transformFileToValue("xmark100k.xml", "q12.xsl");
1082
    if (result != NULL) {
1108

  
1109
    if (result != nullptr && !proc->exceptionOccurred()) {
1083 1110
        cout << "XdmNode returned" << endl;
1084 1111
        sresult->success++;
1085 1112
        delete result;
......
1093 1120
        proc->exceptionClear();
1094 1121
    }
1095 1122
    proc->clearParameters();
1123
    proc->setJustInTimeCompilation(false);
1096 1124

  
1097 1125
}
1098 1126

  
......
1139 1167

  
1140 1168
    if(trans->exceptionOccurred()) {
1141 1169
        const char *message = trans->getErrorMessage();
1142
        if (message != NULL) {
1170
        if (message != nullptr) {
1143 1171
            cout << "Error message =" << message << endl;
1144 1172
        }
1145 1173
        sresult->failure++;
......
1151 1179

  
1152 1180

  
1153 1181
    XsltExecutable * executable = trans->compileFromFile("test1.sef");
1182

  
1183
    if(executable == nullptr) {
1184
	if(trans->exceptionOccurred()) {
1185
          const char *message = trans->getErrorMessage();
1186
          if (message != nullptr) {
1187
            cout << "Error message =" << message << endl;
1188
          }
1189
          sresult->failure++;
1190
          sresult->failureList.push_back("testPackage1a");
1191
          trans->exceptionClear();
1192
    	}
1193
	return;   
1194

  
1195

  
1196
    }
1197

  
1154 1198
    executable->setInitialMatchSelectionAsFile("cat.xml");
1155 1199
    const char * output = executable->applyTemplatesReturningString();
1156 1200
    if (output== nullptr) {
......
1185 1229

  
1186 1230
    trans->compileFromStringAndSave(stylesheet, "test2.sef");
1187 1231

  
1188
    if(trans->exceptionOccurred()) {
1232
    if(trans->exceptionOccurred() || trans->getException() != nullptr) {
1189 1233
        const char *message = trans->getErrorMessage();
1190
        if (message != NULL) {
1234
        if (message != nullptr) {
1191 1235
            cout << "Error message =" << message << endl;
1192 1236
        }
1193 1237
        sresult->success++;
......
1195 1239
        return;
1196 1240

  
1197 1241
    }
1198

  
1242
    trans->exceptionClear();
1199 1243
    sresult->failure++;
1200 1244
    sresult->failureList.push_back("testPackage2_Error");
1201 1245

  

Also available in: Unified diff