Annotation of parser3/src/classes/xalan-patched/XalanTransformer2.cpp, revision 1.7

1.2       parser      1: /** @file
                      2:        Parser: patched transform method to 
                      3:                1. return exceptions 
                      4:                2. pass string params
                      5:        decls.
                      6: 
                      7:        Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
                      8:        Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
                      9: 
1.7     ! paf        10:        $Id: XalanTransformer2.cpp,v 1.6 2001/10/18 11:49:02 parser Exp $
1.2       parser     11: 
                     12:        based on:
                     13: */
1.1       parser     14: /*
                     15:  * The Apache Software License, Version 1.1
                     16:  *
                     17:  *
                     18:  * Copyright (c) 2001 The Apache Software Foundation.  All rights 
                     19:  * reserved.
                     20:  *
                     21:  * Redistribution and use in source and binary forms, with or without
                     22:  * modification, are permitted provided that the following conditions
                     23:  * are met:
                     24:  *
                     25:  * 1. Redistributions of source code must retain the above copyright
                     26:  *       notice, this list of conditions and the following disclaimer. 
                     27:  *
                     28:  * 2. Redistributions in binary form must reproduce the above copyright
                     29:  *       notice, this list of conditions and the following disclaimer in
                     30:  *       the documentation and/or other materials provided with the
                     31:  *       distribution.
                     32:  *
                     33:  * 3. The end-user documentation included with the redistribution,
                     34:  *       if any, must include the following acknowledgment:  
                     35:  *              "This product includes software developed by the
                     36:  *               Apache Software Foundation (http://www.apache.org/)."
                     37:  *       Alternately, this acknowledgment may appear in the software itself,
                     38:  *       if and wherever such third-party acknowledgments normally appear.
                     39:  *
                     40:  * 4. The names "Xalan" and "Apache Software Foundation" must
                     41:  *       not be used to endorse or promote products derived from this
                     42:  *       software without prior written permission. For written 
                     43:  *       permission, please contact apache@apache.org.
                     44:  *
                     45:  * 5. Products derived from this software may not be called "Apache",
                     46:  *       nor may "Apache" appear in their name, without prior written
                     47:  *       permission of the Apache Software Foundation.
                     48:  *
                     49:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
                     50:  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     51:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
                     52:  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
                     53:  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
                     54:  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
                     55:  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
                     56:  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
                     57:  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
                     58:  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
                     59:  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     60:  * SUCH DAMAGE.
                     61:  * ====================================================================
                     62:  *
                     63:  * This software consists of voluntary contributions made by many
                     64:  * individuals on behalf of the Apache Software Foundation and was
                     65:  * originally based on software copyright (c) 1999, International
                     66:  * Business Machines, Inc., http://www.ibm.com.  For more
                     67:  * information on the Apache Software Foundation, please see
                     68:  * <http://www.apache.org/>.
                     69:  */
1.2       parser     70: 
                     71: #include "pa_config_includes.h"
                     72: #ifdef XML
                     73: 
                     74: #include "XalanTransformer2.hpp"
1.1       parser     75: 
                     76: 
                     77: 
                     78: #include <algorithm>
                     79: 
                     80: 
                     81: 
                     82: #include <sax/SAXException.hpp>
                     83: 
                     84: 
                     85: 
                     86: #include <XalanDOM/XalanDOMException.hpp>
                     87: 
                     88: 
                     89: 
                     90: #include <PlatformSupport/DOMStringHelper.hpp>
                     91: #include <PlatformSupport/DOMStringPrintWriter.hpp>
                     92: #include <PlatformSupport/XalanOutputStreamPrintWriter.hpp>
                     93: 
                     94: 
                     95: 
                     96: #include <XPath/XObjectFactoryDefault.hpp>
                     97: #include <XPath/XPathFactoryBlock.hpp>
                     98: #include <XPath/XPathFactoryDefault.hpp>
                     99: 
                    100: 
                    101: 
                    102: #include <XSLT/StylesheetConstructionContextDefault.hpp>
                    103: #include <XSLT/StylesheetExecutionContextDefault.hpp>
                    104: #include <XSLT/StylesheetRoot.hpp>
                    105: #include <XSLT/XSLTEngineImpl.hpp>
                    106: #include <XSLT/XSLTInit.hpp>
                    107: #include <XSLT/XSLTProcessorEnvSupportDefault.hpp>
                    108: 
                    109: 
                    110: 
                    111: #include <XalanSourceTree/XalanSourceTreeDOMSupport.hpp>
                    112: #include <XalanSourceTree/XalanSourceTreeParserLiaison.hpp>
                    113: 
                    114: 
                    115: 
1.2       parser    116: #include "XalanTransformer/XalanCompiledStylesheetDefault.hpp"
                    117: #include "XalanTransformer/XalanDefaultDocumentBuilder.hpp"
                    118: #include "XalanTransformer/XalanDefaultParsedSource.hpp"
                    119: #include "XalanTransformer/XalanTransformerOutputStream.hpp"
                    120: #include "XalanTransformer/XercesDOMParsedSource.hpp"
1.1       parser    121: 
                    122: 
1.6       parser    123: #include "XercesParserLiaison/XercesDOMSupport.hpp"
                    124: #include "XMLSupport/XMLParserLiaisonDefault.hpp"
                    125: 
1.1       parser    126: 
1.2       parser    127: XSLTInit*      XalanTransformer2::s_xsltInit = 0;
1.1       parser    128: 
                    129: 
                    130: 
1.2       parser    131: XalanTransformer2::XalanTransformer2():
1.1       parser    132:        m_compiledStylesheets(),
                    133:        m_parsedSources(),
                    134:        m_paramPairs(),
                    135:        m_functionPairs(),
                    136:        m_errorMessage(1, '\0'),
                    137:        m_stylesheetExecutionContext(new StylesheetExecutionContextDefault)
                    138: {
                    139: }
                    140: 
                    141: 
                    142: 
