Project

Profile

Help

Revision 339c45ee

Added by Dave Delpratt 5 months ago

Saxon/C development - fixes for testXQuery

View differences:

src/main/c/Saxon.C.API/XsltExecutable.cpp
114 114
}
115 115

  
116 116
void XsltExecutable::setInitialMatchSelection(XdmValue *_selection) {
117
    if (_selection != nullptr) {
117
    if(selection) {
118
        SaxonProcessor::sxn_environ->env->DeleteGlobalRef(selection);
119
        selection = nullptr;
120
    }
121
    if(selectionV != nullptr) {
122
	selectionV->decrementRefCount();
123
    }
124
//    if (_selection != nullptr) {
118 125
        _selection->incrementRefCount();
119 126
        selectionV = _selection;
120 127
        selection = SaxonProcessor::sxn_environ->env->NewGlobalRef(_selection->getUnderlyingValue());
121
    }
128
//    }
122 129
}
123 130

  
124 131

  
125 132
void XsltExecutable::setInitialMatchSelectionAsFile(const char *filename) {
133
    if(selection) {
134
        SaxonProcessor::sxn_environ->env->DeleteGlobalRef(selection);
135
        selection = nullptr;
136
    }
126 137
    if (filename != nullptr) {
127 138
        selection = SaxonProcessor::sxn_environ->env->NewGlobalRef(SaxonProcessor::sxn_environ->env->NewStringUTF(filename));
128 139

  
......
744 755
XdmValue *XsltExecutable::callTemplateReturningValue(const char *templateName) {
745 756

  
746 757

  
758
    if(templateName == nullptr) {
759
	std::cerr<<"template name given as null"<<std::endl;
760
	return nullptr;
761
    }
747 762
    static jmethodID ctsvmID = nullptr;
748 763
    if (ctsvmID == nullptr) {
749 764
        ctsvmID = (jmethodID) SaxonProcessor::sxn_environ->env->GetStaticMethodID(cppClass,
......
783 798
            jclass nodeClass = lookForClass(SaxonProcessor::sxn_environ->env, "net/sf/saxon/s9api/XdmNode");
784 799
            jclass functionItemClass = lookForClass(SaxonProcessor::sxn_environ->env,
785 800
                                                    "net/sf/saxon/s9api/XdmFunctionItem");
801
            jclass mapItemClass = lookForClass(SaxonProcessor::sxn_environ->env,
802
                                                    "net/sf/saxon/s9api/XdmMap");
803
            jclass arrayItemClass = lookForClass(SaxonProcessor::sxn_environ->env,
804
                                               "net/sf/saxon/s9api/XdmArray");
786 805
            XdmValue *value = nullptr;
787 806

  
788 807
            XdmItem *xdmItem = nullptr;
......
799 818
                xdmItem = new XdmFunctionItem(result);
800 819
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
801 820
                return xdmItem;
821

  
822
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, mapItemClass) == JNI_TRUE) {
823
                xdmItem = new XdmMap(result);
824
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
825
                return xdmItem;
826
            } else if (SaxonProcessor::sxn_environ->env->IsInstanceOf(result, arrayItemClass) == JNI_TRUE) {
827
                xdmItem = new XdmArray(result);
828
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
829
                return xdmItem;
802 830
            } else {
803 831
                value = new XdmValue(result, true);
804 832
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
......
887 915
                SaxonProcessor::sxn_environ->env->DeleteLocalRef(result);
888 916
                return xdmItem;
889 917
            } else {
890
                value = new XdmValue(result, true);
918
                value = new XdmValue(result);
891 919
                return value;
892 920
            }
893 921
            value = new XdmValue();

Also available in: Unified diff