Hello,
J'ai créé un programme en JAVA qui applique plusieurs transformations xslt. il fonctionne très bien depuis Eclipse, mais je n'arrive pas à l'éxécuter en lignes de commandes...
C'est peut-être tout con, mais je n'ai plus trop l'habitude...
Je lance les lignes suivantes:
la première qui compile fonctionne. La deuxième me met une exception noClassDefFoundError...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 javac Transform.java java Transform.class xsd.xsd head.xsl body.xsl xhtml.xsl xforms_generated.xhtml (mêmes paramètres que dans Eclipse)
Je ne comprend pas...
Voici mon fichier JAVA, au cas ou...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 import javax.xml.transform.Source; import javax.xml.transform.Result; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamResult; import java.io.*; public class Transform { public static void main(String[] args) throws Exception { if (args.length != 5) { System.err.println( "Utilisation: java Transform [xsdFile] [headXslFile] [bodyXslFile] [globalXslFile] [destFile]"); System.exit(1); } try{ File xsdFile = new File(args[0]); File headXSLFile = new File(args[1]); File bodyXSLFile = new File(args[2]); File globalXSLFile = new File(args[3]); File destXHTMLFile = new File(args[4]); Source xsdSource = new StreamSource(xsdFile); Source headXSLSource = new StreamSource(headXSLFile); Source bodyXSLSource = new StreamSource(bodyXSLFile); Source globalXSLSource = new StreamSource(globalXSLFile); Result destheadResult = new StreamResult("head_generated.xhtml"); Result destbodyResult = new StreamResult("body_generated.xhtml"); Result destXHTMLResult = new StreamResult(destXHTMLFile); TransformerFactory transFact = TransformerFactory.newInstance(); Transformer transHead = transFact.newTransformer(headXSLSource); transHead.transform(xsdSource, destheadResult); Transformer transBody = transFact.newTransformer(bodyXSLSource); transBody.transform(xsdSource, destbodyResult); Transformer transFinal = transFact.newTransformer(globalXSLSource); transFinal.transform(xsdSource, destXHTMLResult); System.out.println("Transformation effectuee avec succes"); } catch(Exception e){ System.out.println("Erreur!!"); } } }
Partager