DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15569>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15569

XalanDocument doesnīt work as ParsedSource / stringstream doesnīt work as input after 
it has been used as input

           Summary: XalanDocument doesnīt work as ParsedSource /
                    stringstream doesnīt work as input after it has been
                    used as input
           Product: Xerces-C++
           Version: 2.1.0
          Platform: PC
        OS/Version: Windows NT/2K
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Build
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Hi,
I use MSVC 6.0 on Windows NT.
I maybe found some Bugs in your C++ API, that I didnīt understand.
It could be that iīm too stupid to understand the API, but please try 
the Source Code iīm going to attach. 
I just tried to use the Result of one Transformation for the next 
Transformation. Therefore I use an created but empty XalanDocument as Result 
Target. I take this and use it as InputSource for the next Transformation.
It didnīt work, so I decided to use stringstream instead of XalanDocument. 
Didnīt work either. I even tried to convert all to Xerces DOM_Document and 
back. Didnīt work either. I tried creating my empty XalanDocument through 
various ParserLiasion. Itīs just impossible. The only way I encountered to 
process the Output of a Transformation is to write it to a file, and use that 
file as Input. That just canīt be true? If it is like that, than please do so 
remarks in your Documentation. (if there are remarks, i didnīt find them...)

I tried to find the solution myself, but iīm not a crack...
But what makes me scratch my head about your Design, is that any InputSource 
for transformations is run through a parser... Later in the doTransform the 
XalanDocument is extracted again.

If you got any Questions, feel free to eMail me. It would be nice to get an 
reply, what was wrong (especially if iīm just too stupid..). 

Source Code:
(I Hope itīs not too long but itīs a working Testframe with Comments on what 
didnīt work, and how i got around it...)
bool func()
{
        XMLPlatformUtils::Initialize();

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


        XalanTransformer Transformer;
        XercesDOMSupport   theDOMSupport;
        XercesParserLiaison     theParserLiaison(theDOMSupport);
        int theResult=0;

        XalanDocument *pOne;
        XalanDocument *pTwo=theParserLiaison.createDocument();
        XalanDocument *pThree=theParserLiaison.createDocument();
        XalanParsedSource *pP;
        
        theResult = Transformer.parseSource("foo.xml",pP);
        if(theResult!=0)
        {
                std::cout << Transformer.getLastError() << std::endl;
                return false;
        }
        std::cout << "Parsed 1!" << std::endl;

        pOne=pP->getDocument();
        
        //------------THIS DOESNīT WORK !!!!!!!---------------------------------
----
        // theResult = Transformer.transform(pOne,"cgn_sample.cgn",pTwo); // 
dunno...
        //------------THIS WORKS !!!!!!!!!!!!!!---------------------------------
----
        theResult = Transformer.transform(*pP,"foo.xsl",pTwo); // works...
        // theResult = Transformer->transform
("dsl_sample.xml","cgn_sample.cgn",pTwo); // also works...
        if(theResult!=0)
        {
                std::cout << Transformer.getLastError() << std::endl;
                return false;
        }
        std::cout << "Transformed 1!" << std::endl;

        //------------THIS DOESNīT WORK !!!!!!!---------------------------------
----
        // theResult = Transformer->transform
(pTwo,"cgn_sample.cgn",pThree); //dunno
        //------------THIS WORKS !!!!!!!!!!!!!!---------------------------------
----
        std::ofstream out("temp.xml");
        XalanStdOutputStream                    theStream(out);
        XalanOutputStreamPrintWriter    thePrintWriter(theStream);
        FormatterToXML                  theFormatter(thePrintWriter);
        FormatterTreeWalker             theWalker(theFormatter);
        theWalker.traverse(pTwo); //if you use startDocument and endDocument 
you get 2 Headers!!!!
        out.close();
        theResult = Transformer.transform
("temp.xml","cgn_sample.cgn",pThree); //works...        
        if(theResult!=0)
        {
                std::cout << Transformer.getLastError() << std::endl;
                return false;
        }
        std::cout << "Transformed 2!" << std::endl;

        std::stringstream stream1;
        std::stringstream stream2;

        theResult = Transformer.transform
("dsl_sample.xml","cgn_sample.cgn",&stream1); //works...        
        if(theResult!=0)
        {
                std::cout << Transformer.getLastError() << std::endl;
                return false;
        }
        std::cout << "Transformed 3!" << std::endl;

        //------------THIS DOESNīT WORK !!!!!!!---------------------------------
----
        //theResult = Transformer.transform
(&stream1,"cgn_sample.cgn",&stream2); //dunno
        //------------THIS WORKS !!!!!!!!!!!!!!---------------------------------
----
        std::ofstream out2("temp2.xml");
        out2 << stream1.str().c_str();
        out2.close();
        theResult = Transformer.transform
("temp2.xml","cgn_sample.cgn",&stream2); //works...

        if(theResult!=0)
        {
                std::cout << Transformer.getLastError() << std::endl;
                return false;
        }
        std::cout << "Transformed 4!" << std::endl;

        XalanTransformer::terminate();

                // Terminate Xerces...
        XMLPlatformUtils::Terminate();

        return true;
}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to