IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Format d'échange (XML, JSON...) Java Discussion :

La classe driver de FOP est manquante


Sujet :

Format d'échange (XML, JSON...) Java

  1. #1
    Membre éprouvé
    Homme Profil pro
    Technophile Web
    Inscrit en
    Mai 2007
    Messages
    930
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations professionnelles :
    Activité : Technophile Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2007
    Messages : 930
    Par défaut La classe driver de FOP est manquante
    bonjour,

    j'ai une classe qui compile des transforme des XML en PDF, XHTML via des XSLT.
    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
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    package com.datalion.exogema;
     
    import java.io.File;
     
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.stream.StreamResult;
    import javax.xml.transform.stream.StreamSource;
     
    import java.io.IOException;
    import java.io.OutputStream;
    import javax.xml.transform.TransformerException;
    import javax.xml.transform.Source;
    import javax.xml.transform.Result;
    import javax.xml.transform.sax.SAXResult;
    import org.apache.avalon.framework.ExceptionUtil;
    import org.apache.avalon.framework.logger.ConsoleLogger;
    import org.apache.avalon.framework.logger.Logger;
    import org.apache.fop.apps.FOPException;
     
    public class StylesheetTransformer 
    {
    	private TransformerFactory factory;
    	public static void main(String args[]) throws FOPException, IOException, TransformerException
    	{
    		StylesheetTransformer styl = new StylesheetTransformer();
    		styl.convert("PDF", "src/com/datalion/exogema/xml/stylesheet.xsl", "src/com/datalion/exogema/xml/enquiry.xml", 
    				System.getenv("java.io.tmp"));
     
    	}
    	public StylesheetTransformer()
    	{
    		this.factory = TransformerFactory.newInstance();
    	}
    	/** Convert a XML file to other file(s) using XSL
             * @param Type of conversion (PDF/XHTML)
             * @param The URL of XSL stylesheet
             * @param The path of XML file
             * @param The output file
             * @throws TransformerException 
             * @throws IOException 
             * @throws FOPException 
             */
    	public void convert(String type, String xsl, String xml, String outputFile) throws FOPException, IOException, TransformerException
    	{
    		if(type.equals("XHTML"))
    		{
    			this.convertInXHTML(xsl,xml,outputFile);
    		}
    		if(type.equals("PDF"))
    		{
    			this.toPDF(new File(xml),new File(xsl),new File(outputFile));
    		}
    	}
    	public void convertInXHTML (String path2xsl, String path2xml, String outputFile)
    	{
    		try
    		{
    		      Transformer transformer = this.factory.newTransformer(new StreamSource(path2xsl));
    		      transformer.transform(new StreamSource(path2xml), new StreamResult(outputFile));
     
    		 }
    		 catch (Exception e)
    		 {
    			 e.getCause();
    		 }
    	}
    	public void toPDF(File xml, File xslt, File pdf)
    		throws IOException, FOPException, TransformerException {
    		 //Construct driver
    		 Driver driver = new Driver();
     
    		 //Setup logger
    		 Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
    		 driver.setLogger(logger);
    		 MessageHandler.setScreenLogger(logger);
     
    		 //Setup Renderer (output format)
    		 driver.setRenderer(Driver.RENDER_PDF);
     
    		 //Setup output
    		 OutputStream out = new java.io.FileOutputStream(pdf);
    		 try {
    		 driver.setOutputStream(out);
     
    		 //Setup XSLT
    		 Transformer transformer = this.factory.newTransformer(new StreamSource(xslt));
     
    		 //Setup input for XSLT transformation
    		 Source src = new StreamSource(xml);
     
    		 //Resulting SAX events (the generated FO) must be piped through to FOP
    		 Result res = new SAXResult(driver.getContentHandler());
     
    		 //Start XSLT transformation and FOP processing
    		 transformer.transform(src, res);
    		 } finally {
    		 out.close();
    		}
    		 }
    }
    mais voila je n'arrive pas à charge la classe driver, elle ne semble paêtre dans le jar de fop.

    quelqu'un a til rencontré le même problème que moi ?

  2. #2
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    T'as pas oublié la directive import pour ta classe Driver?

  3. #3
    Membre éprouvé
    Homme Profil pro
    Technophile Web
    Inscrit en
    Mai 2007
    Messages
    930
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations professionnelles :
    Activité : Technophile Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2007
    Messages : 930
    Par défaut
    justement quand je fait un Ctrl+Shift+O (import) eclipse ne me propose pas ce choix. j'ai regardé dans l'archive fop.jar mais je n'ai pas trouvé de classe driver (j'ai téléchargerr fop du site officiel pourtant).

  4. #4
    Membre éclairé
    Profil pro
    Inscrit en
    Juin 2005
    Messages
    731
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2005
    Messages : 731
    Par défaut
    Je pense que tu as du simplement télécharger un jar deprecated ou bien ta classe driver fait partie d'une ancienne version de ta librairie FOP.
    A partir d'où as-tu télécharger FOP ?

  5. #5
    Membre éprouvé
    Homme Profil pro
    Technophile Web
    Inscrit en
    Mai 2007
    Messages
    930
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations professionnelles :
    Activité : Technophile Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2007
    Messages : 930
    Par défaut
    j'ai télécharger ce jar là
    http://apache.multidist.com/xmlgraph...-jdk1.4.tar.gz
    provenant d'un mirroir officiel

  6. #6
    Membre éclairé
    Profil pro
    Inscrit en
    Juin 2005
    Messages
    731
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2005
    Messages : 731
    Par défaut
    J'ai téléchargé moi aussi le FOP. Pas de classe Driver en effet.
    Où as-tu récupéré ton exemple de code ?
    Y'avait-t'il spécifié à un moment donné un import d'un classe Driver à partir de la librairie FOP ?

  7. #7
    Membre éprouvé
    Homme Profil pro
    Technophile Web
    Inscrit en
    Mai 2007
    Messages
    930
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations professionnelles :
    Activité : Technophile Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2007
    Messages : 930
    Par défaut
    le type avait spécifié un import de la classe org.apache.fop.apps.Driver

  8. #8
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    La classe Driver n'existe plus dans les version récentes de Fop. L'équivalent est l'objet Fop que tu récupère de la FopFactory.


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    import org.apache.fop.apps.Fop;
    import org.apache.fop.apps.FopFactory
    //...
    FopFactory.newInstance().getFop(.....)
    ;

  9. #9
    Membre éprouvé
    Homme Profil pro
    Technophile Web
    Inscrit en
    Mai 2007
    Messages
    930
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations professionnelles :
    Activité : Technophile Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2007
    Messages : 930
    Par défaut
    Citation Envoyé par tchize_ Voir le message
    La classe Driver n'existe plus dans les version récentes de Fop. L'équivalent est l'objet Fop que tu récupère de la FopFactory.


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    import org.apache.fop.apps.Fop;
    import org.apache.fop.apps.FopFactory
    //...
    FopFactory.newInstance().getFop(.....)
    ;
    ah c'est donc pour ça


    voici ma méthode pour générer un PDF
    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
    public void toPDF(File xml, File xslt, File pdf)
    		throws IOException, FOPException, TransformerException {
    		 //Construct driver
    		 Driver driver = new Driver();
     
    		 //Setup logger
    		 Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
    		 driver.setLogger(logger);
    		 MessageHandler.setScreenLogger(logger);
     
    		 //Setup Renderer (output format)
    		 driver.setRenderer(Driver.RENDER_PDF);
     
    		 //Setup output
    		 OutputStream out = new java.io.FileOutputStream(pdf);
    		 try {
    		 driver.setOutputStream(out);
     
    		 //Setup XSLT
    		 Transformer transformer = this.factory.newTransformer(new StreamSource(xslt));
     
    		 //Setup input for XSLT transformation
    		 Source src = new StreamSource(xml);
     
    		 //Resulting SAX events (the generated FO) must be piped through to FOP
    		 Result res = new SAXResult(driver.getContentHandler());
     
    		 //Start XSLT transformation and FOP processing
    		 transformer.transform(src, res);
    		 } finally {
    		 out.close();
    		}
    j'ai pas compris par quoi tu remplace
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Driver driver = new Driver();

  10. #10
    Membre Expert
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    1 466
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 1 466

  11. #11
    Membre éprouvé
    Homme Profil pro
    Technophile Web
    Inscrit en
    Mai 2007
    Messages
    930
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations professionnelles :
    Activité : Technophile Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2007
    Messages : 930
    Par défaut
    j'ai touvé ceci
    http://svn.apache.org/viewvc/xmlgrap...va?view=markup

    mais ce n'est pas documenté

  12. #12
    Membre Expert
    Profil pro
    Inscrit en
    Septembre 2006
    Messages
    1 466
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2006
    Messages : 1 466
    Par défaut
    C'est un lien direct au svn interne depuis le site officiel de fop .

  13. #13
    Membre éprouvé
    Homme Profil pro
    Technophile Web
    Inscrit en
    Mai 2007
    Messages
    930
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations professionnelles :
    Activité : Technophile Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Mai 2007
    Messages : 930
    Par défaut
    Citation Envoyé par Morbo Voir le message
    C'est un lien direct au svn interne depuis le site officiel de fop .
    c'est une question ?

  14. #14
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    Citation Envoyé par sliderman Voir le message
    j'ai pas compris par quoi tu remplace
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    Driver driver = new Driver();
    Comme je l'ai dit, par un appel à newFop sur un object de type FopFactory.

Discussions similaires

  1. [XSL-FO][FOP] Classe Driver
    Par Enfa dans le forum XSL/XSLT/XPATH
    Réponses: 4
    Dernier message: 20/09/2007, 20h51
  2. Réponses: 6
    Dernier message: 01/08/2006, 16h28
  3. Réponses: 4
    Dernier message: 22/02/2006, 15h47
  4. Noyau du deboggeur BORDBK41.dll est manquant ou non rescencé
    Par Colinbayard dans le forum C++Builder
    Réponses: 3
    Dernier message: 08/12/2004, 00h09
  5. Classe d'association ? comment est ce implémenté ??
    Par clawhammer dans le forum Diagrammes de Classes
    Réponses: 3
    Dernier message: 16/09/2004, 19h40

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo