--- parser3/src/classes/xalan-patched/Attic/XalanTransformer2.cpp 2001/10/09 14:25:15 1.2 +++ parser3/src/classes/xalan-patched/Attic/XalanTransformer2.cpp 2001/10/26 12:21:29 1.7 @@ -7,7 +7,7 @@ Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com) Author: Alexander Petrosyan (http://design.ru/paf) - $Id: XalanTransformer2.cpp,v 1.2 2001/10/09 14:25:15 parser Exp $ + $Id: XalanTransformer2.cpp,v 1.7 2001/10/26 12:21:29 paf Exp $ based on: */ @@ -120,6 +120,9 @@ #include "XalanTransformer/XercesDOMParsedSource.hpp" +#include "XercesParserLiaison/XercesDOMSupport.hpp" +#include "XMLSupport/XMLParserLiaisonDefault.hpp" + XSLTInit* XalanTransformer2::s_xsltInit = 0; @@ -883,14 +886,14 @@ XalanTransformer2::parseSource( try { - if(useXercesDOM == true) + //if(useXercesDOM == true) { theParsedSource = new XercesDOMParsedSource(theInputSource); } - else + /*else { theParsedSource = new XalanDefaultParsedSource(theInputSource); - } + }*/ // Store it in a vector. m_parsedSources.push_back(theParsedSource); @@ -1140,6 +1143,81 @@ XalanTransformer2::transform2( theXSLTProcessorEnvSupport.setProcessor(&theProcessor); + // Since the result target is not const in our + // internal intefaces, we'll pass in a local copy + // of the one provided... + XSLTResultTarget tempResultTarget(theResultTarget); + + const EnsureReset theReset(*this); + + // Set up the stylesheet execution context. + m_stylesheetExecutionContext->setXPathEnvSupport(&theXSLTProcessorEnvSupport); + + m_stylesheetExecutionContext->setDOMSupport(&theDOMSupport); + + m_stylesheetExecutionContext->setXObjectFactory(&theXObjectFactory); + + m_stylesheetExecutionContext->setXSLTProcessor(&theProcessor); + + // Set the compiled stylesheet. + m_stylesheetExecutionContext->setStylesheetRoot(theCompiledStylesheet->getStylesheetRoot()); + + // Set the parameters if any. + for (ParamPairVectorType::size_type i = 0; i < m_paramPairs.size(); ++i) + { + theProcessor.setStylesheetParam( + m_paramPairs[i].first, + theXObjectFactory.createString(m_paramPairs[i].second)); /// PAF + } + + // Set the functions if any. + for (FunctionParamPairVectorType::size_type f = 0; f < m_functionPairs.size(); ++f) + { + theXSLTProcessorEnvSupport.installExternalFunctionLocal( + m_functionPairs[f].first.getNamespace(), + m_functionPairs[f].first.getLocalPart(), + *(m_functionPairs[f].second)); + } + + // Do the transformation... + theProcessor.process( + theParsedXML.getDocument(), + tempResultTarget, + *m_stylesheetExecutionContext); +} + + +void +XalanTransformer2::transform2( + XalanDocument& theDocument, + const XalanCompiledStylesheet* theCompiledStylesheet, + const XSLTResultTarget& theResultTarget) +{ +#if !defined(XALAN_NO_NAMESPACES) + using std::for_each; +#endif + + XercesDOMSupport theDOMSupport; + + XercesParserLiaison theParserLiaison(theDOMSupport); + + // Create some more support objects... + XSLTProcessorEnvSupportDefault theXSLTProcessorEnvSupport; + + XObjectFactoryDefault theXObjectFactory; + + XPathFactoryDefault theXPathFactory; + + // Create a processor... + XSLTEngineImpl theProcessor( + theParserLiaison, + theXSLTProcessorEnvSupport, + theDOMSupport, + theXObjectFactory, + theXPathFactory); + + theXSLTProcessorEnvSupport.setProcessor(&theProcessor); + // Create a problem listener and send output to a XalanDOMString. //DOMStringPrintWriter thePrintWriter(theErrorMessage); @@ -1185,8 +1263,9 @@ XalanTransformer2::transform2( // Do the transformation... theProcessor.process( - theParsedXML.getDocument(), + &theDocument, tempResultTarget, *m_stylesheetExecutionContext); } -#endif \ No newline at end of file + +#endif