You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by yl...@amadeus.net on 2002/07/22 16:44:38 UTC

Re: Unknown formatting object - Using the JDK1.4 parser


> > I am getting the following error when using fop v0.20.4.
> > It worked ok before with v0.20.2 and I removed the use of Xerces since
> > then.
> ...
> > [ERROR] Unknown formatting object ^
> >
> > ------------------------------------
> > Exception is: Root element must be root, not (none)

> The error message says that the fo:root element is
> not recognized, and FOP got empty strings for both
> namespace and element names.
>
> Does your FO file work with the FOP command line
> application?
> Did you mean you do not use Xerces as XML parser?
> If so, does your FO file work if the Xerces.jar in
> the lib is replaced by your XML parser?
> Does the parser by default recognize namespaces, or
> do you set it up so that it recognizes namespaces?


If I try to launch the process directly with fop, I get another error
(which I'll worry about later on)...
My application embeeding Fop is running using JDK1.4 and I want to use the
JDK parser rather than Xerces.
I don't know if it recognizes namespaces...

How I create the parser:
  private static XMLReader createParser()
  {
    try
    {
      SAXParserFactory theFactory = SAXParserFactory.newInstance();
      SAXParser theSaxParser = theFactory.newSAXParser();
      return theSaxParser.getXMLReader();
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
    return null;
  }


Does anyone have any experience in using the JDK1.4 parser ? Is there any
special setup to do ?

*-*-*-*-*-*-*-*-*-*-*-

my previous posting as a reminder of the problem.


Hi,


I am getting the following error when using fop v0.20.4.
It worked ok before with v0.20.2 and I removed the use of Xerces since
then.
The error message is not very helpful. What could that be ???

I am lost. Please help

----------------------------------------
my Java code :

...
      // Get the StreamSource object from the style sheet file.
      StreamSource theStyleSource = new StreamSource(thePrintStyleSheet);

      // Get Transformer for output.
      TransformerFactory theFactory = TransformerFactory.newInstance();
      Transformer theTransformer =
theFactory.newTransformer(theStyleSource);


      // Get the result of the transformer from the Source object.
      ByteArrayOutputStream theFoStream = new ByteArrayOutputStream();
      StreamResult theResult = new StreamResult(theFoStream);
      theTransformer.transform(theSource, theResult);

      PrinterJob thePrinterJob = PrinterJob.getPrinterJob();
      // If the user has not cancel the dialog.
      if (thePrinterJob.printDialog())
      {

System.out.println("--------- TRACE--setting logger");
        //setting the log correctly
        Logger theLogger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);
        org.apache.fop.messaging.MessageHandler.setScreenLogger(theLogger);

        Driver theDriver = new Driver();
        theDriver.setLogger(theLogger);

System.out.println("--------- TRACE--setting renderer");
        FopPrintRenderer theRenderer = new FopPrintRenderer(thePrinterJob);
        theDriver.setRenderer(theRenderer);



System.out.println("--------- TRACE--creating parser");

        XMLReader theParser = createParser();

System.out.println("--------- TRACE--rendering");

        ByteArrayInputStream theByteArrayInputStream = new
ByteArrayInputStream(theFoStream.toByteArray());

        theDriver.render(theParser, new
InputSource(theByteArrayInputStream));
...


  private static XMLReader createParser()
  {
    try
    {
      SAXParserFactory theFactory = SAXParserFactory.newInstance();
      SAXParser theSaxParser = theFactory.newSAXParser();
      return theSaxParser.getXMLReader();
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
    return null;
  }

-----------------------------
output:
...
--------- TRACE--setting logger
--------- TRACE--setting renderer
--------- TRACE--creating parser
--------- TRACE--rendering
[INFO] building formatting object tree
[ERROR] Unknown formatting object ^

------------------------------------
Exception is: Root element must be root, not (none)

------------------------------------
Start of the fop input

<?xml version="1.0" encoding="UTF-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="all" page-height="21cm" page-width
="29.7cm" margin-top="1cm" margin-bottom="2cm" margin-left="1.5cm"
margin-right="1.5cm"><fo:region-before extent="7cm"/>
<fo:region-body margin-top="2cm"/>
<fo:region-after extent="1.5cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-name="all">
<fo:static-content flow-name="xsl-region-before">
<fo:table><fo:table-column column-width="0.5cm"/>
<fo:table-column column-width="8.5cm"/>
<fo:table-column column-width="8.5cm"/>
<fo:table-column column-width="8.5cm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell
etc...








Re: Unknown formatting object - Using the JDK1.4 parser

Posted by "J.Pietschmann" <j3...@yahoo.de>.
ylamoureux@amadeus.net wrote:
>       SAXParserFactory theFactory = SAXParserFactory.newInstance();
>       SAXParser theSaxParser = theFactory.newSAXParser();
>       return theSaxParser.getXMLReader();

Turn on namespace recognition (see JavaDocs). It should
be turned on by default, but you never know.

J.Pietschmann