From: Claudio Sacerdoti Coen Date: Fri, 10 Nov 2000 10:50:48 +0000 (+0000) Subject: Xalan-J-2 support added. Still too alpha to work, too. X-Git-Tag: nogzip~185 X-Git-Url: http://matita.cs.unibo.it/gitweb/?p=helm.git;a=commitdiff_plain;h=54889b5fb4ea40df04165bcb88324c0fd271cd72 Xalan-J-2 support added. Still too alpha to work, too. --- diff --git a/helm/interface/Makefile b/helm/interface/Makefile index 8bb54e9ad..ba52624e2 100644 --- a/helm/interface/Makefile +++ b/helm/interface/Makefile @@ -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 diff --git a/helm/interface/cadet b/helm/interface/cadet index aedf5b700..4a7707b2d 100755 --- a/helm/interface/cadet +++ b/helm/interface/cadet @@ -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 diff --git a/helm/interface/xaland-java/xaland.java b/helm/interface/xaland-java/xaland.java index 9eda83124..1b9312c46 100644 --- a/helm/interface/xaland-java/xaland.java +++ b/helm/interface/xaland-java/xaland.java @@ -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 index 000000000..95b42c712 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 index 000000000..9d91d37fb --- /dev/null +++ b/helm/interface/xaland-java2/xaland2.java @@ -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 index 000000000..95b42c712 Binary files /dev/null and b/helm/interface/xaland2.class differ