1.2       parser    143: XalanTransformer2::~XalanTransformer2()
1.1       parser    144: {
                    145: #if !defined(XALAN_NO_NAMESPACES)
                    146:        using std::for_each;
                    147: #endif
                    148: 
                    149:        // Clean up all entries in the compliledStylesheets vector.
                    150:        for_each(m_compiledStylesheets.begin(),
                    151:                         m_compiledStylesheets.end(),
                    152:                         DeleteFunctor<XalanCompiledStylesheet>());
                    153: 
                    154:        // Clean up all entries in the compliledStylesheets vector.
                    155:        for_each(m_parsedSources.begin(),
                    156:                         m_parsedSources.end(),
                    157:                         DeleteFunctor<XalanParsedSource>());
                    158: 
                    159:        for (FunctionParamPairVectorType::size_type i = 0; i < m_functionPairs.size(); ++i)
                    160:        {                       
                    161:                delete m_functionPairs[i].second;
                    162:        }
                    163: 
                    164:        m_functionPairs.clear();
                    165: 
                    166:        delete m_stylesheetExecutionContext;
                    167: }
                    168: 
                    169: 
                    170: 
                    171: void
1.2       parser    172: XalanTransformer2::initialize()
1.1       parser    173: {
                    174:        // Initialize Xalan. 
                    175:        s_xsltInit = new XSLTInit;
                    176: }
                    177: 
                    178: 
                    179: 
                    180: void
1.2       parser    181: XalanTransformer2::terminate()
1.1       parser    182: {
                    183:        // Terminate Xalan and release memory.
                    184:        delete s_xsltInit;
                    185: 
                    186:        s_xsltInit = 0;
                    187: }
                    188: 
                    189: 
                    190: 
                    191: int
1.2       parser    192: XalanTransformer2::transform(
1.1       parser    193:        const XalanParsedSource&        theParsedXML, 
                    194:        const XSLTInputSource&          theStylesheetSource,
                    195:        const XSLTResultTarget&         theResultTarget)
                    196: {
                    197: #if !defined(XALAN_NO_NAMESPACES)
                    198:        using std::for_each;
                    199: #endif
                    200: 
                    201:        int     theResult = 0;
                    202: 
                    203:        // Clear the error message.
                    204:        m_errorMessage.resize(1, '\0');
                    205: 
                    206:        // Store error messages from problem listener.
                    207:        XalanDOMString  theErrorMessage;
                    208: 
                    209:        try
                    210:        {
                    211:                // Create the helper object that is necessary for running the processor...
                    212:                XalanAutoPtr<XalanParsedSourceHelper>   theHelper(theParsedXML.createHelper());
                    213:                assert(theHelper.get() != 0);
                    214: 
                    215:                DOMSupport&                                     theDOMSupport = theHelper->getDOMSupport();
                    216: 
                    217:                XMLParserLiaison&                               theParserLiaison = theHelper->getParserLiaison();
                    218: 
                    219:                // Create some more support objects...
                    220:                XSLTProcessorEnvSupportDefault  theXSLTProcessorEnvSupport;
                    221: 
                    222:                XObjectFactoryDefault                   theXObjectFactory;
                    223: 
                    224:                XPathFactoryDefault                     theXPathFactory;
                    225: 
                    226:                // Create a processor...
                    227:                XSLTEngineImpl  theProcessor(
                    228:                                theParserLiaison,
                    229:                                theXSLTProcessorEnvSupport,
                    230:                                theDOMSupport,
                    231:                                theXObjectFactory,
                    232:                                theXPathFactory);
                    233: 
                    234:                theXSLTProcessorEnvSupport.setProcessor(&theProcessor);
                    235: 
                    236:                // Create a problem listener and send output to a XalanDOMString.
                    237:                DOMStringPrintWriter    thePrintWriter(theErrorMessage);
                    238:                
                    239:                ProblemListenerDefault  theProblemListener(&thePrintWriter);
                    240: 
                    241:                theProcessor.setProblemListener(&theProblemListener);
                    242: 
                    243:                theParserLiaison.setExecutionContext(*m_stylesheetExecutionContext);
                    244: 
                    245:                // Create a stylesheet construction context, 
                    246:                // using the stylesheet's factory support objects.
                    247:                StylesheetConstructionContextDefault    theStylesheetConstructionContext(
                    248:                                        theProcessor,
                    249:                                        theXSLTProcessorEnvSupport,
                    250:                                        theXPathFactory);
                    251: 
                    252:                // Hack used to cast away const.
                    253:                XSLTResultTarget        tempResultTarget(theResultTarget);
                    254: 
                    255:                const EnsureReset       theReset(*this);
                    256: 
                    257:                // Set up the stylesheet execution context.
                    258:                m_stylesheetExecutionContext->setXPathEnvSupport(&theXSLTProcessorEnvSupport);
                    259: 
                    260:                m_stylesheetExecutionContext->setDOMSupport(&theDOMSupport);
                    261: 
                    262:                m_stylesheetExecutionContext->setXObjectFactory(&theXObjectFactory);
                    263: 
                    264:                m_stylesheetExecutionContext->setXSLTProcessor(&theProcessor);
                    265: 
                    266:                // Set the parameters if any.
                    267:                for (ParamPairVectorType::size_type i = 0; i < m_paramPairs.size(); ++i)
                    268:                {
                    269:                        theProcessor.setStylesheetParam(
                    270:                                        m_paramPairs[i].first,
                    271:                                        m_paramPairs[i].second);
                    272:                }
                    273: 
                    274:                // Set the functions if any.
                    275:                for (FunctionParamPairVectorType::size_type f = 0; f < m_functionPairs.size(); ++f)
                    276:                {
                    277:                        theXSLTProcessorEnvSupport.installExternalFunctionLocal(
                    278:                                        m_functionPairs[f].first.getNamespace(),
                    279:                                        m_functionPairs[f].first.getLocalPart(),
                    280:                                        *(m_functionPairs[f].second));
                    281:                }
                    282: 
                    283:                // Do the transformation...
                    284:                theProcessor.process(
                    285:                                        theParsedXML.getDocument(),
                    286:                                        theStylesheetSource,
                    287:                                        tempResultTarget,
                    288:                                        theStylesheetConstructionContext,
                    289:                                        *m_stylesheetExecutionContext);
                    290:        }
                    291:        catch (XSLException& e)
                    292:        {
                    293:                if (length(theErrorMessage) != 0)
                    294:                {
                    295:                        TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
                    296:                }
                    297:                else
                    298:                {
                    299:                        TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
                    300:                }
                    301: 
                    302:                theResult = -1;         
                    303:        }
                    304:        catch (SAXException& e)
                    305:        {
                    306:                if (length(theErrorMessage) != 0)
                    307:                {
                    308:                        TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
                    309:                }
                    310:                else
                    311:                {
                    312:                        TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
                    313:                }
                    314: 
                    315:                theResult = -2;
                    316:        }
                    317:        catch (XMLException& e)
                    318:        {
                    319:                if (length(theErrorMessage) != 0)
                    320:                {
                    321:                        TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
                    322:                }
                    323:                else
                    324:                {
                    325:                        TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
                    326:                }
                    327: 
                    328:                theResult = -3;
                    329:        }
                    330:        catch(const XalanDOMException&  e)
                    331:        {
                    332:                if (length(theErrorMessage) != 0)
                    333:                {
                    334:                        TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
                    335:                }
                    336:                else
                    337:                {
                    338:                        XalanDOMString theMessage("XalanDOMException caught.  The code is ");
                    339:                        
                    340:                        append(theMessage,      LongToDOMString(long(e.getExceptionCode())));
                    341:                        append(theMessage,      XalanDOMString("."));                                            
                    342: 
                    343:                        TranscodeToLocalCodePage(theMessage, m_errorMessage, true);
                    344:                }
                    345: 
                    346:                theResult = -4;
                    347:        }
                    348: 
                    349:        return theResult;
                    350: }
                    351: 
                    352: 
                    353: 
                    354: int
