You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by dl...@locus.apache.org on 2000/05/05 21:03:50 UTC
cvs commit: xml-xalan/c/samples/CompileStylesheet foo1.xml foo10.xml foo2.xml foo3.xml foo4.xml foo5.xml foo6.xml foo7.xml foo8.xml foo9.xml CompileStylesheet.cpp
dleslie 00/05/05 12:03:50
Modified: c/samples/CompileStylesheet CompileStylesheet.cpp
Added: c/samples/CompileStylesheet foo1.xml foo10.xml foo2.xml
foo3.xml foo4.xml foo5.xml foo6.xml foo7.xml
foo8.xml foo9.xml
Log:
Modified CompileStylesheet to process 10 input files, using
the XSLTEngineImpl process() method.
Revision Changes Path
1.2 +24 -48 xml-xalan/c/samples/CompileStylesheet/CompileStylesheet.cpp
Index: CompileStylesheet.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/samples/CompileStylesheet/CompileStylesheet.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CompileStylesheet.cpp 2000/04/27 21:53:07 1.1
+++ CompileStylesheet.cpp 2000/05/05 19:03:49 1.2
@@ -1,29 +1,17 @@
#include <cassert>
#include <fstream>
-#include <fstream>
#include <iostream>
#include <strstream>
-
-
#include <util/PlatformUtils.hpp>
-
-
#include <PlatformSupport/DOMStringHelper.hpp>
-
-
-
#include <DOMSupport/DOMSupportDefault.hpp>
-
-
#include <XPath/XObjectFactoryDefault.hpp>
#include <XPath/XPathSupportDefault.hpp>
#include <XPath/XPathFactoryDefault.hpp>
-
-
#include <XSLT/StylesheetConstructionContextDefault.hpp>
#include <XSLT/StylesheetExecutionContextDefault.hpp>
#include <XSLT/StylesheetRoot.hpp>
@@ -32,12 +20,8 @@
#include <XSLT/XSLTProcessorEnvSupportDefault.hpp>
#include <XSLT/XSLTResultTarget.hpp>
-
-
#include <XercesParserLiaison/XercesParserLiaison.hpp>
-
-
#include <XercesPlatformSupport/TextFileOutputStream.hpp>
#include <XercesPlatformSupport/XercesDOMPrintWriter.hpp>
@@ -59,7 +43,7 @@
if (argc != 1)
{
- cerr << "Usage: SimpleTransform"
+ cerr << "Usage: CompileStylesheet"
<< endl
<< endl;
}
@@ -96,8 +80,8 @@
theProcessor.setFormatter(&theParserLiaison);
// Create separate factory support objects so the stylesheet's
- // factory-created instances are independent from those of the
- // processor's.
+ // factory-created XObject and XPath instances are independent
+ // from processor's.
XObjectFactoryDefault theStylesheetXObjectFactory(
theXSLTProcessorEnvSupport,
theXPathSupport);
@@ -113,7 +97,7 @@
// The execution context uses the same factory support objects as
// the processor, since those objects have the same lifetime as
- // other objects created as a result of the exection.
+ // other objects created as a result of the execution.
StylesheetExecutionContextDefault theExecutionContext(
theProcessor,
theXSLTProcessorEnvSupport,
@@ -122,8 +106,8 @@
// Our input files. The assumption is that the executable will be run
// from same directory as the input files.
- const DOMString theXMLFileName("foo.xml");
- const DOMString theXSLFileName("foo.xsl");
+ const XalanDOMString theXMLFileName("foo.xml");
+ const XalanDOMString theXSLFileName("foo.xsl");
// Our stylesheet input source...
XSLTInputSource theStylesheetSource(c_wstr(theXSLFileName));
@@ -138,36 +122,28 @@
theConstructionContext);
assert(theStylesheetRoot != 0);
- // Our source tree input source...
- XSLTInputSource theInputSource(c_wstr(theXMLFileName));
-
- // Create the source tree...
- XalanNode* const theSourceTree =
- theProcessor.getSourceTreeFromInput(theInputSource);
- assert(theSourceTree != 0);
-
for (unsigned int i = 0; i < 10; i++)
{
- // Generate a unique file name based on i...
- ostrstream theFormatter;
-
- theFormatter << "foo" << i + 1 << ".out" << '\0';
-
- // Our output target is specified as a file name...
- XSLTResultTarget theResultTarget(theFormatter.str());
-
- // Unfreeze the ostrstream, so the memory is returned...
- theFormatter.freeze(false);
+ // Generate the input and output file names.
+ ostrstream theFormatterIn, theFormatterOut;
+ theFormatterIn << "foo" << i + 1 << ".xml" << '\0';
+ theFormatterOut << "foo" << i + 1 << ".out" << '\0';
+
+ //Generate the XML input and output objects.
+ XSLTInputSource theInputSource(theFormatterIn.str());
+ XSLTResultTarget theResultTarget(theFormatterOut.str());
+
+ // Unfreeze the ostrstreams, so the memory is returned...
+ theFormatterIn.freeze(false);
+ theFormatterOut.freeze(false);
// Do the tranformation...
- theStylesheetRoot->process(
- theSourceTree,
- theResultTarget,
- theExecutionContext);
-
- // Reset things, so we can go again...
- theProcessor.reset();
- theExecutionContext.reset();
+ theProcessor.process(
+ theInputSource,
+ 0, //Use the StylesheetRoot
+ theResultTarget,
+ theConstructionContext,
+ theExecutionContext);
}
}
catch(...)
1.1 xml-xalan/c/samples/CompileStylesheet/foo1.xml
Index: foo1.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<doc>Hello 1</doc>
1.1 xml-xalan/c/samples/CompileStylesheet/foo10.xml
Index: foo10.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<doc>Hello 10</doc>
1.1 xml-xalan/c/samples/CompileStylesheet/foo2.xml
Index: foo2.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<doc>Hello 2</doc>
1.1 xml-xalan/c/samples/CompileStylesheet/foo3.xml
Index: foo3.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<doc>Hello 3</doc>
1.1 xml-xalan/c/samples/CompileStylesheet/foo4.xml
Index: foo4.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<doc>Hello 4</doc>
1.1 xml-xalan/c/samples/CompileStylesheet/foo5.xml
Index: foo5.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<doc>Hello 5</doc>
1.1 xml-xalan/c/samples/CompileStylesheet/foo6.xml
Index: foo6.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<doc>Hello 6</doc>
1.1 xml-xalan/c/samples/CompileStylesheet/foo7.xml
Index: foo7.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<doc>Hello 7</doc>
1.1 xml-xalan/c/samples/CompileStylesheet/foo8.xml
Index: foo8.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<doc>Hello 8</doc>
1.1 xml-xalan/c/samples/CompileStylesheet/foo9.xml
Index: foo9.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<doc>Hello 9</doc>