+// Base header file. Must be first.
+#include <Include/PlatformDefinitions.hpp>
+
+#include <iostream>
+#include <fstream>
+
+#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/XSLTEngineImpl.hpp>
+#include <XSLT/XSLTInit.hpp>
+#include <XSLT/XSLTInputSource.hpp>
+#include <XSLT/XSLTProcessorEnvSupportDefault.hpp>
+#include <XSLT/XSLTResultTarget.hpp>
+
+#include <XercesParserLiaison/XercesDOMSupport.hpp>
+#include <XercesParserLiaison/XercesParserLiaison.hpp>
+
+int main(int argc, const char* [])
+{
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::cerr;
+ using std::endl;
+ using std::ofstream;
+#endif
+
+ if (argc != 1) {
+ cerr << "Usage: SimpleTransform"
+ << endl
+ << endl;
+ } else {
+ try {
+ // Call the static initializer for Xerces...
+ XMLPlatformUtils::Initialize();
+
+ {
+ // Initialize the Xalan XSLT subsystem...
+ XSLTInit theInit;
+
+ // Create the support objects that are necessary for
+ // running the processor...
+ XercesDOMSupport theDOMSupport;
+ XercesParserLiaison theParserLiaison(theDOMSupport);
+ XPathSupportDefault theXPathSupport(theDOMSupport);
+ XSLTProcessorEnvSupportDefault theXSLTProcessorEnvSupport;
+ XObjectFactoryDefault theXObjectFactory;
+ XPathFactoryDefault theXPathFactory;
+
+ // Create a processor...
+ XSLTEngineImpl theProcessor(
+ theParserLiaison,
+ theXPathSupport,
+ 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,
+ theXPathSupport,
+ 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);
+
+ }
+
+ // Call the static terminator for Xerces...
+ XMLPlatformUtils::Terminate();
+ }
+ catch(...) {
+ cerr << "Exception caught!!!"
+ << endl
+ << endl;
+ }
+ }
+
+ return 0;
+}
+
+/**************************************************/
+/*
+
+public class xaland {
+ public static void Transform(StylesheetRoot style, String xmlSourceURL, String OutputURL) throws java.io.IOException, java.net.MalformedURLException, org.xml.sax.SAXException
+ {
+ XSLTInputSource xmlSource = new XSLTInputSource (xmlSourceURL);
+ XSLTResultTarget xmlResult = new XSLTResultTarget (OutputURL);
+ style.process(xmlSource, xmlResult);
+ }
+
+ public static void main(String argv[]) throws java.io.IOException, java.net.MalformedURLException, org.xml.sax.SAXException
+ {
+ int port = Integer.parseInt(argv[0]);
+ int port2 = Integer.parseInt(argv[1]);
+ String xsl1 = argv[2];
+ String xsl2 = argv[3];
+ String theory_xsl1 = argv[4];
+ String theory_xsl2 = argv[5];
+
+ XSLTProcessor theory_processor =
+ XSLTProcessorFactory.getProcessor(new org.apache.xalan.xpath.xdom.XercesLiaison());
+ StylesheetRoot theory_style1 =
+ theory_processor.processStylesheet(theory_xsl1);
+ theory_processor.reset();
+ StylesheetRoot theory_style2 =
+ theory_processor.processStylesheet(theory_xsl2);
+ theory_processor.setStylesheet(theory_style2);
+
+ XSLTProcessor processor =
+ XSLTProcessorFactory.getProcessor(new org.apache.xalan.xpath.xdom.XercesLiaison());
+ StylesheetRoot style1 = processor.processStylesheet(xsl1);
+ processor.reset();
+ StylesheetRoot style2 = processor.processStylesheet(xsl2);
+ processor.setStylesheet(style2);
+
+ DatagramSocket socket = new DatagramSocket(port);
+
+ System.out.println("Demon activated on input port " + port +
+ " and output port " + port2);
+ while(true) {
+ System.out.print("Ready...");
+
+ /* Warning: the packet must be a fresh one! * /
+ DatagramPacket packet = new DatagramPacket(new byte[1024],1024);
+ socket.receive(packet);
+ byte data[] = packet.getData();
+ int datalen = packet.getLength();
+ String received = new String(data,0,datalen);
+
+ int first = received.indexOf(' ');
+ int last = received.lastIndexOf(' ');
+ String mode = received.substring(0,first);
+ String input = received.substring(first+1,last);
+ String output = received.substring(last+1);
+
+ System.out.println("request received! Parameters are");
+ System.out.println("Mode: " + mode + " ");
+ System.out.println("Input file: \"" + input + "\"");
+ System.out.println("Output file: \"" + output + "\"\n");
+
+ if ((new File(output)).exists()) {
+ System.out.println("Using cached version\n");
+ } else {
+ FileOutputStream fout = new FileOutputStream(output);
+ if (mode.equals("cic")) {
+ processor.setDocumentHandler(style2.getSAXSerializer(fout));
+ XSLTResultTarget content = new XSLTResultTarget(processor);
+ style1.process(new XSLTInputSource(input), content);
+ } else if (mode.equals("theory")) {
+ theory_processor.setDocumentHandler(
+ theory_style2.getSAXSerializer(fout));
+ XSLTResultTarget content =
+ new XSLTResultTarget(theory_processor);
+ theory_style1.process(new XSLTInputSource(input), content);
+ }
+ }
+
+ InetAddress address = InetAddress.getLocalHost();
+ DatagramSocket socket2 = new DatagramSocket();
+
+ byte buf[] = new byte[0];
+ DatagramPacket packet2 = new DatagramPacket(buf,0,address,port2);
+
+ socket2.send(packet2);
+ }
+ }
+}
+
+*/