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 "Wolf Gustavo (SGC-EXT)" <Gu...@etat.ge.ch> on 2001/07/05 17:49:38 UTC

XSLTInputHandler not doing its job??

Hi,
      as I said a few hours ago, I have the following code:

        InputHandler inputHandler = new
XSLTInputHandler(xmlInputSource,xslInputSource);
        InputSource inputSource = inputHandler.getInputSource();
        XMLReader  parser = (XMLReader)
Class.forName(this.parserClass).newInstance();
 
parser.setFeature("http://xml.org/sax/features/namespace-prefixes",true);
/**
* Creates the driver telling it to write the output to a file.
*/
        Driver driver = new Driver();
        driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer");
//  ERROR IN THE FOLLOWING LINE
        driver.buildFOTree(parser, inputSource);
        File test = new File("test.pdf");
        driver.setOutputStream(new java.io.FileOutputStream(test));
        driver.format();
        driver.render();

In the second line, InputSource inputSource is suppossed to be the .fo file
after the processing of xmlInputSource by xslInputSource.

I am using as xmlInputSource and xslInputSource two files that I took from
the chap 15 of the XMLbible (attached).

Now, when the program tries to execute "driver.buildFOTree(parser,
inputSource);", I get the following msg and Exception:

"building formatting object tree
 WARNING: Unknown formatting object ^PERIODIC_TABLE
 FOPException: org.xml.sax.SAXException (msg: null)"

It seems to me that XSLTInputHandler is not doing its job properly, because
of the WARNING.

Again, if I run a line command with 
Fop -xml xmlInputSource -xsl xslInputSource -pdf test.pdf 
everything is OK, which tells me that there shouldn't be a problem with the
input files.

Does anyone knows how to cure this? 

Thanks a lot,
                                Gustavo





 <<prueba.xml>>  <<prueba.xsl>> 



Re: XSLTInputHandler not doing its job??

Posted by Abdul Wahab <wa...@medical-online.net>.
Hi Gustavo, Karen and All!

I am also using the same coding as how u code(below) to covert from XML to
PDF using XSL.
But I am getting "No Such MethodError" exception eventhough the method is
existed in class file.
Could u please help me to solve this problem.

java.lang.NoSuchMethodError
        at
org.apache.xpath.DOM2Helper.getNamespaceOfNode(DOM2Helper.java:348)
        at org.apache.xpath.patterns.NodeTest.execute(NodeTest.java:471)

Thanks,
Wahab.

----- Original Message -----
From: "Wolf Gustavo (SGC-EXT)" <Gu...@etat.ge.ch>
To: "Fop (E-mail)" <fo...@xml.apache.org>
Sent: Thursday, July 05, 2001 11:49 PM
Subject: XSLTInputHandler not doing its job??


> Hi,
>       as I said a few hours ago, I have the following code:
>
>         InputHandler inputHandler = new
> XSLTInputHandler(xmlInputSource,xslInputSource);
>         InputSource inputSource = inputHandler.getInputSource();
>         XMLReader  parser = (XMLReader)
> Class.forName(this.parserClass).newInstance();
>
> parser.setFeature("http://xml.org/sax/features/namespace-prefixes",true);
> /**
> * Creates the driver telling it to write the output to a file.
> */
>         Driver driver = new Driver();
>         driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer");
> //  ERROR IN THE FOLLOWING LINE
>         driver.buildFOTree(parser, inputSource);
>         File test = new File("test.pdf");
>         driver.setOutputStream(new java.io.FileOutputStream(test));
>         driver.format();
>         driver.render();
>
> In the second line, InputSource inputSource is suppossed to be the .fo
file
> after the processing of xmlInputSource by xslInputSource.
>
> I am using as xmlInputSource and xslInputSource two files that I took from
> the chap 15 of the XMLbible (attached).
>
> Now, when the program tries to execute "driver.buildFOTree(parser,
> inputSource);", I get the following msg and Exception:
>
> "building formatting object tree
>  WARNING: Unknown formatting object ^PERIODIC_TABLE
>  FOPException: org.xml.sax.SAXException (msg: null)"
>
> It seems to me that XSLTInputHandler is not doing its job properly,
because
> of the WARNING.
>
> Again, if I run a line command with
> Fop -xml xmlInputSource -xsl xslInputSource -pdf test.pdf
> everything is OK, which tells me that there shouldn't be a problem with
the
> input files.
>
> Does anyone knows how to cure this?
>
> Thanks a lot,
>                                 Gustavo
>
>
>
>
>
>  <<prueba.xml>>  <<prueba.xsl>>
>
>
>


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


> ---------------------------------------------------------------------
> 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


Re: XSLTInputHandler not doing its job??

Posted by Karen Lease <kl...@club-internet.fr>.
Hi Gustavo,

I'm not 100% sure, but it looks to me as if you get the parser from the
inputHandler instead of using newInstance, it will work. That's what FOP
does when you pass it the xml and xsl in the command line.

InputHandler inputHandler = new
XSLTInputHandler(xmlInputSource,xslInputSource);
XMLReader parser = inputHandler.getParser();
InputSource inputSource = inputHandler.getInputSource();

Then pass that to the driver.

What is happening is that the inputSource you're getting back now is
just returning your original XML file. When you call getParser() on the
XSLTInputHandler, it's actually going to "parse" the FO file which
results from transforming your xml with the xsl.

Hope that helps,
Karen Lease


"Wolf Gustavo (SGC-EXT)" wrote:
> 
> Hi,
>       as I said a few hours ago, I have the following code:
> 
>         InputHandler inputHandler = new
> XSLTInputHandler(xmlInputSource,xslInputSource);
>         InputSource inputSource = inputHandler.getInputSource();
>         XMLReader  parser = (XMLReader)
> Class.forName(this.parserClass).newInstance();
> 
> parser.setFeature("http://xml.org/sax/features/namespace-prefixes",true);
> /**
> * Creates the driver telling it to write the output to a file.
> */
>         Driver driver = new Driver();
>         driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer");
> //  ERROR IN THE FOLLOWING LINE
>         driver.buildFOTree(parser, inputSource);
>         File test = new File("test.pdf");
>         driver.setOutputStream(new java.io.FileOutputStream(test));
>         driver.format();
>         driver.render();
> 
> In the second line, InputSource inputSource is suppossed to be the .fo file
> after the processing of xmlInputSource by xslInputSource.
> 
> I am using as xmlInputSource and xslInputSource two files that I took from
> the chap 15 of the XMLbible (attached).
> 
> Now, when the program tries to execute "driver.buildFOTree(parser,
> inputSource);", I get the following msg and Exception:
> 
> "building formatting object tree
>  WARNING: Unknown formatting object ^PERIODIC_TABLE
>  FOPException: org.xml.sax.SAXException (msg: null)"
> 
> It seems to me that XSLTInputHandler is not doing its job properly, because
> of the WARNING.
> 
> Again, if I run a line command with
> Fop -xml xmlInputSource -xsl xslInputSource -pdf test.pdf
> everything is OK, which tells me that there shouldn't be a problem with the
> input files.
> 
> Does anyone knows how to cure this?
> 
> Thanks a lot,
>                                 Gustavo
> 
>  <<prueba.xml>>  <<prueba.xsl>>
> 
>   ------------------------------------------------------------------------
>                  Name: prueba.xml
>    prueba.xml    Type: unspecified type (application/octet-stream)
>              Encoding: quoted-printable
> 
>    prueba.xslName: prueba.xsl
>              Type: unspecified type (application/octet-stream)
> 
>   ------------------------------------------------------------------------
> ---------------------------------------------------------------------
> 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