1.2       parser    355: XalanTransformer2::transform(
1.1       parser    356:                        const XalanParsedSource&                theParsedXML, 
                    357:                        const XalanCompiledStylesheet*  theCompiledStylesheet,
                    358:                        const XSLTResultTarget&                 theResultTarget)
                    359: {
                    360: #if !defined(XALAN_NO_NAMESPACES)
                    361:        using std::for_each;
                    362: #endif
                    363: 
                    364:        int     theResult = 0;
                    365: 
                    366:        // Clear the error message.
                    367:        m_errorMessage.resize(1, '\0');
                    368: 
                    369:        // Store error messages from problem listener.
                    370:        XalanDOMString  theErrorMessage;
                    371: 
                    372:        try
                    373:        {
                    374:                // Create the helper object that is necessary for running the processor...
                    375:                XalanAutoPtr<XalanParsedSourceHelper>   theHelper(theParsedXML.createHelper());
                    376:                assert(theHelper.get() != 0);
                    377: 
                    378:                DOMSupport&                                     theDOMSupport = theHelper->getDOMSupport();
                    379: 
                    380:                XMLParserLiaison&                               theParserLiaison = theHelper->getParserLiaison();
                    381: 
                    382:                // Create some more support objects...
                    383:                XSLTProcessorEnvSupportDefault  theXSLTProcessorEnvSupport;
                    384: 
                    385:                XObjectFactoryDefault                   theXObjectFactory;
                    386: 
                    387:                XPathFactoryDefault                     theXPathFactory;
                    388: 
                    389:                // Create a processor...
                    390:                XSLTEngineImpl  theProcessor(
                    391:                                theParserLiaison,
                    392:                                theXSLTProcessorEnvSupport,
                    393:                                theDOMSupport,
                    394:                                theXObjectFactory,
                    395:                                theXPathFactory);
                    396: 
                    397:                theXSLTProcessorEnvSupport.setProcessor(&theProcessor);
                    398: 
                    399:                // Create a problem listener and send output to a XalanDOMString.
                    400:                DOMStringPrintWriter    thePrintWriter(theErrorMessage);
                    401:                
                    402:                ProblemListenerDefault  theProblemListener(&thePrintWriter);
                    403: 
                    404:                theProcessor.setProblemListener(&theProblemListener);
                    405: 
                    406:                // Since the result target is not const in our
                    407:                // internal intefaces, we'll pass in a local copy
                    408:                // of the one provided...
                    409:                XSLTResultTarget        tempResultTarget(theResultTarget);
                    410: 
                    411:                const EnsureReset       theReset(*this);
                    412: 
                    413:                // Set up the stylesheet execution context.
                    414:                m_stylesheetExecutionContext->setXPathEnvSupport(&theXSLTProcessorEnvSupport);
                    415: 
                    416:                m_stylesheetExecutionContext->setDOMSupport(&theDOMSupport);
                    417: 
                    418:                m_stylesheetExecutionContext->setXObjectFactory(&theXObjectFactory);
                    419: 
                    420:                m_stylesheetExecutionContext->setXSLTProcessor(&theProcessor);
                    421:                
                    422:                // Set the compiled stylesheet.
                    423:                m_stylesheetExecutionContext->setStylesheetRoot(theCompiledStylesheet->getStylesheetRoot());
                    424: 
                    425:                // Set the parameters if any.
                    426:                for (ParamPairVectorType::size_type i = 0; i < m_paramPairs.size(); ++i)
                    427:                {
                    428:                        theProcessor.setStylesheetParam(
                    429:                                        m_paramPairs[i].first,
                    430:                                        m_paramPairs[i].second);
                    431:                }
                    432: 
                    433:                // Set the functions if any.
                    434:                for (FunctionParamPairVectorType::size_type f = 0; f < m_functionPairs.size(); ++f)
                    435:                {
                    436:                        theXSLTProcessorEnvSupport.installExternalFunctionLocal(
                    437:                                        m_functionPairs[f].first.getNamespace(),
                    438:                                        m_functionPairs[f].first.getLocalPart(),
                    439:                                        *(m_functionPairs[f].second));
                    440:                }
                    441: 
                    442:                // Do the transformation...
                    443:                theProcessor.process(
                    444:                                        theParsedXML.getDocument(),     
                    445:                                        tempResultTarget,                                       
                    446:                                        *m_stylesheetExecutionContext);
                    447:        }
                    448:        catch (XSLException& e)
                    449:        {
                    450:                if (length(theErrorMessage) != 0)
                    451:                {
                    452:                        TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
                    453:                }
                    454:                else
                    455:                {
                    456:                        TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
                    457:                }
                    458: 
                    459:                theResult = -1;         
                    460:        }
                    461:        catch (SAXException& e)
                    462:        {
                    463:                if (length(theErrorMessage) != 0)
                    464:                {
                    465:                        TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
                    466:                }
                    467:                else
                    468:                {
                    469:                        TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
                    470:                }
                    471: 
                    472:                theResult = -2;
                    473:        }
                    474:        catch (XMLException& e)
                    475:        {
                    476:                if (length(theErrorMessage) != 0)
                    477:                {
                    478:                        TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
                    479:                }
                    480:                else
                    481:                {
                    482:                        TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
                    483:                }
                    484: 
                    485:                theResult = -3;
                    486:        }
                    487:        catch(const XalanDOMException&  e)
                    488:        {
                    489:                if (length(theErrorMessage) != 0)
                    490:                {
                    491:                        TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
                    492:                }
                    493:                else
                    494:                {
                    495:                        XalanDOMString theMessage("XalanDOMException caught.  The code is ");
                    496:                        
                    497:                        append(theMessage,      LongToDOMString(long(e.getExceptionCode())));
                    498:                        append(theMessage,      XalanDOMString("."));                                            
                    499: 
                    500:                        TranscodeToLocalCodePage(theMessage, m_errorMessage, true);
                    501:                }
                    502: 
                    503:                theResult = -4;
                    504:        }
                    505: 
                    506:        return theResult;
                    507: }
                    508: 
                    509: 
                    510: 
                    511: int
