You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Bracchi Cabannes Christophe <ch...@ac-toulouse.fr> on 2001/04/18 16:08:43 UTC

Problem when I try to transform XML / XSLT in PDF

  Hi !

  I'm work in Windoze with TOMCAT/JBUILDER, with servlet.

  I have a problem when I try to transform XML / XSLT in PDF : WARNING:
Unknown formatting object ^Document

  I don't understand why !! XSLT and XML and DTD are 3 files provides
with src of FOP 0.18 (Exemples.xml, Document.xsl and Document.dtd in
doc\exemples\svg). I try with others files but there is the same pbl,
that break with first "balise".
  In the classpath there is Xalan, Xerces and FOP. (If I add W3C there
is nothing more).

  If instead of use XML et XSLT, I give directly an fo file in
InputSource, that's work.

---------------------------
This is the implementation :

    XSLTInputHandler xi = new XSLTInputHandler( new
File("Exemples.xml"), new File("Document.xsl") );
    InputSource foFile = xi.getInputSource();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    Driver driver = new Driver(foFile, out);
    driver.setRenderer(Driver.RENDER_PDF);
    driver.run();

    byte[] content = out.toByteArray();
    response.setContentType("application/pdf");
    response.setContentLength(content.length);
    response.getOutputStream().write(content);
    response.getOutputStream().flush();

---------------------------
Begin of Exemples.xml :

<?xml version="1.0"?>
<!DOCTYPE Document SYSTEM "Document.dtd">
<Document>
 <Title>SVG Tests</Title>
 <Description>
....

Begin of Document.xsl :

<?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"
xmlns:svg="http://www.w3.org/2000/svg">
 <xsl:output method="xml" indent="yes"/>
 <xsl:template match="Document">
  <fo:root>
   <fo:layout-master-set>
...

---------------------------
The error :

org.apache.fop.apps.FOPException
WARNING: Unknown formatting object ^Document

---------------------------

  Have you an idea ?

  Thank's,

  Christophe.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Re: Transform XML / XSLT in PDF ... THE END (ouf !)

Posted by Bracchi Cabannes Christophe <ch...@ac-toulouse.fr>.
HI !

Finally, I found where was the problem.     :-)))))))

JBUILDER uses TOMCAT for the execution of the server of servlet.
By defect the classpath is automatically updated with addition of the
classes jbuilder/tomcat of which xml.jar.
There is conflict between xml.jar and fop.jar.
To solve the problem it is enough to be arranged so that in the
classpath fop is before xml, and the turn is played!!

Bye.




Bracchi Cabannes Christophe a �crit :

