hi everybody, i have this code

<code>
#include "../../es_yell_frontlite_mvc_View_RenderizarVistaXalanC.h"
#include <xalanc/Include/PlatformDefinitions.hpp>
#if defined(XALAN_CLASSIC_IOSTREAMS)
#include <iostream.h>
#include <strstream.h>
#include <fstream.h>
#else
#include <iostream>
#include <strstream>
#include <fstream>
#endif
#include <xercesc/util/PlatformUtils.hpp>
#include <xalanc/XalanTransformer/XalanTransformer.hpp>


JNIEXPORT jstring JNICALL
Java_es_yell_frontlite_mvc_View_RenderizarVistaXalanC_renderView
  (JNIEnv *env, jobject obj, jstring xml, jstring xsl) {

    jboolean blnIsCopy;
    jstring salida ;
    
    XALAN_USING_STD(cout)
    XALAN_USING_STD(endl)
    XALAN_USING_STD(cerr)
    XALAN_USING_STD(cout)
    XALAN_USING_STD(endl)
    XALAN_USING_STD(istrstream)
    XALAN_USING_STD(ofstream)
    XALAN_USING_STD(ostrstream)
    
    #if defined(XALAN_STRICT_ANSI_HEADERS)
        using std::strlen;
    #endif
    
    XALAN_USING_XERCES(XMLPlatformUtils)

    XALAN_USING_XALAN(XalanTransformer)

    // Call the static initializer for Xerces.

    XMLPlatformUtils::Initialize();

    // Initialize Xalan.
    XalanTransformer::initialize();
    {

    // Create a XalanTransformer.
        XalanTransformer theXalanTransformer;
        const char* theInputXmlDocument
=env->GetStringUTFChars(xml,&blnIsCopy);
        istrstream      theXMLStream(theInputXmlDocument);
        const char*   theInputXslDocument =
env->GetStringUTFChars(xsl,&blnIsCopy);
        istrstream      theXSLStream(theInputXslDocument);
        
        XALAN_USING_XALAN(XalanDOMString)
        XALAN_USING_XALAN(XSLTInputSource)
        XALAN_USING_XALAN(XSLTResultTarget)
        XALAN_USING_STD(streamsize) 

        XSLTInputSource         inputXSLSource(&theXSLStream);

        inputXSLSource.setSystemId(XalanDOMString("foo").c_str());

        /// Generate the XML output object.
        ostrstream  theOutputStream; 

        
         // Do the transform.
        int theResult = theXalanTransformer.transform(&theXMLStream,
inputXSLSource, theOutputStream);
        const char * cadena = theOutputStream.str();
        cout<<"ANTES---->"<<endl<<cadena<<endl;
        salida= env->NewStringUTF(cadena);
        cout<<"DESPUES---->"<<salida<<endl;
        if(theResult != 0)
        {
            cout << "StreamTransform Error: \n" <<
theXalanTransformer.getLastError()
            << endl
            << endl;
        }
        else{
            //libero memoria
            //delete bufferXML;
            //delete bufferXSL;
            theOutputStream.freeze(false);
        }
        //libero la memoria una vez que tengo en mis buffers el xml y el xsl
        env->ReleaseStringUTFChars(xml,theInputXmlDocument);
        env->ReleaseStringUTFChars(xsl,theInputXslDocument);
    }
    
    
    // Terminate Xalan...
    XalanTransformer::terminate();

// Terminate Xerces...
    XMLPlatformUtils::Terminate();
    cout<<"se acabo!!"<<endl;
    return salida;
}

</code>

This code realizes his work, which is to take the chains of characters of
the xml and the insole xsl and to realize the transformation in html. The
problem is that when the html generated by the screen goes out they go out
strange characters, something like this:



It seems as if the theOutputStream object had the transformation stored in
an internal static buffer and when I return the bulging chain it was not
finished with \n\r or worse, that this treading on memory not reserved
adequately.

I know that xml and xsl templates are correct because is being used in other
app version which uses xalanj as xslt engine.

The java class is like this:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package es.yell.frontlite.mvc.View;

//import java.io.ByteArrayOutputStream;

/**
 *
 * @author alonso
 */
public class RenderizarVistaXalanC {
        
    public native String renderView(String xml, String xsl);
}


pls help!


-- 
View this message in context: 
http://www.nabble.com/problem-extracting-output-to-screen-tp15330229p15330229.html
Sent from the Xalan - C - Users mailing list archive at Nabble.com.

Reply via email to