1.2       parser    512: XalanTransformer2::transform(
1.1       parser    513:                        const XSLTInputSource&                  theInputSource, 
                    514:                        const XalanCompiledStylesheet*  theCompiledStylesheet,
                    515:                        const XSLTResultTarget&                 theResultTarget)
                    516: {
                    517:        const XalanParsedSource*        theParsedSource = 0;
                    518:  
                    519:        const int       theResult = parseSource(theInputSource, theParsedSource);
                    520:  
                    521:        if (theResult != 0)
                    522:        {
                    523:                return theResult;
                    524:        }
                    525:        else
                    526:        {
                    527:                assert(theParsedSource != 0);
                    528:  
                    529:                // Make sure the parsed source is destroyed when
                    530:                // the transformation is finished...
                    531:                EnsureDestroyParsedSource       theGuard(*this, theParsedSource);
                    532: 
                    533:                // Do the transformation...
                    534:                return transform(
                    535:                                                *theParsedSource,
                    536:                                                theCompiledStylesheet,
                    537:                                                theResultTarget);
                    538:        }
                    539: }
                    540: 
                    541: int
1.2       parser    542: XalanTransformer2::transform(
1.1       parser    543:        const XSLTInputSource&          theInputSource, 
                    544:        const XSLTInputSource&          theStylesheetSource,
                    545:        const XSLTResultTarget&         theResultTarget)
                    546: {
                    547:        // Parse the source document.
                    548:        const XalanParsedSource*        theParsedSource = 0;
                    549: 
                    550:        const int       theResult = parseSource(theInputSource, theParsedSource);
                    551: 
                    552:        if (theResult != 0)
                    553:        {
                    554:                return theResult;
                    555:        }
                    556:        else
                    557:        {
                    558:                assert(theParsedSource != 0);
                    559: 
                    560:                // Make sure the parsed source is destroyed when
                    561:                // the transformation is finished...
                    562:                EnsureDestroyParsedSource       theGuard(*this, theParsedSource);
                    563: 
                    564:                // Do the transformation...
                    565:                return transform(
                    566:                                                *theParsedSource,
                    567:                                                theStylesheetSource,
                    568:                                                theResultTarget);
                    569:        }
                    570: }
                    571: 
                    572: 
                    573: 
                    574: int
1.2       parser    575: XalanTransformer2::transform(
1.1       parser    576:                        const XSLTInputSource&          theInputSource,                 
                    577:                        const XSLTResultTarget&         theResultTarget)
                    578: {
                    579:        // Do the transformation...
                    580:        return transform(
                    581:                                        theInputSource, 
                    582:                                        XSLTInputSource(),
                    583:                                        theResultTarget);
                    584: }
                    585: 
                    586: 
                    587: 
                    588: int
1.2       parser    589: XalanTransformer2::transform(
1.1       parser    590:                        const XSLTInputSource&  theInputSource, 
                    591:                        const XSLTInputSource&  theStylesheetSource,
                    592:                        void*                                   theOutputHandle, 
                    593:                        XalanOutputHandlerType  theOutputHandler,
                    594:                        XalanFlushHandlerType   theFlushHandler)
                    595: {
                    596:        // Set to output target to the callback 
                    597:        XalanTransformerOutputStream    theOutputStream(theOutputHandle, theOutputHandler, theFlushHandler);
                    598: 
                    599:        XalanOutputStreamPrintWriter    thePrintWriter(theOutputStream);
                    600: 
                    601:        XSLTResultTarget                                theResultTarget(&thePrintWriter);
                    602: 
                    603:        // Do the transformation...
                    604:        return transform(
                    605:                                        theInputSource, 
                    606:                                        theStylesheetSource,
                    607:                                        theResultTarget);
                    608: }
                    609: 
                    610: 
                    611: 
                    612: int
1.2       parser    613: XalanTransformer2::transform(
1.1       parser    614:                        const XalanParsedSource&                theParsedSource, 
                    615:                        const XalanCompiledStylesheet*  theCompiledStylesheet,
                    616:                        void*                                                   theOutputHandle, 
                    617:                        XalanOutputHandlerType                  theOutputHandler,
                    618:                        XalanFlushHandlerType                   theFlushHandler)
                    619: {
                    620:        // Set to output target to the callback 
                    621:        XalanTransformerOutputStream    theOutputStream(theOutputHandle, theOutputHandler, theFlushHandler);
                    622: 
                    623:        XalanOutputStreamPrintWriter    thePrintWriter(theOutputStream);
                    624: 
                    625:        XSLTResultTarget                                theResultTarget(&thePrintWriter);
                    626: 
                    627:        // Do the transformation...
                    628:        return transform(
                    629:                                        theParsedSource,
                    630:                                        theCompiledStylesheet,
                    631:                                        theResultTarget);
                    632: }
                    633: 
                    634: 
                    635: 
                    636: int
1.2       parser    637: XalanTransformer2::transform(
1.1       parser    638:                        const XSLTInputSource&          theInputSource,                 
                    639:                        void*                                           theOutputHandle, 
                    640:                        XalanOutputHandlerType          theOutputHandler,
                    641:                        XalanFlushHandlerType           theFlushHandler)
                    642: {
                    643:        // Set to output target to the callback 
                    644:        XalanTransformerOutputStream    theOutputStream(theOutputHandle, theOutputHandler, theFlushHandler);
                    645: 
                    646:        XalanOutputStreamPrintWriter    thePrintWriter(theOutputStream);
                    647: 
                    648:        XSLTResultTarget                                theResultTarget(&thePrintWriter);
                    649: 
                    650:        // Do the transformation...
                    651:        return transform(
                    652:                                        theInputSource, 
                    653:                                        XSLTInputSource(),
                    654:                                        theResultTarget);
                    655: }
                    656: 
                    657: 
                    658: 
                    659: int
