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

XSL/XSLT/XPATH XML Discussion :

[ERROR]:org.apache.fop.fo.ValidationException XSL XML FOP


Sujet :

XSL/XSLT/XPATH XML

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre habitué
    Profil pro
    Inscrit en
    Mars 2010
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2010
    Messages : 11
    Par défaut [ERROR]:org.apache.fop.fo.ValidationException XSL XML FOP
    Bonjour à tous,
    Je suis novice dans l'utilisation de FOP et même au concept XML/XSLT/XSL-FO, et je cherche à générer un PDF à partir d'un fichier XML.
    Pour ce qui est de la génération du fichier XML, je n'ai pas de soucis (j'utilise XMLEncoder pour créer mon XML à partir de bean Java).

    Exemple de XML:

    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
     
    <?xml version="1.0" encoding="UTF-8"?> 
    <java version="1.6.0_18" class="java.beans.XMLDecoder"> 
     <object class="java.util.ArrayList"> 
      <void method="add"> 
       <object class="com.atosorigin.cacc.ir.services.dto.DisplayTransactionDto"> 
        <void property="blablatId"> 
         <string>toto</string> 
        </void> 
        <void property="blablaRef"> 
         <string>000</string> 
        </void> 
        <void property="carID"> 
         <string>015</string> 
        </void> 
        <void property="carNumb"> 
         <string>001</string> 
        </void> 
        <void property="currency"> 
         <string>EUR</string> 
        </void> 
        <void property="currentAmount"> 
         <string>282,50</string> 
        </void> 
        <void property="datePurchase"> 
         <object class="java.sql.Timestamp"> 
          <long>1310018400000</long> 
         </object> 
        </void> 
        <void property="payment"> 
         <string>Cheque</string> 
        </void> 
       </object> 
      </void> 
     </object> 
    </java>
    Un fois la génération faite, je me suis lancé dans la construction du XSL pour pouvoir créer mon Objet XSL-FO:
    J'ai commencé par les bases et je suis bloqué sur cette erreur...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: 
    "{http://www.w3.org/1999/XSL/Format}page-sequence"
    is not a valid child of "fo:layout-master-set"! (No context info available)
    Voici mon XSL:

    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
     
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:output method="xml"/>
    <xsl:template match="/java/object/void/object/void" >
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <fo:layout-master-set>  
    <fo:page-sequence master-reference="A4">
    	<fo:table-and-caption>
    	<fo:table>
     
    	</fo:table>
    	</fo:table-and-caption>
    </fo:page-sequence>
    </fo:layout-master-set>  
    </fo:root>
    </xsl:template>
    </xsl:stylesheet>
    Pour info:
    voici mon code java pour générer le Stream pour la création du 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
    33
    34
    35
    36
     
    	// Setup input and output files
    			 File xmlfile = new File("testXML.xml");
    			 File xsltfile = new File("TestXSL.xsl");
     
    			 System.out.println("Input: XML (" + xmlfile + ")");
    			 System.out.println("Stylesheet: " + xsltfile);
     
    			 System.out.println("Transforming...");
     
    			// configure fopFactory as desired
    			 FopFactory fopFactory = FopFactory.newInstance();
     
    			 FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
    			 // configure foUserAgent as desired
     
    		//	 ByteArrayOutputStream baosTestXml = new ByteArrayOutputStream();
     
    			// Construct fop with desired output format
    			 Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, baos);
     
    			// Setup XSLT
    			 TransformerFactory factory = TransformerFactory.newInstance();
    			 Transformer transformer = factory.newTransformer(new StreamSource(xsltfile));
     
    			// Set the value of a <param> in the stylesheet
    			 transformer.setParameter("versionParam", "2.0");
     
    			// Setup input for XSLT transformation
    			 Source src = new StreamSource(xmlfile);
     
    			// Resulting SAX events (the generated FO) must be piped through to FOP
    			 Result res = new SAXResult(fop.getDefaultHandler());
     
    			 // Start XSLT transformation and FOP processing
    			 transformer.transform(src, res);
    Merci pour votre aide

  2. #2
    Membre habitué
    Profil pro
    Inscrit en
    Mars 2010
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2010
    Messages : 11
    Par défaut
    Apres relecture du post... je me suis rendu compte d'une erreur
    mon XSL ressemble à ça maintenant ^^

    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
     
    <?xml version="1.0"?>
    <xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:output method="xml"/>
    <xsl:template match="/java/object/void/object/void" >
    <fo:root>
    <fo:layout-master-set>
      <fo:simple-page-master master-name="A4">
      <fo:region-body margin-top="3cm"/>
      </fo:simple-page-master>
    </fo:layout-master-set>
     
    <fo:page-sequence master-reference="A4">
    	<fo:table-and-caption>
    	<fo:table>
     
    	</fo:table>
    	</fo:table-and-caption>
    </fo:page-sequence>
     
    </fo:root>
    </xsl:template>
    </xsl:stylesheet>
    Du coup Update de l'erreur aussi :p

    org.apache.fop.fo.ValidationException:
    "{http://www.w3.org/1999/XSL/Format}table-and-caption"
    is not a valid child of "fo:page-sequence"! (No context info available)
    [EDIT:] je me base sur le site:
    http://www.w3schools.com/xslfo/xslfo_documents.asp
    D'après le site mon arborescence XML est bonne :
    sert à initialiser le contenu de ma future page (je veux juste afficher un tableau^^)

  3. #3
    Membre habitué
    Profil pro
    Inscrit en
    Mars 2010
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2010
    Messages : 11
    Par défaut
    Nouvelle maj

    Fichier XML:
    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
     
    <?xml version="1.0"?>
    <xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:output method="xml"/>
    <xsl:template match="/java/object/void/object/void" >
    <fo:root>
    <fo:layout-master-set>
      <fo:simple-page-master master-name="A4">
      <fo:region-body margin-top="3cm"/>
      </fo:simple-page-master>
    </fo:layout-master-set>
     
    <fo:page-sequence master-reference="A4">
    <fo:flow flow-name="xsl-region-body">
    	<fo:table-and-caption>
    	<fo:table table-layout="auto" width="100%" border-collapse="collapse">
     
    	<fo:table-header>
    		<fo:table-row keep-together.within-page="always" >
    			<fo:table-cell>
    			<fo:block>
    				Test
    				</fo:block>
    			</fo:table-cell>
    		</fo:table-row>
    	</fo:table-header>
     
    	<fo:table-body>
    		<fo:table-row>
    			<fo:table-cell>
    				<fo:block>
    				Test
    				</fo:block>
    			</fo:table-cell>
    		</fo:table-row>
    	</fo:table-body>	
    	</fo:table>
    	</fo:table-and-caption>
    </fo:flow>
    </fo:page-sequence>
     
    </fo:root>
    </xsl:template>
    </xsl:stylesheet>
    Nouvelle erreur:

    WARN [org.apache.fop.apps.FOUserAgent]
    > The following feature isn't implemented by Apache FOP, yet: fo:table-and-caption (on fo:table-and-caption) (No context info available)

    WARN [org.apache.fop.apps.FOUserAgent]
    > The following feature isn't implemented by Apache FOP, yet: table-layout="auto" (on fo:table) (No context info available)

    ERROR [org.apache.fop.layoutmgr.LayoutManagerMapping]
    > No LayoutManager maker for class class org.apache.fop.fo.flow.table.TableAndCaption

    ERROR [org.apache.fop.fo.FOTreeBuilder]
    > javax.xml.transform.TransformerException: java.lang.NullPointerException
    Mon code java n'a pas changé depuis le début.
    J'utilise la version 1.0 de fop (récupérée sur le repository Maven) et le jdk 1.6

    [EDIT:]http://xmlgraphics.apache.org/fop/co...-table-section

  4. #4
    Membre Expert
    Avatar de Loceka
    Profil pro
    Inscrit en
    Mars 2004
    Messages
    2 276
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2004
    Messages : 2 276
    Par défaut
    Est-ce que tu lis les messages d'erreur avant de les poster ?

    Dans le lien que tu as posté il est explicitement marqué :
    Element : table-and-caption
    Support in FOP 0.95 (stable) : NON
    Support in FOP 1.0 (stable) : NON
    Support in FOP development : NON

    Alors pourquoi le mettre dans ton code ?

    Pour les messages d'erreur précédents, il était clairement dit que l'élément "fo:layout-master-set" n'acceptait pas les éléments "page-sequence" et "table-and-caption" en tant que fils. Alors pourquoi les mettre ?

  5. #5
    Membre habitué
    Profil pro
    Inscrit en
    Mars 2010
    Messages
    11
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2010
    Messages : 11
    Par défaut
    Pour les premiers messages j'avoue que je n'étais pas très réveillé :p
    Par contre pour le dernier message d'erreur, je le comprends mais je ne vois pas par quoi remplacer les balises/attributs non gérées par FOP :s

  6. #6
    Membre Expert
    Avatar de Loceka
    Profil pro
    Inscrit en
    Mars 2004
    Messages
    2 276
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2004
    Messages : 2 276
    Par défaut
    Il faut supprimer (ne pas utiliser) l'élément "table-and-caption" car il n'est pas géré par ta version de FOP.

Discussions similaires

  1. Réponses: 0
    Dernier message: 25/05/2009, 14h41
  2. Version de FOP et fichier xsl pour fop 0.2
    Par Lolitaaa dans le forum XML/XSL et SOAP
    Réponses: 6
    Dernier message: 06/10/2008, 12h25
  3. [XSL-FO][FOP] Problème avec <xsl:apply-template/>
    Par citizen87 dans le forum XSL/XSLT/XPATH
    Réponses: 2
    Dernier message: 10/04/2008, 12h00
  4. [FOP][debutante][ERROR] org.apache.fop.fo.flow.Inline
    Par norkius dans le forum XML/XSL et SOAP
    Réponses: 8
    Dernier message: 05/05/2006, 14h31
  5. [XSL-FO] [Débutant] xml, xsl, fo fop pdf ...ahhh !
    Par enigma dans le forum XSL/XSLT/XPATH
    Réponses: 2
    Dernier message: 05/08/2005, 09h14

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