> Hi !
>
> Currently my problem is only at the level of the production of the
> file fo starting from a file XML and XSLT.
> I made a series of alternative to produce the fo.
>
> Here are different result:
>
>     // TEST 1
>     /* ERREUR : javax.xml.transform.TransformerConfigurationException:
> File "C:\maia\webapps\maia\test.xsl" not found.
>     ALORS QUE LE FICHIER EST BIEN PRESENT !!!! // WHEREAS THE FILE
> EAST WELL PRESENT!!! */
>     utilitaires.XSLTInputHandler xi = new
> utilitaires.XSLTInputHandler(xmlF, xslF);
>     InputSource foFile = xi.getInputSource();
>     etc...
>    (In this example I re-examined the XSLTInputHandler class in order
> to eliminate the concept of version (cf NB fine of page) and to
> produce
> the file fo r��lement.).
>
>     // TEST 2
>     /* ERREUR : java.lang.NoSuchMethodError */
>     java.io.Writer writer;
>     writer = new StringWriter();
>     java.io.Reader reader;
>     XSLTransform.transform(xmlFile, xsltFile, writer);
>     writer.flush();
>     writer.close();
>     reader = new StringReader(writer.toString());
>     InputSource foFile = new InputSource(reader);
>     etc...
>
>     // TEST 3
>     /* ERREUR : java.lang.NoSuchMethodError */
>     javax.xml.transform.TransformerFactory tFactory =
> javax.xml.transform.TransformerFactory.newInstance();
>     javax.xml.transform.Transformer transformer =
> tFactory.newTransformer (new
> javax.xml.transform.stream.StreamSource(xsltFile));
>     transformer.transform (new
> javax.xml.transform.stream.StreamSource(xmlFile), new
> javax.xml.transform.stream.StreamResult(new
> java.io.FileOutputStream("foo.out")));
>     etc...
>
>     // TEST 4
>     /* ERREUR : java.lang.reflect.InvocationTargetException:
> java.lang.NoSuchMethodError: org.w3c.dom.Node: method
> getLocalName()Ljava/lang/String; not found */
>     Xslt xsl = new Xslt();
>     xsl.setInfile(xmlFile);
>     xsl.setOutfile("foo.out");
>     xsl.setXsltfile(xsltFile);
>     xsl.execute();
>     etc...
>
>
> They plant all !!!!    :-(
>
>  I however succeeded in making move the problem...  see TEST 4.
> On the level of the last error, I obtain the error message
> "java.lang.reflect.InvocationTargetException:
> java.lang.NoSuchMethodError: org.w3c.dom.Node: method
> getLocalName()Ljava/lang/String; not found".  That leaves hope.
>
> The Node class is abstract.  I suppose that a polymorphic system was
> created and call a class which inherits Node.
> Two possibilities :
> - Either I forgot to put in the classpath this sub-class (but then
> which is this jar?),
> - That is to say the method getLocalName was not implemented is the
> sub-class... (but what then I to make there?)
>
> Have you an idea on the thing?
>
> Thank you.
>
> NB : About the preceding message, I found where is the problem,
> without being able to solve it.  A concept of version was set up and
> the method return xml instead  of the fo, not cool! That's explain the
> error message.
>
>
> Bracchi Cabannes Christophe a �crit :
>
>>   Hi !
>>
>>   I'm work in Windoze with TOMCAT/JBUILDER, with servlet.
>>
>>   I have a problem when I try to transform XML / XSLT in PDF :
>> WARNING:
>> Unknown formatting object ^Document
>>
>>   I don't understand why !! XSLT and XML and DTD are 3 files
>> provides
>> with src of FOP 0.18 (Exemples.xml, Document.xsl and Document.dtd in
>>
>> doc\exemples\svg). I try with others files but there is the same
>> pbl,
>> that break with first "balise".
>>   In the classpath there is Xalan, Xerces and FOP. (If I add W3C
>> there
>> is nothing more).
>>
>>   If instead of use XML et XSLT, I give directly an fo file in
>> InputSource, that's work.
>>
>> ---------------------------
>> This is the implementation :
>>
>>     XSLTInputHandler xi = new XSLTInputHandler( new
>> File("Exemples.xml"), new File("Document.xsl") );
>>     InputSource foFile = xi.getInputSource();
>>     ByteArrayOutputStream out = new ByteArrayOutputStream();
>>     Driver driver = new Driver(foFile, out);
>>     driver.setRenderer(Driver.RENDER_PDF);
>>     driver.run();
>>
>>     byte[] content = out.toByteArray();
>>     response.setContentType("application/pdf");
>>     response.setContentLength(content.length);
>>     response.getOutputStream().write(content);
>>     response.getOutputStream().flush();
>>
>> ---------------------------
>> Begin of Exemples.xml :
>>
>> <?xml version="1.0"?>
>> <!DOCTYPE Document SYSTEM "Document.dtd">
>> <Document>
>>  <Title>SVG Tests</Title>
>>  <Description>
>> ....
>>
>> Begin of Document.xsl :
>>
>> <?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"
>> xmlns:svg="http://www.w3.org/2000/svg">
>>  <xsl:output method="xml" indent="yes"/>
>>  <xsl:template match="Document">
>>   <fo:root>
>>    <fo:layout-master-set>
>> ...
>>
>> ---------------------------
>> The error :
>>
>> org.apache.fop.apps.FOPException
>> WARNING: Unknown formatting object ^Document
>>
>> ---------------------------
>>
>>   Have you an idea ?
>>
>>   Thank's,
>>
>>   Christophe.
>>
>> -------------
>> -------------------------------------------------------
>> To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
>> For additional commands, email: fop-dev-help@xml.apache.org
>
>    ----------------------------------------------------------------
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
> For additional commands, email: fop-dev-help@xml.apache.org
>

Transform XML / XSLT in PDF ... THE RETURN

Posted by Bracchi Cabannes Christophe <ch...@ac-toulouse.fr>.
Hi !

Currently my problem is only at the level of the production of the file fo
starting from a file XML and XSLT.
I made a series of alternative to produce the fo.

Here are different result:

    // TEST 1
    /* ERREUR : javax.xml.transform.TransformerConfigurationException: File
"C:\maia\webapps\maia\test.xsl" not found.
    ALORS QUE LE FICHIER EST BIEN PRESENT !!!! // WHEREAS THE FILE EAST
WELL PRESENT!!! */
    utilitaires.XSLTInputHandler xi = new
utilitaires.XSLTInputHandler(xmlF, xslF);
    InputSource foFile = xi.getInputSource();
    etc...
   (In this example I re-examined the XSLTInputHandler class in order to
eliminate the concept of version (cf NB fine of page) and to produce
the file fo r��lement.).

    // TEST 2
    /* ERREUR : java.lang.NoSuchMethodError */
    java.io.Writer writer;
    writer = new StringWriter();
    java.io.Reader reader;
    XSLTransform.transform(xmlFile, xsltFile, writer);
    writer.flush();
    writer.close();
    reader = new StringReader(writer.toString());
    InputSource foFile = new InputSource(reader);
    etc...

    // TEST 3
    /* ERREUR : java.lang.NoSuchMethodError */
    javax.xml.transform.TransformerFactory tFactory =
javax.xml.transform.TransformerFactory.newInstance();
    javax.xml.transform.Transformer transformer = tFactory.newTransformer
(new javax.xml.transform.stream.StreamSource(xsltFile));
    transformer.transform (new
javax.xml.transform.stream.StreamSource(xmlFile), new
javax.xml.transform.stream.StreamResult(new
java.io.FileOutputStream("foo.out")));
    etc...

    // TEST 4
    /* ERREUR : java.lang.reflect.InvocationTargetException:
java.lang.NoSuchMethodError: org.w3c.dom.Node: method
getLocalName()Ljava/lang/String; not found */
    Xslt xsl = new Xslt();
    xsl.setInfile(xmlFile);
    xsl.setOutfile("foo.out");
    xsl.setXsltfile(xsltFile);
    xsl.execute();
    etc...


They plant all !!!!    :-(

 I however succeeded in making move the problem...  see TEST 4.
On the level of the last error, I obtain the error message
"java.lang.reflect.InvocationTargetException: java.lang.NoSuchMethodError:
org.w3c.dom.Node: method getLocalName()Ljava/lang/String; not found".  That
leaves hope.

The Node class is abstract.  I suppose that a polymorphic system was
created and call a class which inherits Node.
Two possibilities :
- Either I forgot to put in the classpath this sub-class (but then which is
this jar?),
- That is to say the method getLocalName was not implemented is the
sub-class... (but what then I to make there?)

Have you an idea on the thing?

Thank you.

NB : About the preceding message, I found where is the problem, without
being able to solve it.  A concept of version was set up and the method
return xml instead  of the fo, not cool! That's explain the error message.


Bracchi Cabannes Christophe a �crit :

>   Hi !
>
>   I'm work in Windoze with TOMCAT/JBUILDER, with servlet.
>
>   I have a problem when I try to transform XML / XSLT in PDF : WARNING:
> Unknown formatting object ^Document
>
>   I don't understand why !! XSLT and XML and DTD are 3 files provides
> with src of FOP 0.18 (Exemples.xml, Document.xsl and Document.dtd in
> doc\exemples\svg). I try with others files but there is the same pbl,
> that break with first "balise".
>   In the classpath there is Xalan, Xerces and FOP. (If I add W3C there
> is nothing more).
>
>   If instead of use XML et XSLT, I give directly an fo file in
> InputSource, that's work.
>
> ---------------------------
> This is the implementation :
>
>     XSLTInputHandler xi = new XSLTInputHandler( new
> File("Exemples.xml"), new File("Document.xsl") );
>     InputSource foFile = xi.getInputSource();
>     ByteArrayOutputStream out = new ByteArrayOutputStream();
>     Driver driver = new Driver(foFile, out);
>     driver.setRenderer(Driver.RENDER_PDF);
>     driver.run();
>
>     byte[] content = out.toByteArray();
>     response.setContentType("application/pdf");
>     response.setContentLength(content.length);
>     response.getOutputStream().write(content);
>     response.getOutputStream().flush();
>
> ---------------------------
> Begin of Exemples.xml :
>
> <?xml version="1.0"?>
> <!DOCTYPE Document SYSTEM "Document.dtd">
> <Document>
>  <Title>SVG Tests</Title>
>  <Description>
> ....
>
> Begin of Document.xsl :
>
> <?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"
> xmlns:svg="http://www.w3.org/2000/svg">
>  <xsl:output method="xml" indent="yes"/>
>  <xsl:template match="Document">
>   <fo:root>
>    <fo:layout-master-set>
> ...
>
> ---------------------------
> The error :
>
> org.apache.fop.apps.FOPException
> WARNING: Unknown formatting object ^Document
>
> ---------------------------
>
>   Have you an idea ?
>
>   Thank's,
>
>   Christophe.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
> For additional commands, email: fop-dev-help@xml.apache.org