1.2       parser    660: XalanTransformer2::compileStylesheet(
1.1       parser    661:                        const XSLTInputSource&                          theStylesheetSource,
                    662:                        const XalanCompiledStylesheet*&         theCompiledStylesheet)
                    663: {
                    664:        // Clear the error message.
                    665:        m_errorMessage.resize(1, '\0');
                    666: 
                    667:        // Store error messages from problem listener.
                    668:        XalanDOMString  theErrorMessage;
                    669: 
                    670:        int                     theResult = 0;
                    671: 
                    672:        try
                    673:        {
                    674:                // Create some support objects that are necessary for running the processor...
                    675:                XalanSourceTreeDOMSupport               theDOMSupport;
                    676: 
                    677:                XalanSourceTreeParserLiaison    theParserLiaison(theDOMSupport);
                    678: 
                    679:                // Hook the two together...
                    680:                theDOMSupport.setParserLiaison(&theParserLiaison);
                    681: 
                    682:                // Create some more support objects...
                    683:                XSLTProcessorEnvSupportDefault  theXSLTProcessorEnvSupport;
                    684: 
                    685:                XObjectFactoryDefault                   theXObjectFactory;
                    686: 
                    687:                XPathFactoryDefault                     theXPathFactory;
                    688: 
                    689:                // Create a processor...
                    690:                XSLTEngineImpl  theProcessor(
                    691:                                theParserLiaison,
                    692:                                theXSLTProcessorEnvSupport,
                    693:                                theDOMSupport,
                    694:                                theXObjectFactory,
                    695:                                theXPathFactory);
                    696: 
                    697:                // Create a problem listener and send output to a XalanDOMString.
                    698:                DOMStringPrintWriter    thePrintWriter(theErrorMessage);
                    699: 
                    700:                ProblemListenerDefault  theProblemListener(&thePrintWriter);
                    701: 
                    702:                theProcessor.setProblemListener(&theProblemListener);
                    703: 
                    704:                // Create a new XalanCompiledStylesheet.
                    705:                theCompiledStylesheet =
                    706:                        new XalanCompiledStylesheetDefault(
                    707:                                                theStylesheetSource,
                    708:                                                theXSLTProcessorEnvSupport,
                    709:                                                theProcessor);
                    710: 
                    711:                // Store it in a vector.
                    712:                m_compiledStylesheets.push_back(theCompiledStylesheet);
                    713:        }
                    714:        catch (XSLException& e)
                    715:        {
                    716:                if (length(theErrorMessage) != 0)
                    717:                {
                    718:                        TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
                    719:                }
                    720:                else
                    721:                {
                    722:                        TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
                    723:                }
                    724: 
                    725:                theResult = -1;
                    726:        }
                    727:        catch (SAXException& e)
                    728:        {
                    729:                if (length(theErrorMessage) != 0)
                    730:                {
                    731:                        TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
                    732:                }
                    733:                else
                    734:                {
                    735:                        TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
                    736:                }
                    737: 
                    738:                theResult = -2;
                    739:        }
                    740:        catch (XMLException& e)
                    741:        {
                    742:                if (length(theErrorMessage) != 0)
                    743:                {
                    744:                        TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
                    745:                }
                    746:                else
                    747:                {
                    748:                        TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
                    749:                }
                    750: 
                    751:                theResult = -3;
                    752:        }
                    753:        catch(const XalanDOMException&  e)
                    754:        {
                    755:                if (length(theErrorMessage) != 0)
                    756:                {
                    757:                        TranscodeToLocalCodePage(theErrorMessage, m_errorMessage, true);
                    758:                }
                    759:                else
                    760:                {
                    761:                        XalanDOMString theMessage("XalanDOMException caught.  The code is ");
                    762: 
                    763:                        append(theMessage,      LongToDOMString(long(e.getExceptionCode())));
                    764: 
                    765:                        append(theMessage,      XalanDOMString("."));
                    766: 
                    767:                        TranscodeToLocalCodePage(theMessage, m_errorMessage, true);
                    768:                }
                    769: 
                    770:                theResult = -4;
                    771:        }
                    772: 
                    773:        return theResult;
                    774: }
                    775: 
1.2       parser    776: void
                    777: XalanTransformer2::compileStylesheet2(
                    778:                        const XSLTInputSource&                          theStylesheetSource,
                    779:                        const XalanCompiledStylesheet*&         theCompiledStylesheet) // PAF@design.ru
                    780: {
                    781:        // Clear the error message.
                    782:        m_errorMessage.resize(1, '\0');
                    783: 
                    784:        // Store error messages from problem listener.
                    785: //     XalanDOMString  theErrorMessage;
                    786: 
                    787:        int                     theResult = 0;
                    788: 
                    789:                // Create some support objects that are necessary for running the processor...
                    790:                XalanSourceTreeDOMSupport               theDOMSupport;
                    791: 
                    792:                XalanSourceTreeParserLiaison    theParserLiaison(theDOMSupport);
                    793: 
                    794:                // Hook the two together...
                    795:                theDOMSupport.setParserLiaison(&theParserLiaison);
                    796: 
                    797:                // Create some more support objects...
                    798:                XSLTProcessorEnvSupportDefault  theXSLTProcessorEnvSupport;
                    799: 
                    800:                XObjectFactoryDefault                   theXObjectFactory;
                    801: 
                    802:                XPathFactoryDefault                     theXPathFactory;
                    803: 
                    804:                // Create a processor...
                    805:                XSLTEngineImpl  theProcessor(
                    806:                                theParserLiaison,
                    807:                                theXSLTProcessorEnvSupport,
                    808:                                theDOMSupport,
                    809:                                theXObjectFactory,
                    810:                                theXPathFactory);
                    811: 
                    812:                // Create a problem listener and send output to a XalanDOMString.
                    813: //             DOMStringPrintWriter    thePrintWriter(theErrorMessage);
                    814: 
                    815: //             ProblemListenerDefault  theProblemListener(&thePrintWriter);
                    816: 
                    817: //             theProcessor.setProblemListener(&theProblemListener);
                    818: 
                    819:                // Create a new XalanCompiledStylesheet.
                    820:                theCompiledStylesheet =
                    821:                        new XalanCompiledStylesheetDefault(
                    822:                                                theStylesheetSource,
                    823:                                                theXSLTProcessorEnvSupport,
                    824:                                                theProcessor);
                    825: 
                    826:                // Store it in a vector.
                    827:                m_compiledStylesheets.push_back(theCompiledStylesheet);
                    828: }
                    829: 
