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 "Cristóbal Ruiz, Oscar" <oc...@aena.es> on 2003/12/29 12:11:19 UTC

How to use XSL-FOP-Java together

Hi there.
I dont get to tranform directly from XML to a PDF file.
I tried to execute the simplest example... but I cannot do it.
I get this exception: Content is not allowed in prolog.
What is the meaning of that?

Thanks in advance.

My xsl file is:
*******************************************
<?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 indent="yes"/>

  <xsl:template match="/">
    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

      <fo:layout-master-set>
        <fo:simple-page-master master-name="only">
          <fo:region-body/>
        </fo:simple-page-master>
      </fo:layout-master-set>

      <fo:page-sequence master-reference="only">

        <fo:flow flow-name="xsl-region-body">
          <xsl:apply-templates select="//ATOM"/>
        </fo:flow>

      </fo:page-sequence>

    </fo:root>
  </xsl:template>

  <xsl:template match="ATOM">
    <fo:block font-size="20pt" font-family="serif"
              line-height="30pt">
      <xsl:value-of select="NAME"/>
    </fo:block>
  </xsl:template>

</xsl:stylesheet>
*******************************************

My xml file is:
*******************************************
<?xml version = '1.0'?>
<ATOM>
 <NAME>
	Plata
 </NAME>
</ATOM>
*******************************************

I receive the next stack trace:
********************************
javax.xml.transform.TransformerException: org.xml.sax.SAXParseException:
Content is not allowed in prolog. 	at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
686) 	at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
1088) 	at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
1066) 	at reporte.processor.Procesador.XML2PDF(Procesador.java:132) 	at
reporte.Marco1.jButton1_actionPerformed(Marco1.java:83) 	at
reporte.Marco1_jButton1_actionAdapter.actionPerformed(Marco1.java:124) 	at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)
at
javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButto
n.java:1817) 	at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:4
19) 	at
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257) 	at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener
.java:245) 	at java.awt.Component.processMouseEvent(Component.java:5134)
at java.awt.Component.processEvent(Component.java:4931) 	at
java.awt.Container.processEvent(Container.java:1566) 	at
java.awt.Component.dispatchEventImpl(Component.java:3639) 	at
java.awt.Container.dispatchEventImpl(Container.java:1623) 	at
java.awt.Component.dispatchEvent(Component.java:3480) 	at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450) 	at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165) 	at
java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095) 	at
java.awt.Container.dispatchEventImpl(Container.java:1609) 	at
java.awt.Window.dispatchEventImpl(Window.java:1590) 	at
java.awt.Component.dispatchEvent(Component.java:3480) 	at
java.awt.EventQueue.dispatchEvent(EventQueue.java:450) 	at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.ja
va:197) 	at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java
:150) 	at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144) 	at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136) 	at
java.awt.EventDispatchThread.run(EventDispatchThread.java:99) Caused by:
org.xml.sax.SAXParseException: Content is not allowed in prolog. 	at
org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) 	at
org.apache.xml.dtm.ref.DTMManagerDefault.getDTM(DTMManagerDefault.java:349)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
630) 	... 28 more --------- org.xml.sax.SAXParseException: Content is not
allowed in prolog. 	at
org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source) 	at
org.apache.xml.dtm.ref.DTMManagerDefault.getDTM(DTMManagerDefault.java:349)
at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
630) 	at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
1088) 	at
org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:
1066) 	at reporte.processor.Procesador.XML2PDF(Procesador.java:132) 	at
reporte.Marco1.jButton1_actionPerformed(Marco1.java:83) 	at
reporte.Marco1_jButton1_actionAdapter.actionPerformed(Marco1.java:124) 	at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)
at
javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButto
n.java:1817) 	at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:4
19) 	at
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257) 	at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener
.java:245) 	at java.awt.Component.processMouseEvent(Component.java:5134)
at java.awt.Component.processEvent(Component.java:4931) 	at
java.awt.Container.processEvent(Container.java:1566) 	at
java.awt.Component.dispatchEventImpl(Component.java:3639) 	at
java.awt.Container.dispatchEventImpl(Container.java:1623) 	at
java.awt.Component.dispatchEvent(Component.java:3480) 	at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450) 	at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165) 	at
java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095) 	at
java.awt.Container.dispatchEventImpl(Container.java:1609) 	at
java.awt.Window.dispatchEventImpl(Window.java:1590) 	at
java.awt.Component.dispatchEvent(Component.java:3480) 	at
java.awt.EventQueue.dispatchEvent(EventQueue.java:450) 	at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.ja
va:197) 	at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java
:150) 	at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144) 	at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136) 	at
java.awt.EventDispatchThread.run(EventDispatchThread.java:99) 
********************************

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


Re: How to use XSL-FOP-Java together

Posted by "Rodolfo M. Raya" <ro...@heartsome.net>.
On Mon, 2003-12-29 at 08:11, "Cristóbal Ruiz, Oscar" wrote:
> Hi there.
> I dont get to tranform directly from XML to a PDF file.
> I tried to execute the simplest example... but I cannot do it.
> I get this exception: Content is not allowed in prolog.
> What is the meaning of that?Hi Oscar,

I saw this error many, many times. I bet that there is an Unicode mark
_before_ your xml declaration.

Open your file with a _real_ text editor like VIM (not with Notepad or
Wordpad) and check the first bytes. It is possible that you find
something like:

¥¢<?xml version="1.0"


Get rid of the first two bytes and your file will be fine.

Hope this helps,
Rodolfo
-- 
Rodolfo M. Raya <ro...@heartsome.net>
Heartsome Holdings Pte.Ltd. 


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


Re: How to use XSL-FOP-Java together

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Cristóbal Ruiz, Oscar wrote:
> I get this exception: Content is not allowed in prolog.

This means there are non-whitespace characters before the document
element (and outside the XML decl and any PI or XML comment). Some
older parsers reported this errorneously if the input file was
UTF-16 encoded.
Check:
- Which JDK are you using? If you use a 1.4 series JDK, upgrade to
  the latest release. The XML parser contained in the 1.4 JDK overrides
  the parser coming with FOP.
- If you use the Xerces parser distributed with FOP, check that you
  are using the 0.20.5 FOP release.
- Check the encoding of you XML source. Make sure it is UTF-8, as
  assumed by the parser.
- Do a hex dump of you XML source and check whether non-whitespace but
  otherwise invisible character like a non-breaking space sneaked in.

> <?xml version = '1.0'?>
                ^ ^
Well, I'd remove these spaces just to be sure.

J.Pietschmann


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