You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by au...@apache.org on 2001/04/19 20:44:55 UTC
cvs commit: xml-xalan/c/samples/SimpleTransform SimpleTransform.cpp
auriemma 01/04/19 11:44:55
Modified: c/samples/SimpleTransform SimpleTransform.cpp
Log:
Updated to use the XalanTransformer class.
Revision Changes Path
1.13 +31 -106 xml-xalan/c/samples/SimpleTransform/SimpleTransform.cpp
Index: SimpleTransform.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/samples/SimpleTransform/SimpleTransform.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- SimpleTransform.cpp 2001/01/08 20:26:28 1.12
+++ SimpleTransform.cpp 2001/04/19 18:44:54 1.13
@@ -3,48 +3,14 @@
-#if defined(XALAN_OLD_STREAM_HEADERS)
-#include <fstream.h>
-#include <iostream.h>
-#else
-#include <fstream>
-#include <iostream>
-#endif
-
-
-
#include <util/PlatformUtils.hpp>
-
-#include <PlatformSupport/DOMStringHelper.hpp>
-
-
-
-#include <DOMSupport/DOMSupportDefault.hpp>
-
-
-
-#include <XPath/XObjectFactoryDefault.hpp>
-#include <XPath/XPathFactoryDefault.hpp>
+#include <XalanTransformer/XalanTransformer.hpp>
-#include <XSLT/StylesheetConstructionContextDefault.hpp>
-#include <XSLT/StylesheetExecutionContextDefault.hpp>
-#include <XSLT/XSLTEngineImpl.hpp>
-#include <XSLT/XSLTInit.hpp>
-#include <XSLT/XSLTInputSource.hpp>
-#include <XSLT/XSLTProcessorEnvSupportDefault.hpp>
-#include <XSLT/XSLTResultTarget.hpp>
-
-
-#include <XalanSourceTree/XalanSourceTreeDOMSupport.hpp>
-#include <XalanSourceTree/XalanSourceTreeParserLiaison.hpp>
-
-
-
int
main(
int argc,
@@ -53,94 +19,53 @@
#if !defined(XALAN_NO_NAMESPACES)
using std::cerr;
using std::endl;
- using std::ofstream;
#endif
+ int theResult = 0;
+
if (argc != 1)
{
cerr << "Usage: SimpleTransform"
<< endl
<< endl;
+
+ theResult = -1;
}
else
{
- try
- {
- // Call the static initializer for Xerces...
- XMLPlatformUtils::Initialize();
+ // Call the static initializer for Xerces.
+ XMLPlatformUtils::Initialize();
- {
- // Initialize the Xalan XSLT subsystem...
- XSLTInit theInit;
-
- // Create some support objects that are necessary for running the processor...
- XalanSourceTreeDOMSupport theDOMSupport;
- XalanSourceTreeParserLiaison theParserLiaison(theDOMSupport);
-
- // Hook the two together...
- theDOMSupport.setParserLiaison(&theParserLiaison);
-
- // Create some more support objects...
- XSLTProcessorEnvSupportDefault theXSLTProcessorEnvSupport;
- XObjectFactoryDefault theXObjectFactory;
- XPathFactoryDefault theXPathFactory;
-
- // Create a processor...
- XSLTEngineImpl theProcessor(
- theParserLiaison,
- theXSLTProcessorEnvSupport,
- theDOMSupport,
- theXObjectFactory,
- theXPathFactory);
-
- // Connect the processor to the support object...
- theXSLTProcessorEnvSupport.setProcessor(&theProcessor);
-
- // Create a stylesheet construction context, and a stylesheet
- // execution context...
- StylesheetConstructionContextDefault theConstructionContext(
- theProcessor,
- theXSLTProcessorEnvSupport,
- theXPathFactory);
-
- StylesheetExecutionContextDefault theExecutionContext(
- theProcessor,
- theXSLTProcessorEnvSupport,
- theDOMSupport,
- theXObjectFactory);
-
- // Our input files...The assumption is that the executable will be run
- // from same directory as the input files.
- const XalanDOMString theXMLFileName("foo.xml");
- const XalanDOMString theXSLFileName("foo.xsl");
-
- // Our input sources...
- XSLTInputSource theInputSource(c_wstr(theXMLFileName));
- XSLTInputSource theStylesheetSource(c_wstr(theXSLFileName));
-
- // Our output target...
- const XalanDOMString theOutputFileName("foo.out");
- XSLTResultTarget theResultTarget(theOutputFileName);
-
- theProcessor.process(
- theInputSource,
- theStylesheetSource,
- theResultTarget,
- theConstructionContext,
- theExecutionContext);
+ // Initialize Xalan.
+ XalanTransformer::initialize();
- }
+ // Create a XalanTransformer.
+ XalanTransformer theXalanTransformer;
- // Call the static terminator for Xerces...
- XMLPlatformUtils::Terminate();
- }
- catch(...)
+ // Our input files...The assumption is that the executable will be run
+ // from same directory as the input files.
+ const char* theXMLFileName = "foo.xml";
+ const char* theXSLFileName = "foo.xsl";
+
+ // Our output target...
+ const char* theOutputFileName = "foo.out";
+
+ // Do the transform.
+ theResult = theXalanTransformer.transform(theXMLFileName, theXSLFileName, theOutputFileName);
+
+ if(theResult != 0)
{
- cerr << "Exception caught!!!"
+ cerr << "SimpleTransform Error: \n" << theXalanTransformer.getLastError()
<< endl
<< endl;
}
+
+ // Terminate Xalan.
+ XalanTransformer::terminate();
+
+ // Call the static terminator for Xerces.
+ XMLPlatformUtils::Terminate();
}
- return 0;
+ return theResult;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org