1.1       parser    830: 
                    831: 
                    832: int
1.2       parser    833: XalanTransformer2::destroyStylesheet(const XalanCompiledStylesheet*    theStylesheet)
1.1       parser    834: {
                    835: #if !defined(XALAN_NO_NAMESPACES)
                    836:        using std::find;
                    837: #endif
                    838: 
                    839:        const CompiledStylesheetPtrVectorType::iterator         i =
                    840:                find(
                    841:                        m_compiledStylesheets.begin(),
                    842:                        m_compiledStylesheets.end(),
                    843:                        theStylesheet);
                    844: 
                    845:        if (i == m_compiledStylesheets.end())
                    846:        {
                    847:                const char* const       theStylesheetErrorMessage =
                    848:                                "An invalid compiled stylesheet was provided.";
                    849: 
                    850:                const unsigned int      theLength =
                    851:                        length(theStylesheetErrorMessage);
                    852: 
                    853:                m_errorMessage.resize(theLength + 1, '\0');
                    854: 
                    855:                strncpy(&*m_errorMessage.begin(), theStylesheetErrorMessage, theLength);
                    856: 
                    857:                return -1;
                    858:        }
                    859:        else
                    860:        {
                    861:                m_compiledStylesheets.erase(i);
                    862: 
                    863: #if defined(XALAN_CANNOT_DELETE_CONST)
                    864:                delete (XalanCompiledStylesheet*) theStylesheet;
                    865: #else
                    866:                delete theStylesheet;
                    867: #endif
                    868: 
                    869:                return 0;
                    870:        }
                    871: }
                    872: 
                    873: 
                    874: 
                    875: int
1.2       parser    876: XalanTransformer2::parseSource(
1.1       parser    877:                        const XSLTInputSource&          theInputSource,
                    878:                        const XalanParsedSource*&       theParsedSource,
                    879:                        bool                                            useXercesDOM)
                    880: {
                    881:        // Clear the error message.
                    882:        m_errorMessage.clear();
                    883:        m_errorMessage.push_back(0);
                    884: 
                    885:        int theResult = 0;
                    886: 
                    887:        try
                    888:        {
1.4       parser    889:                //if(useXercesDOM == true)
1.1       parser    890:                {
                    891:                        theParsedSource = new XercesDOMParsedSource(theInputSource);
                    892:                }
1.4       parser    893:                /*else
1.1       parser    894:                {
                    895:                        theParsedSource = new XalanDefaultParsedSource(theInputSource);
1.4       parser    896:                }*/
1.1       parser    897: 
                    898:                // Store it in a vector.
                    899:                m_parsedSources.push_back(theParsedSource);
                    900:        }
                    901:        catch (XSLException& e)
                    902:        {
                    903:                TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
                    904: 
                    905:                theResult = -1;
                    906:        }
                    907:        catch (SAXException& e)
                    908:        {
                    909:                TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
                    910: 
                    911:                theResult = -2;
                    912:        }
                    913:        catch (XMLException& e)
                    914:        {
                    915:                TranscodeToLocalCodePage(e.getMessage(), m_errorMessage, true);
                    916: 
                    917:                theResult = -3;
                    918:        }
                    919:        catch(const XalanDOMException&  e)
                    920:        {
                    921:                XalanDOMString theMessage("XalanDOMException caught.  The code is ");
                    922:                        
                    923:                append(theMessage,      LongToDOMString(long(e.getExceptionCode())));
                    924: 
                    925:                append(theMessage,      XalanDOMString("."));                                            
                    926: 
                    927:                TranscodeToLocalCodePage(theMessage, m_errorMessage, true);
                    928: 
                    929:                theResult = -3;
                    930:        }
                    931: 
                    932:        return theResult;
                    933: }
                    934: 
                    935: 
                    936: 
                    937: int
1.2       parser    938: XalanTransformer2::destroyParsedSource(const XalanParsedSource*        theParsedSource)
1.1       parser    939: {
                    940: #if !defined(XALAN_NO_NAMESPACES)
                    941:        using std::find;
                    942: #endif
                    943: 
                    944:        const ParsedSourcePtrVectorType::iterator       i =
                    945:                find(
                    946:                        m_parsedSources.begin(),
                    947:                        m_parsedSources.end(),
                    948:                        theParsedSource);
                    949: 
                    950:        if (i == m_parsedSources.end())
                    951:        {
                    952:                const char* const       theParsedSourceErrorMessage =
                    953:                                "An invalid parsed source was provided.";
                    954: 
                    955:                const unsigned int      theLength =
                    956:                        length(theParsedSourceErrorMessage);
                    957: 
                    958:                m_errorMessage.resize(theLength + 1, '\0');
                    959: 
                    960:                strncpy(&*m_errorMessage.begin(), theParsedSourceErrorMessage, theLength);
                    961: 
                    962:                return -1;
                    963:        }
                    964:        else
                    965:        {
                    966:                m_parsedSources.erase(i);
                    967: 
                    968: #if defined(XALAN_CANNOT_DELETE_CONST)
                    969:                delete (XalanCompiledStylesheet*) theParsedSource;
                    970: #else
                    971:                delete theParsedSource;
                    972: #endif
                    973: 
                    974:                return 0;
                    975:        }
                    976: }
                    977: 
                    978: 
                    979: 
                    980: void
1.2       parser    981: XalanTransformer2::setStylesheetParam(
1.1       parser    982:                        const XalanDOMString&   key,
                    983:                        const XalanDOMString&   expression)
                    984: {
                    985:        // Store the stylesheet parameter in a vector.
                    986:        m_paramPairs.push_back(ParamPairType(key,  expression));
                    987: }
                    988: 
                    989: XalanDocumentBuilder*
