Project

Profile

Help

Revision c1cc9bd8

Added by O'Neil Delpratt 5 months ago

Saxon/C bug fix to #4848 and #4847. Also some development work

View differences:

latest10/hec/Saxon.C.API/XsltExecutable.cpp
25 25
    cppClass = lookForClass(SaxonProcessor::sxn_environ->env,
26 26
                            "net/sf/saxon/option/cpp/Xslt30Processor");
27 27

  
28
    messageListenerClass = lookForClass(SaxonProcessor::sxn_environ->env,
29
                                               "net/sf/saxon/option/cpp/SaxonCMessageListener");
30

  
28 31
#ifdef DEBUG
29 32
    jmethodID debugMID = SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass, "setDebugMode", "(Z)V");
30 33
    SaxonProcessor::sxn_environ->env->CallStaticVoidMethod(cppClass, debugMID, (jboolean)true);
......
33 36
    tunnel = false;
34 37
    selection = nullptr;
35 38
    selectionV = nullptr;
39
    saxonMessageListenerObj = nullptr;
36 40
    executableObject = exObject;
37 41
    cwdXE = curr;
38 42
}
......
926 930
}
927 931

  
928 932

  
929
void XsltExecutable::setupXslMessage(bool show, const char * filename) {
930
    if (show) {
933
void XsltExecutable::setupXslMessage(bool create, const char * filename) {
934
    if (create) {
935

  
936
        static jmethodID messageID =   (jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(messageListenerClass,
937
                                                                                    "<init>",
938
                                                                                    "(Ljava/lang/String;Ljava/lang/String;)V");
939
        if (!messageID) {
940
            std::cerr << "Error: "<<"SaxonCMessageListener" << " in " <<getDllname() << " not found\n"
941
                      << std::endl;
942

  
943
        }
944

  
931 945
        if (filename == nullptr) {
932
            setProperty("m", "on");
946
            saxonMessageListenerObj = (jobject)SaxonProcessor::sxn_environ->env->NewObject(messageListenerClass, messageID,
947
                                                                                           SaxonProcessor::sxn_environ->env->NewStringUTF("-:on"));
948
            //setProperty("m", "on");
933 949
        } else {
934
            setProperty("m", filename);
950
            saxonMessageListenerObj = (jobject)SaxonProcessor::sxn_environ->env->NewObject(messageListenerClass, messageID,
951
                                                                                           SaxonProcessor::sxn_environ->env->NewStringUTF(filename));
935 952
        }
936 953
    } else {
937 954
        setProperty("m", "off");
938 955
    }
956

  
957

  
958
}
959

  
960
XdmValue * XsltExecutable::getXslMessages(){
961

  
962
    if(saxonMessageListenerObj) {
963
        static jmethodID getmessageID = (jmethodID) SaxonProcessor::sxn_environ->env->GetMethodID(messageListenerClass,
964
                                                                                                  "getXslMessages",
965
                                                                                                  "()[Lnet/sf/saxon/s9api/XdmNode;");
966
        if (!getmessageID) {
967
            std::cerr << "Error: " << getDllname() << ".getXslMessages" << " not found\n"
968
                      << std::endl;
969

  
970
        } else {
971
            jobjectArray results = (jobjectArray) (
972
                    SaxonProcessor::sxn_environ->env->CallObjectMethod(saxonMessageListenerObj, getmessageID));
973
            int sizex = SaxonProcessor::sxn_environ->env->GetArrayLength(results);
974

  
975
            if (sizex > 0) {
976
                XdmValue *value = new XdmValue();
977

  
978
                for (int p = 0; p < sizex; ++p) {
979
                    jobject resulti = SaxonProcessor::sxn_environ->env->GetObjectArrayElement(results, p);
980
                    value->addUnderlyingValue(resulti);
981
                }
982
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(results);
983
                return value;
984
            }
985
        }
986
    }
987
    return NULL;
988

  
989

  
939 990
}
940 991

  
941 992

  

Also available in: Unified diff