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:
Un fois la génération faite, je me suis lancé dans la construction du XSL pour pouvoir créer mon Objet XSL-FO:
Code : Sélectionner tout - Visualiser dans une fenêtre à part 
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
J'ai commencé par les bases et je suis bloqué sur cette erreur...
Voici mon XSL:
Code : Sélectionner tout - Visualiser dans une fenêtre à part 
2
3
4javax.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)
Pour info:
Code : Sélectionner tout - Visualiser dans une fenêtre à part 
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
voici mon code java pour générer le Stream pour la création du pdf:
Merci pour votre aide
Code : Sélectionner tout - Visualiser dans une fenêtre à part 
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);

 

 
		
		 
        

 
			
			
 
   


 [ERROR]:org.apache.fop.fo.ValidationException XSL XML FOP
 [ERROR]:org.apache.fop.fo.ValidationException XSL XML FOP
				 Répondre avec citation
  Répondre avec citation
Partager