1.2       parser    990: XalanTransformer2::createDocumentBuilder()
1.1       parser    991: {
                    992:        m_parsedSources.reserve(m_parsedSources.size() + 1);
                    993: 
                    994:        XalanDocumentBuilder* const     theNewBuilder = new XalanDefaultDocumentBuilder;
                    995: 
                    996:        m_parsedSources.push_back(theNewBuilder);
                    997: 
                    998:        return theNewBuilder;
                    999: }
                   1000: 
                   1001: 
                   1002: 
                   1003: void
1.2       parser   1004: XalanTransformer2::destroyDocumentBuilder(XalanDocumentBuilder*        theDocumentBuilder)
1.1       parser   1005: {
                   1006:        destroyParsedSource(theDocumentBuilder);
                   1007: }
                   1008: 
                   1009: 
                   1010: 
                   1011: void
1.2       parser   1012: XalanTransformer2::installExternalFunction(
1.1       parser   1013:                        const XalanDOMString&   theNamespace,
                   1014:                        const XalanDOMString&   functionName,
                   1015:                        const Function&                 function)
                   1016: {
                   1017:        m_functionPairs.push_back(FunctionPairType(XalanQNameByValue(theNamespace, functionName), function.clone()));
                   1018: }
                   1019: 
                   1020: 
                   1021: 
                   1022: void
1.2       parser   1023: XalanTransformer2::installExternalFunctionGlobal(
1.1       parser   1024:                        const XalanDOMString&   theNamespace,
                   1025:                        const XalanDOMString&   functionName,
                   1026:                        const Function&                 function)
                   1027: {
                   1028:        XSLTProcessorEnvSupportDefault::installExternalFunctionGlobal(
                   1029:                        theNamespace,
                   1030:                        functionName,
                   1031:                        function);
                   1032: }
                   1033: 
                   1034: 
                   1035: 
                   1036: void
1.2       parser   1037: XalanTransformer2::uninstallExternalFunction(
1.1       parser   1038:                        const XalanDOMString&   theNamespace,
                   1039:                        const XalanDOMString&   functionName)
                   1040: {
                   1041:        for (FunctionParamPairVectorType::size_type i = 0; i < m_functionPairs.size(); ++i)
                   1042:        {
                   1043:                if(XalanQNameByReference(theNamespace, functionName).equals(m_functionPairs[i].first))
                   1044:                {
                   1045:                        delete m_functionPairs[i].second;
                   1046: 
                   1047:                        m_functionPairs.erase(m_functionPairs.begin() + i);     
                   1048:                }
                   1049:        }       
                   1050: }
                   1051: 
                   1052: 
                   1053: 
                   1054: void
1.2       parser   1055: XalanTransformer2::uninstallExternalFunctionGlobal(
1.1       parser   1056:                        const XalanDOMString&   theNamespace,
                   1057:                        const XalanDOMString&   functionName)
                   1058: {
                   1059:        XSLTProcessorEnvSupportDefault::uninstallExternalFunctionGlobal(
                   1060:                        theNamespace,
                   1061:                        functionName);
                   1062: }
                   1063: 
                   1064: 
                   1065: 
                   1066: 
                   1067: const char*
1.2       parser   1068: XalanTransformer2::getLastError() const
1.1       parser   1069: {
                   1070:        return &m_errorMessage[0]; 
                   1071: }
                   1072: 
                   1073: 
                   1074: 
                   1075: void
1.2       parser   1076: XalanTransformer2::reset()
1.1       parser   1077: {
                   1078:        try
                   1079:        {
                   1080:                // Reset objects.
                   1081:                m_stylesheetExecutionContext->setXPathEnvSupport(0);
                   1082: 
                   1083:                m_stylesheetExecutionContext->setDOMSupport(0);
                   1084:                
                   1085:                m_stylesheetExecutionContext->setXObjectFactory(0);
                   1086:                
                   1087:                m_stylesheetExecutionContext->setXSLTProcessor(0);
                   1088: 
                   1089:                m_stylesheetExecutionContext->reset();
                   1090: 
                   1091:                // Clear the ParamPairVectorType.
                   1092:                m_paramPairs.clear();
                   1093:        }
                   1094:        catch(...)
                   1095:        {
                   1096:        }
                   1097: }
                   1098: 
                   1099: 
                   1100: 
                   1101: 
1.2       parser   1102: XalanTransformer2::EnsureReset::~EnsureReset()
1.1       parser   1103: {
                   1104:        m_transformer.m_stylesheetExecutionContext->reset();
                   1105: 
                   1106:        m_transformer.reset();
                   1107: }
1.2       parser   1108: 
                   1109: // PAF@design.ru
