]> matita.cs.unibo.it Git - helm.git/commitdiff
Xalan-J-2 support added. Still too alpha to work, too.
authorClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Fri, 10 Nov 2000 10:50:48 +0000 (10:50 +0000)
committerClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Fri, 10 Nov 2000 10:50:48 +0000 (10:50 +0000)
helm/interface/Makefile
helm/interface/cadet
helm/interface/xaland-java/xaland.java
helm/interface/xaland-java2/xaland2.class [new file with mode: 0644]
helm/interface/xaland-java2/xaland2.java [new file with mode: 0644]
helm/interface/xaland2.class [new file with mode: 0644]

index 8bb54e9add7ef8791bd3704d44f58ce4a5498c76..ba52624e25e965a0981f98faef2a064638b504e2 100644 (file)
@@ -170,7 +170,14 @@ clean:
            mmlinterface.opt mmlinterface2 mmlinterface2.opt
 
 start-xaland:
-       java xaland 12345 12346 examples/style/rootcontent.xsl \
+       java -ss1024K -oss8192K \
+           xaland 12345 12346 examples/style/rootcontent.xsl \
+           examples/style/annotatedpres.xsl examples/style/theory_content.xsl \
+           examples/style/theory_pres.xsl
+
+start-xaland-2:
+       java -ss1024K -oss8192K \
+           xaland2 12345 12346 examples/style/rootcontent.xsl \
            examples/style/annotatedpres.xsl examples/style/theory_content.xsl \
            examples/style/theory_pres.xsl
 
index aedf5b7007ae6b1bffb75035443cd67fe0665f95..4a7707b2de418520f36e07b1949efc45b9014612 100755 (executable)
@@ -2,7 +2,9 @@
 
 export PATH=/home/cadet/sacerdot/jdk118/bin:$PATH
 
+#export CLASSPATH=/home/cadet/sacerdot/xalan-j_1_1/xalan.jar:/home/cadet/sacerdot/xalan-j_1_1/xerces.jar:.
 export CLASSPATH=/home/cadet/sacerdot/xalan-j_1_2/xalan.jar:/home/cadet/sacerdot/xalan-j_1_2/xerces.jar:.
+#export CLASSPATH=/home/cadet/sacerdot/xalan-j_2_0_D01/bin/xalan.jar:/home/cadet/sacerdot/xalan-j_2_0_D01/bin/xerces.jar:.
 
 #export CLASSPATH=$CLASSPATH:/home/lpadovan/helm/java/xalan_1_1/xalan.jar
 #export CLASSPATH=$CLASSPATH:/home/lpadovan/helm/java/xalan_1_1/xerces.jar
index 9eda83124f873aba29fbc822e82a5bead580a0f4..1b9312c46d443a3b835d3bd67c3f0ffda840f30d 100644 (file)
@@ -3,12 +3,14 @@ import java.net.*;
 import java.io.*;
 
 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
    {
diff --git a/helm/interface/xaland-java2/xaland2.class b/helm/interface/xaland-java2/xaland2.class
new file mode 100644 (file)
index 0000000..95b42c7
Binary files /dev/null and b/helm/interface/xaland-java2/xaland2.class differ
diff --git a/helm/interface/xaland-java2/xaland2.java b/helm/interface/xaland-java2/xaland2.java
new file mode 100644 (file)
index 0000000..9d91d37
--- /dev/null
@@ -0,0 +1,134 @@
+import java.net.*;
+import java.io.*;
+
+// Imported TraX classes
+import org.apache.trax.Processor;
+import org.apache.trax.Templates;
+import org.apache.trax.Transformer;
+import org.apache.trax.Result;
+import org.apache.trax.ProcessorException;
+import org.apache.trax.ProcessorFactoryException;
+import org.apache.trax.TransformException;
+
+// Imported SAX classes
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.Parser;
+import org.xml.sax.helpers.ParserAdapter;
+import org.xml.sax.helpers.XMLReaderFactory;
+import org.xml.sax.XMLReader;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.ext.LexicalHandler;
+
+// Imported DOM classes
+import org.w3c.dom.Node;
+
+// Imported Serializer classes
+import org.apache.serialize.OutputFormat;
+import org.apache.serialize.Serializer;
+import org.apache.serialize.SerializerFactory;
+
+// Imported JAVA API for XML Parsing 1.0 classes
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+
+public class xaland2 {
+   public static void main(String argv[]) throws  IOException, MalformedURLException, SAXException, ParserConfigurationException
+   {
+      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];
+
+      Processor theory_processor = Processor.newInstance("xslt");
+      Templates theory_style1 = theory_processor.process(new InputSource(theory_xsl1));
+      Transformer theory_transformer1 = theory_style1.newTransformer();
+
+      Templates theory_style2 = theory_processor.process(new InputSource(theory_xsl2));
+      Transformer theory_transformer2 = theory_style2.newTransformer();
+
+
+      Processor processor = Processor.newInstance("xslt");
+      Templates style1 = processor.process(new InputSource(xsl1));
+      Transformer transformer1 = style1.newTransformer();
+
+      Templates style2 = processor.process(new InputSource(xsl2));
+      Transformer transformer2 = style2.newTransformer();
+
+
+      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")) {
+               XMLReader reader = XMLReaderFactory.createXMLReader();
+               ContentHandler chandler = transformer1.getInputContentHandler();
+               reader.setContentHandler(chandler);
+               if (chandler instanceof LexicalHandler)
+                reader.setProperty("http://xml.org/sax/properties/lexical-handler", chandler);
+               else
+                reader.setProperty("http://xml.org/sax/properties/lexical-handler", null);
+
+               transformer1.setContentHandler(transformer2.getInputContentHandler());
+               Serializer serializer = SerializerFactory.getSerializer("xml");
+               serializer.setOutputStream(fout);
+               transformer2.setContentHandler(serializer.asContentHandler());
+
+               reader.parse(input);
+            } else if (mode.equals("theory")) {
+               XMLReader reader = XMLReaderFactory.createXMLReader();
+               ContentHandler chandler = theory_transformer1.getInputContentHandler();
+               reader.setContentHandler(chandler);
+               if (chandler instanceof LexicalHandler)
+                reader.setProperty("http://xml.org/sax/properties/lexical-handler", chandler);
+               else
+                reader.setProperty("http://xml.org/sax/properties/lexical-handler", null);
+
+               theory_transformer1.setContentHandler(theory_transformer2.getInputContentHandler());
+               Serializer serializer = SerializerFactory.getSerializer("xml");
+               serializer.setOutputStream(fout);
+               theory_transformer2.setContentHandler(serializer.asContentHandler());
+
+               reader.parse(input);
+             }
+         }
+
+         InetAddress address = InetAddress.getLocalHost();
+         DatagramSocket socket2 = new DatagramSocket();
+
+         byte buf[] = new byte[0];
+         DatagramPacket packet2 = new DatagramPacket(buf,0,address,port2);
+
+         socket2.send(packet2);
+      }
+   }
+}
diff --git a/helm/interface/xaland2.class b/helm/interface/xaland2.class
new file mode 100644 (file)
index 0000000..95b42c7
Binary files /dev/null and b/helm/interface/xaland2.class differ