auriemma    01/04/10 07:51:41

  Modified:    c/src/XalanTransformer XalanTransformer.cpp
  Log:
  Added support for parameters.
  
  Revision  Changes    Path
  1.13      +90 -8     xml-xalan/c/src/XalanTransformer/XalanTransformer.cpp
  
  Index: XalanTransformer.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XalanTransformer/XalanTransformer.cpp,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- XalanTransformer.cpp      2001/04/01 01:07:32     1.12
  +++ XalanTransformer.cpp      2001/04/10 14:51:40     1.13
  @@ -79,10 +79,32 @@
   
   
   
  +struct SetParamFunctor 
  +{
  +    SetParamFunctor(XSLTEngineImpl&          theProcessor):
  +        m_processor(theProcessor)
  +    {
  +    }
  +
  +     void
  +    operator()(const XalanTransformer::ParamPairType&        theParamPair) 
  +     {
  +             // Set the stylesheet parameter.
  +         m_processor.setStylesheetParam(
  +                                     theParamPair.first,  
  +                                     theParamPair.second);        
  +     }
  +
  +     XSLTEngineImpl&         m_processor;
  +};
  +
  +
  +
   XalanTransformer::XalanTransformer():
        m_stylesheetExecutionContext(),
        m_compiledStylesheets(),
        m_parsedSources(),
  +    m_paramPairs(),
        m_errorMessage()
   {
        m_errorMessage.push_back(0);
  @@ -133,10 +155,15 @@
        const XSLTInputSource&          theStylesheetSource,
        const XSLTResultTarget&         theResultTarget)
   {
  +#if !defined(XALAN_NO_NAMESPACES)
  +     using std::for_each;
  +#endif
  +
        int             theResult = 0;
   
        // Clear the error message.
        m_errorMessage.clear();
  +
        m_errorMessage.push_back(0);
   
        // Store error messages from problem listener.
  @@ -146,11 +173,14 @@
        {               
                // Create some support objects that are necessary for running 
the processor...
                DOMSupport&                     theDOMSupport = 
*theParsedXML.getDOMSupport();
  +
                XMLParserLiaison&       theParserLiaison = 
*theParsedXML.getParserLiaison();
   
                // Create some more support objects...
                XSLTProcessorEnvSupportDefault  theXSLTProcessorEnvSupport;
  +
                XObjectFactoryDefault                   theXObjectFactory;
  +
                XPathFactoryDefault                             theXPathFactory;
   
                // Create a processor...
  @@ -170,20 +200,30 @@
   
                
theParserLiaison.setExecutionContext(m_stylesheetExecutionContext);
   
  -             // Create a stylesheet construction context, using the
  -             // stylesheet's factory support objects.
  +             // Create a stylesheet construction context, 
  +             // using the stylesheet's factory support objects.
                StylesheetConstructionContextDefault    
theStylesheetConstructionContext(
                                        theProcessor,
                                        theXSLTProcessorEnvSupport,
                                        theXPathFactory);
   
  +             // Hack used to cast away const.
                XSLTResultTarget        tempResultTarget(theResultTarget);
   
  +             // Set up the stylesheet execution context.
                
m_stylesheetExecutionContext.setXPathEnvSupport(&theXSLTProcessorEnvSupport);
  +
                m_stylesheetExecutionContext.setDOMSupport(&theDOMSupport);
  +
                
m_stylesheetExecutionContext.setXObjectFactory(&theXObjectFactory);
  +
                m_stylesheetExecutionContext.setXSLTProcessor(&theProcessor);
   
  +        // Set the parameters.
  +         for_each(m_paramPairs.begin(),
  +                          m_paramPairs.end(),
  +                          SetParamFunctor(theProcessor));
  +
                // Do the transformation...
                theProcessor.process(
                                        theParsedXML.getParsedSource(),
  @@ -253,8 +293,11 @@
        }
   
        m_stylesheetExecutionContext.setXPathEnvSupport(0);
  +
        m_stylesheetExecutionContext.setDOMSupport(0);
  +
        m_stylesheetExecutionContext.setXObjectFactory(0);
  +
        m_stylesheetExecutionContext.setXSLTProcessor(0);
   
        return theResult;
  @@ -268,10 +311,15 @@
                        const XalanCompiledStylesheet*  theCompiledStylesheet,
                        const XSLTResultTarget&                 theResultTarget)
   {
  +#if !defined(XALAN_NO_NAMESPACES)
  +     using std::for_each;
  +#endif
  +
        int             theResult = 0;
   
        // Clear the error message.
        m_errorMessage.clear();
  +
        m_errorMessage.push_back(0);
   
        // Store error messages from problem listener.
  @@ -281,11 +329,14 @@
        {
                // Create some support objects that are necessary for running 
the processor...
                DOMSupport&                     theDOMSupport = 
*theParsedXML.getDOMSupport();
  +
                XMLParserLiaison&       theParserLiaison = 
*theParsedXML.getParserLiaison();
   
                // Create some more support objects...
                XSLTProcessorEnvSupportDefault  theXSLTProcessorEnvSupport;
  +
                XObjectFactoryDefault                   theXObjectFactory;
  +
                XPathFactoryDefault                             theXPathFactory;
   
                // Create a processor...
  @@ -303,16 +354,26 @@
   
                theProcessor.setProblemListener(&theProblemListener);
   
  +             // Hack used to cast away const.
                XSLTResultTarget        tempResultTarget(theResultTarget);
   
  +             // Set up the stylesheet execution context.
                
m_stylesheetExecutionContext.setXPathEnvSupport(&theXSLTProcessorEnvSupport);
  +
                m_stylesheetExecutionContext.setDOMSupport(&theDOMSupport);
  +
                
m_stylesheetExecutionContext.setXObjectFactory(&theXObjectFactory);
  -             m_stylesheetExecutionContext.setXSLTProcessor(&theProcessor);
   
  +             m_stylesheetExecutionContext.setXSLTProcessor(&theProcessor);
  +             
                // Set the compiled stylesheet.
                
theCompiledStylesheet->setStylesheetRoot(m_stylesheetExecutionContext);
   
  +             // Set the parameters.
  +         for_each(m_paramPairs.begin(),
  +                          m_paramPairs.end(),
  +                          SetParamFunctor(theProcessor));
  +
                // Do the transformation...
                theProcessor.process(
                                        theParsedXML.getParsedSource(),         
  @@ -378,8 +439,11 @@
        }
   
        m_stylesheetExecutionContext.setXPathEnvSupport(0);
  +
        m_stylesheetExecutionContext.setDOMSupport(0);
  +
        m_stylesheetExecutionContext.setXObjectFactory(0);
  +
        m_stylesheetExecutionContext.setXSLTProcessor(0);
   
        reset();
  @@ -449,7 +513,9 @@
   {
        // Set to output target to the callback 
        XalanTransformerOutputStream    theOutputStream(theOutputHandle, 
theOutputHandler, theFlushHandler);
  +
        XalanOutputStreamPrintWriter    thePrintWriter(theOutputStream);
  +
        XSLTResultTarget                                
theResultTarget(&thePrintWriter);
   
        // Do the transformation...
  @@ -471,7 +537,9 @@
   {
        // Set to output target to the callback 
        XalanTransformerOutputStream    theOutputStream(theOutputHandle, 
theOutputHandler, theFlushHandler);
  +
        XalanOutputStreamPrintWriter    thePrintWriter(theOutputStream);
  +
        XSLTResultTarget                                
theResultTarget(&thePrintWriter);
   
        // Do the transformation...
  @@ -492,7 +560,9 @@
   {
        // Set to output target to the callback 
        XalanTransformerOutputStream    theOutputStream(theOutputHandle, 
theOutputHandler, theFlushHandler);
  +
        XalanOutputStreamPrintWriter    thePrintWriter(theOutputStream);
  +
        XSLTResultTarget                                
theResultTarget(&thePrintWriter);
   
        // Do the transformation...
  @@ -509,6 +579,7 @@
   {
        // Clear the error message.
        m_errorMessage.clear();
  +
        m_errorMessage.push_back(0);
   
        // Store error messages from problem listener.
  @@ -519,6 +590,7 @@
   
                // Create some support objects that are necessary for running 
the processor...
                XalanSourceTreeDOMSupport               theDOMSupport;
  +
                XalanSourceTreeParserLiaison    theParserLiaison(theDOMSupport);
   
                // Hook the two together...
  @@ -526,7 +598,9 @@
   
                // Create some more support objects...
                XSLTProcessorEnvSupportDefault  theXSLTProcessorEnvSupport;
  +
                XObjectFactoryDefault                   theXObjectFactory;
  +
                XPathFactoryDefault                             theXPathFactory;
   
                // Create a processor...
  @@ -596,6 +670,7 @@
                        XalanDOMString theMessage("XalanDOMException caught.  
The code is ");
                        
                        append(theMessage,  
LongToDOMString(long(e.getExceptionCode())));
  +
                        append(theMessage,  XalanDOMString("."));               
                                 
   
                        TranscodeToLocalCodePage(theMessage, m_errorMessage, 
true);
  @@ -683,6 +758,7 @@
                        XalanDOMString theMessage("XalanDOMException caught.  
The code is ");
                        
                        append(theMessage,  
LongToDOMString(long(e.getExceptionCode())));
  +
                        append(theMessage,  XalanDOMString("."));               
                                 
   
                        TranscodeToLocalCodePage(theMessage, m_errorMessage, 
true);
  @@ -698,8 +774,8 @@
                        const XalanDOMString&   key,
                        const XalanDOMString&   expression)
   {
  -     // Set the stylesheet parameter.
  -//   m_processor.setStylesheetParam(key,  expression);
  +     // Store the stylesheet parameter in a vector.
  +     m_paramPairs.push_back(ParamPairType(key,  expression));
   }
   
   
  @@ -710,9 +786,9 @@
                        const char*                             expression)
   {
        // Set the stylesheet parameter.
  -//   m_processor.setStylesheetParam(
  -//                                   XalanDOMString(key),  
  -//                                   XalanDOMString(expression));
  +     setStylesheetParam(
  +                                     XalanDOMString(key),  
  +                                     XalanDOMString(expression));
   }
   
   
  @@ -732,11 +808,17 @@
        {
                // Reset objects.
                m_stylesheetExecutionContext.setXPathEnvSupport(0);
  +
                m_stylesheetExecutionContext.setDOMSupport(0);
  +             
                m_stylesheetExecutionContext.setXObjectFactory(0);
  +             
                m_stylesheetExecutionContext.setXSLTProcessor(0);
   
                m_stylesheetExecutionContext.reset();
  +
  +        // Clear the ParamPairVectorType.
  +        m_paramPairs.clear();
        }
        catch(...)
        {
  
  
  

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

Reply via email to