1.7     ! paf      1110: 
1.2       parser   1111: void
                   1112: XalanTransformer2::transform2(
                   1113:                        const XalanParsedSource&                theParsedXML, 
                   1114:                        const XalanCompiledStylesheet*  theCompiledStylesheet,
                   1115:                        const XSLTResultTarget&                 theResultTarget)
                   1116: {
                   1117: #if !defined(XALAN_NO_NAMESPACES)
                   1118:        using std::for_each;
                   1119: #endif
                   1120: 
                   1121:        // Create the helper object that is necessary for running the processor...
                   1122:        XalanAutoPtr<XalanParsedSourceHelper>   theHelper(theParsedXML.createHelper());
                   1123:        assert(theHelper.get() != 0);
                   1124: 
                   1125:        DOMSupport&                                     theDOMSupport = theHelper->getDOMSupport();
                   1126: 
                   1127:        XMLParserLiaison&                               theParserLiaison = theHelper->getParserLiaison();
                   1128: 
                   1129:        // Create some more support objects...
                   1130:        XSLTProcessorEnvSupportDefault  theXSLTProcessorEnvSupport;
                   1131: 
                   1132:        XObjectFactoryDefault                   theXObjectFactory;
                   1133: 
                   1134:        XPathFactoryDefault                     theXPathFactory;
                   1135: 
                   1136:        // Create a processor...
                   1137:        XSLTEngineImpl  theProcessor(
                   1138:                        theParserLiaison,
                   1139:                        theXSLTProcessorEnvSupport,
                   1140:                        theDOMSupport,
                   1141:                        theXObjectFactory,
                   1142:                        theXPathFactory);
                   1143: 
                   1144:        theXSLTProcessorEnvSupport.setProcessor(&theProcessor);
                   1145: 
                   1146:        // Since the result target is not const in our
                   1147:        // internal intefaces, we'll pass in a local copy
                   1148:        // of the one provided...
                   1149:        XSLTResultTarget        tempResultTarget(theResultTarget);
                   1150: 
                   1151:        const EnsureReset       theReset(*this);
                   1152: 
                   1153:        // Set up the stylesheet execution context.
                   1154:        m_stylesheetExecutionContext->setXPathEnvSupport(&theXSLTProcessorEnvSupport);
                   1155: 
                   1156:        m_stylesheetExecutionContext->setDOMSupport(&theDOMSupport);
                   1157: 
                   1158:        m_stylesheetExecutionContext->setXObjectFactory(&theXObjectFactory);
                   1159: 
                   1160:        m_stylesheetExecutionContext->setXSLTProcessor(&theProcessor);
                   1161:        
                   1162:        // Set the compiled stylesheet.
                   1163:        m_stylesheetExecutionContext->setStylesheetRoot(theCompiledStylesheet->getStylesheetRoot());
                   1164: 
                   1165:        // Set the parameters if any.
                   1166:        for (ParamPairVectorType::size_type i = 0; i < m_paramPairs.size(); ++i)
                   1167:        {
                   1168:                theProcessor.setStylesheetParam(
                   1169:                                m_paramPairs[i].first,
                   1170:                                theXObjectFactory.createString(m_paramPairs[i].second)); /// PAF
                   1171:        }
                   1172: 
                   1173:        // Set the functions if any.
                   1174:        for (FunctionParamPairVectorType::size_type f = 0; f < m_functionPairs.size(); ++f)
                   1175:        {
                   1176:                theXSLTProcessorEnvSupport.installExternalFunctionLocal(
                   1177:                                m_functionPairs[f].first.getNamespace(),
                   1178:                                m_functionPairs[f].first.getLocalPart(),
                   1179:                                *(m_functionPairs[f].second));
                   1180:        }
                   1181: 
                   1182:        // Do the transformation...
                   1183:        theProcessor.process(
                   1184:                                theParsedXML.getDocument(),     
                   1185:                                tempResultTarget,                                       
                   1186:                                *m_stylesheetExecutionContext);
                   1187: }
1.7     ! paf      1188: 
        !          1189: 
1.5       parser   1190: void
1.6       parser   1191: XalanTransformer2::transform2(
1.7     ! paf      1192:                        XalanDocument&          theDocument, 
1.5       parser   1193:                        const XalanCompiledStylesheet*  theCompiledStylesheet,
                   1194:                        const XSLTResultTarget&                 theResultTarget)
                   1195: {
                   1196: #if !defined(XALAN_NO_NAMESPACES)
                   1197:        using std::for_each;
                   1198: #endif
                   1199: 
1.6       parser   1200:        XercesDOMSupport                                        theDOMSupport;
1.5       parser   1201: 
1.6       parser   1202:        XercesParserLiaison  theParserLiaison(theDOMSupport);
1.5       parser   1203: 
                   1204:        // Create some more support objects...
                   1205:        XSLTProcessorEnvSupportDefault  theXSLTProcessorEnvSupport;
                   1206: 
                   1207:        XObjectFactoryDefault                   theXObjectFactory;
                   1208: 
                   1209:        XPathFactoryDefault                     theXPathFactory;
                   1210: 
                   1211:        // Create a processor...
                   1212:        XSLTEngineImpl  theProcessor(
                   1213:                        theParserLiaison,
                   1214:                        theXSLTProcessorEnvSupport,
                   1215:                        theDOMSupport,
                   1216:                        theXObjectFactory,
                   1217:                        theXPathFactory);
                   1218: 
                   1219:        theXSLTProcessorEnvSupport.setProcessor(&theProcessor);
                   1220: 
                   1221:        // Create a problem listener and send output to a XalanDOMString.
                   1222:        //DOMStringPrintWriter  thePrintWriter(theErrorMessage);
                   1223:        
                   1224:        //ProblemListenerDefault        theProblemListener(&thePrintWriter);
                   1225: 
                   1226:        //theProcessor.setProblemListener(&theProblemListener);
                   1227: 
                   1228:        // Since the result target is not const in our
                   1229:        // internal intefaces, we'll pass in a local copy
                   1230:        // of the one provided...
                   1231:        XSLTResultTarget        tempResultTarget(theResultTarget);
                   1232: 
                   1233:        const EnsureReset       theReset(*this);
                   1234: 
                   1235:        // Set up the stylesheet execution context.
                   1236:        m_stylesheetExecutionContext->setXPathEnvSupport(&theXSLTProcessorEnvSupport);
                   1237: 
                   1238:        m_stylesheetExecutionContext->setDOMSupport(&theDOMSupport);
                   1239: 
                   1240:        m_stylesheetExecutionContext->setXObjectFactory(&theXObjectFactory);
                   1241: 
                   1242:        m_stylesheetExecutionContext->setXSLTProcessor(&theProcessor);
                   1243:        
                   1244:        // Set the compiled stylesheet.
                   1245:        m_stylesheetExecutionContext->setStylesheetRoot(theCompiledStylesheet->getStylesheetRoot());
                   1246: 
                   1247:        // Set the parameters if any.
                   1248:        for (ParamPairVectorType::size_type i = 0; i < m_paramPairs.size(); ++i)
                   1249:        {
                   1250:                theProcessor.setStylesheetParam(
                   1251:                                m_paramPairs[i].first,
                   1252:                                theXObjectFactory.createString(m_paramPairs[i].second)); /// PAF
                   1253:        }
                   1254: 
                   1255:        // Set the functions if any.
                   1256:        for (FunctionParamPairVectorType::size_type f = 0; f < m_functionPairs.size(); ++f)
                   1257:        {
                   1258:                theXSLTProcessorEnvSupport.installExternalFunctionLocal(
                   1259:                                m_functionPairs[f].first.getNamespace(),
                   1260:                                m_functionPairs[f].first.getLocalPart(),
                   1261:                                *(m_functionPairs[f].second));
                   1262:        }
                   1263: 
                   1264:        // Do the transformation...
                   1265:        theProcessor.process(
1.7     ! paf      1266:                                &theDocument,   
1.5       parser   1267:                                tempResultTarget,                                       
                   1268:                                *m_stylesheetExecutionContext);
                   1269: }
1.6       parser   1270: 
1.3       parser   1271: #endif

E-mail: