]> matita.cs.unibo.it Git - helm.git/commitdiff
xaland that uses DOM created, but seems to be bugged and not working
authorClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Mon, 27 Nov 2000 17:08:55 +0000 (17:08 +0000)
committerClaudio Sacerdoti Coen <claudio.sacerdoticoen@unibo.it>
Mon, 27 Nov 2000 17:08:55 +0000 (17:08 +0000)
helm/xsltd/Makefile
helm/xsltd/xaland-java-DOM/xaland_DOM.class [new file with mode: 0644]
helm/xsltd/xaland-java-DOM/xaland_DOM.java [new file with mode: 0644]
helm/xsltd/xaland-java/xaland.java
helm/xsltd/xaland_DOM.class [new file with mode: 0644]

index 83c51d9d5a34aa5b19838487aad6b8a125ce45fd..794aa231028ea91edb1ced52b11d1bdd3919b11b 100644 (file)
@@ -6,6 +6,14 @@ start-xaland:
            $(HELM_STYLES_DIR)/theory_content.xsl \
            $(HELM_STYLES_DIR)/theory_pres.xsl
 
+start-xaland-DOM:
+       java -ss1024K -oss8192K \
+           xaland_DOM 12345 12346 \
+           $(HELM_STYLES_DIR)/rootcontent.xsl \
+           $(HELM_STYLES_DIR)/annotatedpres.xsl \
+           $(HELM_STYLES_DIR)/theory_content.xsl \
+           $(HELM_STYLES_DIR)/theory_pres.xsl
+
 start-xaland-2:
        java -ss1024K -oss8192K \
            xaland2 12345 12346 \
diff --git a/helm/xsltd/xaland-java-DOM/xaland_DOM.class b/helm/xsltd/xaland-java-DOM/xaland_DOM.class
new file mode 100644 (file)
index 0000000..59c9683
Binary files /dev/null and b/helm/xsltd/xaland-java-DOM/xaland_DOM.class differ
diff --git a/helm/xsltd/xaland-java-DOM/xaland_DOM.java b/helm/xsltd/xaland-java-DOM/xaland_DOM.java
new file mode 100644 (file)
index 0000000..898f1f8
--- /dev/null
@@ -0,0 +1,91 @@
+import org.apache.xalan.xslt.*;
+import org.w3c.dom.Document;
+import java.net.*;
+import java.io.*;
+
+public class xaland_DOM {
+   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")) {
+Document content_doc = new org.apache.xerces.dom.DocumentImpl();
+XSLTResultTarget content = new XSLTResultTarget(content_doc);
+/*
+               processor.setDocumentHandler(style2.getSAXSerializer(fout));
+               XSLTResultTarget content = new XSLTResultTarget(processor);
+*/
+System.out.print("Prima...\n");
+               style1.process(new XSLTInputSource(input), content);
+System.out.print("Durante...\n");
+               style2.process(new XSLTInputSource(content_doc),new XSLTResultTarget(fout));
+System.out.print("Dopo...\n");
+            } 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);
+      }
+   }
+}
index 1b9312c46d443a3b835d3bd67c3f0ffda840f30d..0ad6783f3f03fafd3d3b2ba6ed847b30a7169355 100644 (file)
@@ -3,15 +3,6 @@ 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
    {
       int port    = Integer.parseInt(argv[0]);
diff --git a/helm/xsltd/xaland_DOM.class b/helm/xsltd/xaland_DOM.class
new file mode 100644 (file)
index 0000000..59c9683
Binary files /dev/null and b/helm/xsltd/xaland_DOM.class differ