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 Miguel Tablado <mi...@gmail.com> on 2008/08/20 16:56:59 UTC

Problems with Apache FOP and Barcode4j

Hi folks,

I'm upgrading my FOP version from 0.20 up to 0.95 and I'm getting two
problems.

The first one, and most important, is that I can't generate barcodes with
Apache FOP and Barcode4j projects. I don't know why but I'm getting this
error:
javax.xml.transform.TransformerException: org.xml.sax.SAXException:
Mismatch: page-sequence (http://www.w3.org/1999/XSL/Format) vs. root
(http://www.w3.org/1999/XSL/Format)

I know that this error uses to be a follow-up error but I have no more
detail and I'm lost since I have reached a strange situation.

I have the following code on my xslt.
- Definition:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:fo="http://www.w3.org/1999/XSL/Format"
                xmlns:barcode="org.krysalis.barcode4j.xalan.BarcodeExt"
                xmlns:svg="http://www.w3.org/2000/svg"
                extension-element-prefixes="barcode">
- Template:
	<xsl:template match="texto[@class='CODIGO_BARRAS']">
        <fo:block>
          <fo:instream-foreign-object>
            <xsl:variable name="barcode-cfg">
              <barcode>
                <code128>
                  <human-readable>none</human-readable>
                  <height>5mm</height>
                  <quiet-zone enabled="false"/>
                </code128>
              </barcode>
            </xsl:variable>
            <xsl:copy-of select="barcode:generate($barcode-cfg, .)"/>
          </fo:instream-foreign-object>
        </fo:block>
	</xsl:template>

- Call example:
<texto class="CODIGO_BARRAS" text-align="left" font-size="12pt"
module="0.45" height="10" >D106696</texto>				             

- Java code:
		The following code throws the exception.
		
    public void convertXmlToPdf(final StreamSource xmlSource, final String
xsl, final OutputStream pdf) throws Exception {

        FOUserAgent foUserAgent = instance.fopFactory.newFOUserAgent();
        // todo, configure urls.
       
foUserAgent.setBaseURL("file:///C:/TRIBUTOS/apps/gt_ear/build/gt_ear/gt_web/");
       
foUserAgent.setFontBaseURL("file:///C:/TRIBUTOS/apps/gt_ear/build/gt_ear/gt_web/");
        foUserAgent.setAuthor("Miguel Tablado");

        //Setup XSLT
        Fop fop = instancia.fopFactory.newFop(MimeConstants.MIME_PDF,
foUserAgent, pdf);

        TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer = factory.newTransformer(new
StreamSource(xsl));

        // Parámetro PATH de las imagenes
        transformer.setParameter("AG_XSLFO_PATH_IMAGES",
AGFunciones.agregarProtocoloFile(AGConfig.get("VirtualDirTemplates")) +
"/images");

        //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(xmlSource, res);

    }

		The following one creates the .fo file with no problems.
    private void convertXML2FO(final StreamSource src, final String xslt)
throws IOException, TransformerException
            , FOPException {
        //Setup output
        final File fo = new File(AGConfig.get("writeXmlFoPdfIntoFile"));
        final OutputStream out = new FileOutputStream(fo);

        try {
            //Setup XSLT
            TransformerFactory factory = TransformerFactory.newInstance();
            Transformer transformer = factory.newTransformer(new
StreamSource(xslt));

            // Parámetro PATH de las imagenes
            transformer.setParameter("AG_XSLFO_PATH_IMAGES",
AGFunciones.agregarProtocoloFile(AGConfig.get("VirtualDirTemplates")) +
"/images");

            //Resulting SAX events (the generated FO) must be piped through
to FOP
            Result res = new StreamResult(out);

            //Start XSLT transformation and FOP processing
            transformer.transform(src, res);

        } finally {
            out.close();
        }
    }

		The .fo generated snippet is something like this:
		<fo:block>
			<fo:instream-foreign-object>
				<svg:svg height="1.3316mm" viewBox="0 0 120.54 1.3316" width="120.54mm">
					<svg:g style="fill:black; stroke:none">
						<svg:rect height="1.3316" width="0.42" x="0" y="0"/>
						<svg:rect height="1.3316" width="0.21" x="0.63" y="0"/>
						...
						<svg:rect height="1.3316" width="0.42" x="120.12" y="0"/>
					</svg:g>
				</svg:svg>
			</fo:instream-foreign-object>
		</fo:block>
		
Trying to find out the original problem I have tried two things, the first
one is to replace Barcode4j call to svg code.
Any problem, the resultant pdf has a pretty barcode.
		
The second one, that follows me to the second problem mentioned at
introduction, has been configuring logs to get more information, 
but I didn't get success. I'm logging with Bea Weblogic 8.1 SP 5 system logs
whose are java.util.logging and they are printing on FOP Exceptions, but not
INFO logs. 
How can I configure them to succeed?
Java properties are setted and it doesn't work, I tryied to filter logs, but
there is no special handler...

Many thanks, and excuse me for the text!

Miguel.
-- 
View this message in context: http://www.nabble.com/Problems-with-Apache-FOP-and-Barcode4j-tp19069996p19069996.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: Problems with Apache FOP and Barcode4j

Posted by Miguel Tablado <mi...@gmail.com>.
Hi ToM, good news!


Tobias van Treeck wrote:
> 
> Hui Miquel,
> 
> i also had this problem but then i realized that i forgot the following
> jar:
> 
> barcode4j-fop-ext.jar
> 
> You also need those:
> barcode4j.jar
> batik-all-1.7.jar
> avalon-framework-4.2.0.jar
> commons-io-1.3.1.jar
> commons-logging-1.0.4.jar
> fop.jar
> serializer-2.7.0.jar
> xalan-2.7.0.jar
> xercesImpl-2.7.1.jar
> xml-apis-1.3.04.jar
> xml-apis-ext-1.3.04.jar
> xmlgraphics-commons-1.3.1.jar
> 
> Do you got all those?
> Regards,
> 
> ToM
> 
>>
>> Hi ToM
>>
>> Tobias van Treeck wrote:
>> >
>> > Hi Miguel,
>> >
>> > i had a similar problem recently. I also generated a PDF with a
>> > barcode
>> > and an image.
>> > I got the exact same error you got (root vs. page-sequence) and the
>> > reason was a wrong parameter in a table i used (for the column-with
>> > i
>> > used % instead of cm)
>> >
>> > Now i have serval suggestions for you:
>> >
>> > 1. Try to isolate your barcode 'code' - meaning create a document
>> > with
>> > just the barcode and run it. Does that work?
>> > 2. I used the same barcode 'code' like you but the following proved
>> > to
>> > be better for me:
>> >
>> > Namespace:
>> > xmlns:barcode="http://barcode4j.krysalis.org/ns"
>> >
>> > <block ...>
>> > <fo:instream-foreign-object>
>> >   <barcode:barcode>
>> >     <xsl:attribute name="message">
>> >       <xsl:text>1234567890</xsl:text>
>> >     </xsl:attribute>
>> >     <barcode:codabar>
>> >             <barcode:height>15mm</barcode:height>
>> >             <barcode:module-width>0.3mm</barcode:module-width>
>> >             <barcode:wide-factor>3.0</barcode:wide-factor>
>> >             <barcode:quiet-zone
>> > enabled="true">10mw</barcode:quiet-zone>
>> >     </barcode:codabar>
>> >   </barcode:barcode>
>> > </fo:instream-foreign-object>
>> >
>> > Try that barcodeversion in a separate stylsheet and run it.
>> >
>> > 3. Which version of xalan are you using? Put the newest one with the
>> > endorsed mechanism
>> > (http://java.sun.com/j2se/1.4.2/docs/guide/standards/
>> > ) into your jdk.
>> >
>> > Regards,
>> > ToM
>> >  
>> >> Hi folks,
>> >>
>> >> I'm upgrading my FOP version from 0.20 up to 0.95 and I'm getting
>> >> two
>> >> problems.
>> >>
>> >> The first one, and most important, is that I can't generate
>> >> barcodes
>> >> with
>> >> Apache FOP and Barcode4j projects. I don't know why but I'm getting
>> >> this
>> >> error:
>> >> javax.xml.transform.TransformerException: org.xml.sax.SAXException:
>> >> Mismatch: page-sequence (http://www.w3.org/1999/XSL/Format) vs.
>> >> root
>> >> (http://www.w3.org/1999/XSL/Format)
>> >>
>> >> I know that this error uses to be a follow-up error but I have no
>> >> more
>> >> detail and I'm lost since I have reached a strange situation.
>> >>
>> >> I have the following code on my xslt.
>> >> - Definition:
>> >> <xsl:stylesheet version="1.0"
>> >> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>> >> xmlns:fo="http://www.w3.org/1999/XSL/Format"
>> >> xmlns:barcode="org.krysalis.barcode4j.xalan.BarcodeExt"
>> >> xmlns:svg="http://www.w3.org/2000/svg"
>> >> extension-element-prefixes="barcode">
>> >> - Template:
>> >> <xsl:template match="texto[@class='CODIGO_BARRAS']">
>> >> <fo:block>
>> >> <fo:instream-foreign-object>
>> >> <xsl:variable name="barcode-cfg">
>> >> <barcode>
>> >> <code128>
>> >> <human-readable>none</human-readable>
>> >> <height>5mm</height>
>> >> <quiet-zone enabled="false"/>
>> >> </code128>
>> >> </barcode>
>> >> </xsl:variable>
>> >> <xsl:copy-of select="barcode:generate($barcode-cfg, .)"/>
>> >> </fo:instream-foreign-object>
>> >> </fo:block>
>> >> </xsl:template>
>> >>
>> >> - Call example:
>> >> <texto class="CODIGO_BARRAS" text-align="left" font-size="12pt"
>> >> module="0.45" height="10" >D106696</texto>
>> >>
>> >> - Java code:
>> >> The following code throws the exception.
>> >>
>> >> public void convertXmlToPdf(final StreamSource xmlSource, final
>> >> String
>> >> xsl, final OutputStream pdf) throws Exception {
>> >>
>> >> FOUserAgent foUserAgent = instance.fopFactory.newFOUserAgent();
>> >> // todo, configure urls.
>> >>
>> >>
>> >>
>> >>
>> foUserAgent.setBaseURL("file:///C:/TRIBUTOS/apps/gt_ear/build/gt_ear/gt_web/");
>> >>
>> >>
>> >>
>> >>
>> foUserAgent.setFontBaseURL("file:///C:/TRIBUTOS/apps/gt_ear/build/gt_ear/gt_web/");
>> >> foUserAgent.setAuthor("Miguel Tablado");
>> >>
>> >> //Setup XSLT
>> >> Fop fop = instancia.fopFactory.newFop(MimeConstants.MIME_PDF,
>> >> foUserAgent, pdf);
>> >>
>> >> TransformerFactory factory = TransformerFactory.newInstance();
>> >> Transformer transformer = factory.newTransformer(new
>> >> StreamSource(xsl));
>> >>
>> >> // Parámetro PATH de las imagenes
>> >> transformer.setParameter("AG_XSLFO_PATH_IMAGES",
>> >>
>> >> AGFunciones.agregarProtocoloFile(AGConfig.get("VirtualDirTemplates"))
>> >> +
>> >> "/images");
>> >>
>> >> //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(xmlSource, res);
>> >>
>> >> }
>> >>
>> >> The following one creates the .fo file with no problems.
>> >> private void convertXML2FO(final StreamSource src, final String
>> >> xslt)
>> >> throws IOException, TransformerException
>> >> , FOPException {
>> >> //Setup output
>> >> final File fo = new File(AGConfig.get("writeXmlFoPdfIntoFile"));
>> >> final OutputStream out = new FileOutputStream(fo);
>> >>
>> >> try {
>> >> //Setup XSLT
>> >> TransformerFactory factory = TransformerFactory.newInstance();
>> >> Transformer transformer = factory.newTransformer(new
>> >> StreamSource(xslt));
>> >>
>> >> // Parámetro PATH de las imagenes
>> >> transformer.setParameter("AG_XSLFO_PATH_IMAGES",
>> >>
>> >> AGFunciones.agregarProtocoloFile(AGConfig.get("VirtualDirTemplates"))
>> >> +
>> >> "/images");
>> >>
>> >> //Resulting SAX events (the generated FO) must be piped through
>> >> to FOP
>> >> Result res = new StreamResult(out);
>> >>
>> >> //Start XSLT transformation and FOP processing
>> >> transformer.transform(src, res);
>> >>
>> >> } finally {
>> >> out.close();
>> >> }
>> >> }
>> >>
>> >> The .fo generated snippet is something like this:
>> >> <fo:block>
>> >> <fo:instream-foreign-object>
>> >> <svg:svg height="1.3316mm" viewBox="0 0 120.54 1.3316"
>> >> width="120.54mm">
>> >> <svg:g style="fill:black; stroke:none">
>> >> <svg:rect height="1.3316" width="0.42" x="0" y="0"/>
>> >> <svg:rect height="1.3316" width="0.21" x="0.63" y="0"/>
>> >> ...
>> >> <svg:rect height="1.3316" width="0.42" x="120.12" y="0"/>
>> >> </svg:g>
>> >> </svg:svg>
>> >> </fo:instream-foreign-object>
>> >> </fo:block>
>> >>
>> >> Trying to find out the original problem I have tried two things,
>> >> the
>> >> first
>> >> one is to replace Barcode4j call to svg code.
>> >> Any problem, the resultant pdf has a pretty barcode.
>> >>
>> >> The second one, that follows me to the second problem mentioned at
>> >> introduction, has been configuring logs to get more information,
>> >> but I didn't get success. I'm logging with Bea Weblogic 8.1 SP 5
>> >> system logs
>> >> whose are java.util.logging and they are printing on FOP
>> >> Exceptions,
>> >> but not
>> >> INFO logs.
>> >> How can I configure them to succeed?
>> >> Java properties are setted and it doesn't work, I tryied to filter
>> >> logs, but
>> >> there is no special handler...
>> >>
>> >> Many thanks, and excuse me for the text!
>> >>
>> >> Miguel.
>> >
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
>> > For additional commands, e-mail:
>> > fop-users-help@xmlgraphics.apache.org
>> >
>> >
>> >
>>
>> I have modified my xslt in order to apply only the barcode template
>> and I
>> get the simplest fo file as you said, but unfortunately it doesn't
>> works, it
>> doesn't render the svg (the barcode nodeList, really) nor it prits out
>> any
>> exception.
>>
>> By the way if I launch the fo file from command line I get problems
>> finding
>> barcode classes. I don't know what I'm doing wrong because I have put
>> the
>> jar path on the classpath environment variable.
>>
>> About Xalan version, I'm using 2.7.1 and it is working from Weblogic
>> container, not jdk installation one.
>>
>> Any idea?
>>
>> Tx, Miguel.
>> --
>> View this message in context:
>> http://www.nabble.com/Problems-with-Apache-FOP-and-Barcode4j-tp19069996p19088718.html
>> Sent from the FOP - Users mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
>> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 

I got it, what I have done is to include a line on fop.bat including the jar
since the environment variable didn't work.

So I have include some libraries to my lib project directory and it has
worked. I pray for proper logging :)

Thanks.

-- 
View this message in context: http://www.nabble.com/Problems-with-Apache-FOP-and-Barcode4j-tp19069996p19091917.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: Problems with Apache FOP and Barcode4j

Posted by Tobias van Treeck <tv...@nepatec.de>.
Hui Miquel,

i also had this problem but then i realized that i forgot the following
jar:

barcode4j-fop-ext.jar

You also need those:
barcode4j.jar
batik-all-1.7.jar
avalon-framework-4.2.0.jar
commons-io-1.3.1.jar
commons-logging-1.0.4.jar
fop.jar
serializer-2.7.0.jar
xalan-2.7.0.jar
xercesImpl-2.7.1.jar
xml-apis-1.3.04.jar
xml-apis-ext-1.3.04.jar
xmlgraphics-commons-1.3.1.jar

Do you got all those?
Regards,

ToM

>
> Hi ToM
>
> Tobias van Treeck wrote:
> >
> > Hi Miguel,
> >
> > i had a similar problem recently. I also generated a PDF with a
> > barcode
> > and an image.
> > I got the exact same error you got (root vs. page-sequence) and the
> > reason was a wrong parameter in a table i used (for the column-with
> > i
> > used % instead of cm)
> >
> > Now i have serval suggestions for you:
> >
> > 1. Try to isolate your barcode 'code' - meaning create a document
> > with
> > just the barcode and run it. Does that work?
> > 2. I used the same barcode 'code' like you but the following proved
> > to
> > be better for me:
> >
> > Namespace:
> > xmlns:barcode="http://barcode4j.krysalis.org/ns"
> >
> > <block ...>
> > <fo:instream-foreign-object>
> >   <barcode:barcode>
> >     <xsl:attribute name="message">
> >       <xsl:text>1234567890</xsl:text>
> >     </xsl:attribute>
> >     <barcode:codabar>
> >             <barcode:height>15mm</barcode:height>
> >             <barcode:module-width>0.3mm</barcode:module-width>
> >             <barcode:wide-factor>3.0</barcode:wide-factor>
> >             <barcode:quiet-zone
> > enabled="true">10mw</barcode:quiet-zone>
> >     </barcode:codabar>
> >   </barcode:barcode>
> > </fo:instream-foreign-object>
> >
> > Try that barcodeversion in a separate stylsheet and run it.
> >
> > 3. Which version of xalan are you using? Put the newest one with the
> > endorsed mechanism
> > (http://java.sun.com/j2se/1.4.2/docs/guide/standards/
> > ) into your jdk.
> >
> > Regards,
> > ToM
> >  
> >> Hi folks,
> >>
> >> I'm upgrading my FOP version from 0.20 up to 0.95 and I'm getting
> >> two
> >> problems.
> >>
> >> The first one, and most important, is that I can't generate
> >> barcodes
> >> with
> >> Apache FOP and Barcode4j projects. I don't know why but I'm getting
> >> this
> >> error:
> >> javax.xml.transform.TransformerException: org.xml.sax.SAXException:
> >> Mismatch: page-sequence (http://www.w3.org/1999/XSL/Format) vs.
> >> root
> >> (http://www.w3.org/1999/XSL/Format)
> >>
> >> I know that this error uses to be a follow-up error but I have no
> >> more
> >> detail and I'm lost since I have reached a strange situation.
> >>
> >> I have the following code on my xslt.
> >> - Definition:
> >> <xsl:stylesheet version="1.0"
> >> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> >> xmlns:fo="http://www.w3.org/1999/XSL/Format"
> >> xmlns:barcode="org.krysalis.barcode4j.xalan.BarcodeExt"
> >> xmlns:svg="http://www.w3.org/2000/svg"
> >> extension-element-prefixes="barcode">
> >> - Template:
> >> <xsl:template match="texto[@class='CODIGO_BARRAS']">
> >> <fo:block>
> >> <fo:instream-foreign-object>
> >> <xsl:variable name="barcode-cfg">
> >> <barcode>
> >> <code128>
> >> <human-readable>none</human-readable>
> >> <height>5mm</height>
> >> <quiet-zone enabled="false"/>
> >> </code128>
> >> </barcode>
> >> </xsl:variable>
> >> <xsl:copy-of select="barcode:generate($barcode-cfg, .)"/>
> >> </fo:instream-foreign-object>
> >> </fo:block>
> >> </xsl:template>
> >>
> >> - Call example:
> >> <texto class="CODIGO_BARRAS" text-align="left" font-size="12pt"
> >> module="0.45" height="10" >D106696</texto>
> >>
> >> - Java code:
> >> The following code throws the exception.
> >>
> >> public void convertXmlToPdf(final StreamSource xmlSource, final
> >> String
> >> xsl, final OutputStream pdf) throws Exception {
> >>
> >> FOUserAgent foUserAgent = instance.fopFactory.newFOUserAgent();
> >> // todo, configure urls.
> >>
> >>
> >>
> >> foUserAgent.setBaseURL("file:///C:/TRIBUTOS/apps/gt_ear/build/gt_ear/gt_web/");
> >>
> >>
> >>
> >> foUserAgent.setFontBaseURL("file:///C:/TRIBUTOS/apps/gt_ear/build/gt_ear/gt_web/");
> >> foUserAgent.setAuthor("Miguel Tablado");
> >>
> >> //Setup XSLT
> >> Fop fop = instancia.fopFactory.newFop(MimeConstants.MIME_PDF,
> >> foUserAgent, pdf);
> >>
> >> TransformerFactory factory = TransformerFactory.newInstance();
> >> Transformer transformer = factory.newTransformer(new
> >> StreamSource(xsl));
> >>
> >> // Parámetro PATH de las imagenes
> >> transformer.setParameter("AG_XSLFO_PATH_IMAGES",
> >>
> >> AGFunciones.agregarProtocoloFile(AGConfig.get("VirtualDirTemplates"))
> >> +
> >> "/images");
> >>
> >> //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(xmlSource, res);
> >>
> >> }
> >>
> >> The following one creates the .fo file with no problems.
> >> private void convertXML2FO(final StreamSource src, final String
> >> xslt)
> >> throws IOException, TransformerException
> >> , FOPException {
> >> //Setup output
> >> final File fo = new File(AGConfig.get("writeXmlFoPdfIntoFile"));
> >> final OutputStream out = new FileOutputStream(fo);
> >>
> >> try {
> >> //Setup XSLT
> >> TransformerFactory factory = TransformerFactory.newInstance();
> >> Transformer transformer = factory.newTransformer(new
> >> StreamSource(xslt));
> >>
> >> // Parámetro PATH de las imagenes
> >> transformer.setParameter("AG_XSLFO_PATH_IMAGES",
> >>
> >> AGFunciones.agregarProtocoloFile(AGConfig.get("VirtualDirTemplates"))
> >> +
> >> "/images");
> >>
> >> //Resulting SAX events (the generated FO) must be piped through
> >> to FOP
> >> Result res = new StreamResult(out);
> >>
> >> //Start XSLT transformation and FOP processing
> >> transformer.transform(src, res);
> >>
> >> } finally {
> >> out.close();
> >> }
> >> }
> >>
> >> The .fo generated snippet is something like this:
> >> <fo:block>
> >> <fo:instream-foreign-object>
> >> <svg:svg height="1.3316mm" viewBox="0 0 120.54 1.3316"
> >> width="120.54mm">
> >> <svg:g style="fill:black; stroke:none">
> >> <svg:rect height="1.3316" width="0.42" x="0" y="0"/>
> >> <svg:rect height="1.3316" width="0.21" x="0.63" y="0"/>
> >> ...
> >> <svg:rect height="1.3316" width="0.42" x="120.12" y="0"/>
> >> </svg:g>
> >> </svg:svg>
> >> </fo:instream-foreign-object>
> >> </fo:block>
> >>
> >> Trying to find out the original problem I have tried two things,
> >> the
> >> first
> >> one is to replace Barcode4j call to svg code.
> >> Any problem, the resultant pdf has a pretty barcode.
> >>
> >> The second one, that follows me to the second problem mentioned at
> >> introduction, has been configuring logs to get more information,
> >> but I didn't get success. I'm logging with Bea Weblogic 8.1 SP 5
> >> system logs
> >> whose are java.util.logging and they are printing on FOP
> >> Exceptions,
> >> but not
> >> INFO logs.
> >> How can I configure them to succeed?
> >> Java properties are setted and it doesn't work, I tryied to filter
> >> logs, but
> >> there is no special handler...
> >>
> >> Many thanks, and excuse me for the text!
> >>
> >> Miguel.
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail:
> > fop-users-help@xmlgraphics.apache.org
> >
> >
> >
>
> I have modified my xslt in order to apply only the barcode template
> and I
> get the simplest fo file as you said, but unfortunately it doesn't
> works, it
> doesn't render the svg (the barcode nodeList, really) nor it prits out
> any
> exception.
>
> By the way if I launch the fo file from command line I get problems
> finding
> barcode classes. I don't know what I'm doing wrong because I have put
> the
> jar path on the classpath environment variable.
>
> About Xalan version, I'm using 2.7.1 and it is working from Weblogic
> container, not jdk installation one.
>
> Any idea?
>
> Tx, Miguel.
> --
> View this message in context:
> http://www.nabble.com/Problems-with-Apache-FOP-and-Barcode4j-tp19069996p19088718.html
> Sent from the FOP - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>


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


Re: Problems with Apache FOP and Barcode4j

Posted by Miguel Tablado <mi...@gmail.com>.
Hi ToM

Tobias van Treeck wrote:
> 
> Hi Miguel,
> 
> i had a similar problem recently. I also generated a PDF with a barcode
> and an image.
> I got the exact same error you got (root vs. page-sequence) and the
> reason was a wrong parameter in a table i used (for the column-with i
> used % instead of cm)
> 
> Now i have serval suggestions for you:
> 
> 1. Try to isolate your barcode 'code' - meaning create a document with
> just the barcode and run it. Does that work?
> 2. I used the same barcode 'code' like you but the following proved to
> be better for me:
> 
> Namespace:
> xmlns:barcode="http://barcode4j.krysalis.org/ns"
> 
> <block ...>
> <fo:instream-foreign-object>
>   <barcode:barcode>
>     <xsl:attribute name="message">
>       <xsl:text>1234567890</xsl:text>
>     </xsl:attribute>
>     <barcode:codabar>
>             <barcode:height>15mm</barcode:height>
>             <barcode:module-width>0.3mm</barcode:module-width>
>             <barcode:wide-factor>3.0</barcode:wide-factor>
>             <barcode:quiet-zone enabled="true">10mw</barcode:quiet-zone>
>     </barcode:codabar>
>   </barcode:barcode>
> </fo:instream-foreign-object>
> 
> Try that barcodeversion in a separate stylsheet and run it.
> 
> 3. Which version of xalan are you using? Put the newest one with the
> endorsed mechanism (http://java.sun.com/j2se/1.4.2/docs/guide/standards/
> ) into your jdk.
> 
> Regards,
> ToM
>  
>> Hi folks,
>>
>> I'm upgrading my FOP version from 0.20 up to 0.95 and I'm getting two
>> problems.
>>
>> The first one, and most important, is that I can't generate barcodes
>> with
>> Apache FOP and Barcode4j projects. I don't know why but I'm getting
>> this
>> error:
>> javax.xml.transform.TransformerException: org.xml.sax.SAXException:
>> Mismatch: page-sequence (http://www.w3.org/1999/XSL/Format) vs. root
>> (http://www.w3.org/1999/XSL/Format)
>>
>> I know that this error uses to be a follow-up error but I have no more
>> detail and I'm lost since I have reached a strange situation.
>>
>> I have the following code on my xslt.
>> - Definition:
>> <xsl:stylesheet version="1.0"
>> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>> xmlns:fo="http://www.w3.org/1999/XSL/Format"
>> xmlns:barcode="org.krysalis.barcode4j.xalan.BarcodeExt"
>> xmlns:svg="http://www.w3.org/2000/svg"
>> extension-element-prefixes="barcode">
>> - Template:
>> <xsl:template match="texto[@class='CODIGO_BARRAS']">
>> <fo:block>
>> <fo:instream-foreign-object>
>> <xsl:variable name="barcode-cfg">
>> <barcode>
>> <code128>
>> <human-readable>none</human-readable>
>> <height>5mm</height>
>> <quiet-zone enabled="false"/>
>> </code128>
>> </barcode>
>> </xsl:variable>
>> <xsl:copy-of select="barcode:generate($barcode-cfg, .)"/>
>> </fo:instream-foreign-object>
>> </fo:block>
>> </xsl:template>
>>
>> - Call example:
>> <texto class="CODIGO_BARRAS" text-align="left" font-size="12pt"
>> module="0.45" height="10" >D106696</texto>
>>
>> - Java code:
>> The following code throws the exception.
>>
>> public void convertXmlToPdf(final StreamSource xmlSource, final String
>> xsl, final OutputStream pdf) throws Exception {
>>
>> FOUserAgent foUserAgent = instance.fopFactory.newFOUserAgent();
>> // todo, configure urls.
>>
>>
>> foUserAgent.setBaseURL("file:///C:/TRIBUTOS/apps/gt_ear/build/gt_ear/gt_web/");
>>
>>
>> foUserAgent.setFontBaseURL("file:///C:/TRIBUTOS/apps/gt_ear/build/gt_ear/gt_web/");
>> foUserAgent.setAuthor("Miguel Tablado");
>>
>> //Setup XSLT
>> Fop fop = instancia.fopFactory.newFop(MimeConstants.MIME_PDF,
>> foUserAgent, pdf);
>>
>> TransformerFactory factory = TransformerFactory.newInstance();
>> Transformer transformer = factory.newTransformer(new
>> StreamSource(xsl));
>>
>> // Parámetro PATH de las imagenes
>> transformer.setParameter("AG_XSLFO_PATH_IMAGES",
>> AGFunciones.agregarProtocoloFile(AGConfig.get("VirtualDirTemplates"))
>> +
>> "/images");
>>
>> //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(xmlSource, res);
>>
>> }
>>
>> The following one creates the .fo file with no problems.
>> private void convertXML2FO(final StreamSource src, final String xslt)
>> throws IOException, TransformerException
>> , FOPException {
>> //Setup output
>> final File fo = new File(AGConfig.get("writeXmlFoPdfIntoFile"));
>> final OutputStream out = new FileOutputStream(fo);
>>
>> try {
>> //Setup XSLT
>> TransformerFactory factory = TransformerFactory.newInstance();
>> Transformer transformer = factory.newTransformer(new
>> StreamSource(xslt));
>>
>> // Parámetro PATH de las imagenes
>> transformer.setParameter("AG_XSLFO_PATH_IMAGES",
>> AGFunciones.agregarProtocoloFile(AGConfig.get("VirtualDirTemplates"))
>> +
>> "/images");
>>
>> //Resulting SAX events (the generated FO) must be piped through
>> to FOP
>> Result res = new StreamResult(out);
>>
>> //Start XSLT transformation and FOP processing
>> transformer.transform(src, res);
>>
>> } finally {
>> out.close();
>> }
>> }
>>
>> The .fo generated snippet is something like this:
>> <fo:block>
>> <fo:instream-foreign-object>
>> <svg:svg height="1.3316mm" viewBox="0 0 120.54 1.3316"
>> width="120.54mm">
>> <svg:g style="fill:black; stroke:none">
>> <svg:rect height="1.3316" width="0.42" x="0" y="0"/>
>> <svg:rect height="1.3316" width="0.21" x="0.63" y="0"/>
>> ...
>> <svg:rect height="1.3316" width="0.42" x="120.12" y="0"/>
>> </svg:g>
>> </svg:svg>
>> </fo:instream-foreign-object>
>> </fo:block>
>>
>> Trying to find out the original problem I have tried two things, the
>> first
>> one is to replace Barcode4j call to svg code.
>> Any problem, the resultant pdf has a pretty barcode.
>>
>> The second one, that follows me to the second problem mentioned at
>> introduction, has been configuring logs to get more information,
>> but I didn't get success. I'm logging with Bea Weblogic 8.1 SP 5
>> system logs
>> whose are java.util.logging and they are printing on FOP Exceptions,
>> but not
>> INFO logs.
>> How can I configure them to succeed?
>> Java properties are setted and it doesn't work, I tryied to filter
>> logs, but
>> there is no special handler...
>>
>> Many thanks, and excuse me for the text!
>>
>> Miguel.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 

I have modified my xslt in order to apply only the barcode template and I
get the simplest fo file as you said, but unfortunately it doesn't works, it
doesn't render the svg (the barcode nodeList, really) nor it prits out any
exception.

By the way if I launch the fo file from command line I get problems finding
barcode classes. I don't know what I'm doing wrong because I have put the
jar path on the classpath environment variable.

About Xalan version, I'm using 2.7.1 and it is working from Weblogic
container, not jdk installation one.

Any idea?

Tx, Miguel.
-- 
View this message in context: http://www.nabble.com/Problems-with-Apache-FOP-and-Barcode4j-tp19069996p19088718.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: Problems with Apache FOP and Barcode4j

Posted by Tobias van Treeck <tv...@nepatec.de>.
Hi Miguel,

i had a similar problem recently. I also generated a PDF with a barcode
and an image.
I got the exact same error you got (root vs. page-sequence) and the
reason was a wrong parameter in a table i used (for the column-with i
used % instead of cm)

Now i have serval suggestions for you:

1. Try to isolate your barcode 'code' - meaning create a document with
just the barcode and run it. Does that work?
2. I used the same barcode 'code' like you but the following proved to
be better for me:

Namespace:
xmlns:barcode="http://barcode4j.krysalis.org/ns"

<block ...>
<fo:instream-foreign-object>
  <barcode:barcode>
    <xsl:attribute name="message">
      <xsl:text>1234567890</xsl:text>
    </xsl:attribute>
    <barcode:codabar>
            <barcode:height>15mm</barcode:height>
            <barcode:module-width>0.3mm</barcode:module-width>
            <barcode:wide-factor>3.0</barcode:wide-factor>
            <barcode:quiet-zone enabled="true">10mw</barcode:quiet-zone>
    </barcode:codabar>
  </barcode:barcode>
</fo:instream-foreign-object>

Try that barcodeversion in a separate stylsheet and run it.

3. Which version of xalan are you using? Put the newest one with the
endorsed mechanism (http://java.sun.com/j2se/1.4.2/docs/guide/standards/
) into your jdk.

Regards,
ToM
 
> Hi folks,
>
> I'm upgrading my FOP version from 0.20 up to 0.95 and I'm getting two
> problems.
>
> The first one, and most important, is that I can't generate barcodes
> with
> Apache FOP and Barcode4j projects. I don't know why but I'm getting
> this
> error:
> javax.xml.transform.TransformerException: org.xml.sax.SAXException:
> Mismatch: page-sequence (http://www.w3.org/1999/XSL/Format) vs. root
> (http://www.w3.org/1999/XSL/Format)
>
> I know that this error uses to be a follow-up error but I have no more
> detail and I'm lost since I have reached a strange situation.
>
> I have the following code on my xslt.
> - Definition:
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:fo="http://www.w3.org/1999/XSL/Format"
> xmlns:barcode="org.krysalis.barcode4j.xalan.BarcodeExt"
> xmlns:svg="http://www.w3.org/2000/svg"
> extension-element-prefixes="barcode">
> - Template:
> <xsl:template match="texto[@class='CODIGO_BARRAS']">
> <fo:block>
> <fo:instream-foreign-object>
> <xsl:variable name="barcode-cfg">
> <barcode>
> <code128>
> <human-readable>none</human-readable>
> <height>5mm</height>
> <quiet-zone enabled="false"/>
> </code128>
> </barcode>
> </xsl:variable>
> <xsl:copy-of select="barcode:generate($barcode-cfg, .)"/>
> </fo:instream-foreign-object>
> </fo:block>
> </xsl:template>
>
> - Call example:
> <texto class="CODIGO_BARRAS" text-align="left" font-size="12pt"
> module="0.45" height="10" >D106696</texto>
>
> - Java code:
> The following code throws the exception.
>
> public void convertXmlToPdf(final StreamSource xmlSource, final String
> xsl, final OutputStream pdf) throws Exception {
>
> FOUserAgent foUserAgent = instance.fopFactory.newFOUserAgent();
> // todo, configure urls.
>
>
> foUserAgent.setBaseURL("file:///C:/TRIBUTOS/apps/gt_ear/build/gt_ear/gt_web/");
>
>
> foUserAgent.setFontBaseURL("file:///C:/TRIBUTOS/apps/gt_ear/build/gt_ear/gt_web/");
> foUserAgent.setAuthor("Miguel Tablado");
>
> //Setup XSLT
> Fop fop = instancia.fopFactory.newFop(MimeConstants.MIME_PDF,
> foUserAgent, pdf);
>
> TransformerFactory factory = TransformerFactory.newInstance();
> Transformer transformer = factory.newTransformer(new
> StreamSource(xsl));
>
> // Parámetro PATH de las imagenes
> transformer.setParameter("AG_XSLFO_PATH_IMAGES",
> AGFunciones.agregarProtocoloFile(AGConfig.get("VirtualDirTemplates"))
> +
> "/images");
>
> //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(xmlSource, res);
>
> }
>
> The following one creates the .fo file with no problems.
> private void convertXML2FO(final StreamSource src, final String xslt)
> throws IOException, TransformerException
> , FOPException {
> //Setup output
> final File fo = new File(AGConfig.get("writeXmlFoPdfIntoFile"));
> final OutputStream out = new FileOutputStream(fo);
>
> try {
> //Setup XSLT
> TransformerFactory factory = TransformerFactory.newInstance();
> Transformer transformer = factory.newTransformer(new
> StreamSource(xslt));
>
> // Parámetro PATH de las imagenes
> transformer.setParameter("AG_XSLFO_PATH_IMAGES",
> AGFunciones.agregarProtocoloFile(AGConfig.get("VirtualDirTemplates"))
> +
> "/images");
>
> //Resulting SAX events (the generated FO) must be piped through
> to FOP
> Result res = new StreamResult(out);
>
> //Start XSLT transformation and FOP processing
> transformer.transform(src, res);
>
> } finally {
> out.close();
> }
> }
>
> The .fo generated snippet is something like this:
> <fo:block>
> <fo:instream-foreign-object>
> <svg:svg height="1.3316mm" viewBox="0 0 120.54 1.3316"
> width="120.54mm">
> <svg:g style="fill:black; stroke:none">
> <svg:rect height="1.3316" width="0.42" x="0" y="0"/>
> <svg:rect height="1.3316" width="0.21" x="0.63" y="0"/>
> ...
> <svg:rect height="1.3316" width="0.42" x="120.12" y="0"/>
> </svg:g>
> </svg:svg>
> </fo:instream-foreign-object>
> </fo:block>
>
> Trying to find out the original problem I have tried two things, the
> first
> one is to replace Barcode4j call to svg code.
> Any problem, the resultant pdf has a pretty barcode.
>
> The second one, that follows me to the second problem mentioned at
> introduction, has been configuring logs to get more information,
> but I didn't get success. I'm logging with Bea Weblogic 8.1 SP 5
> system logs
> whose are java.util.logging and they are printing on FOP Exceptions,
> but not
> INFO logs.
> How can I configure them to succeed?
> Java properties are setted and it doesn't work, I tryied to filter
> logs, but
> there is no special handler...
>
> Many thanks, and excuse me for the text!
>
> Miguel.


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


Re: Problems with Apache FOP and Barcode4j

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Thanks for the extensive additional data. I might have the problem now.

> 21-ago-2008 11:16:05 org.apache.fop.fo.ElementMappingRegistry findFOMaker
> ADVERTENCIA: Unknown formatting object
> http://barcode4j.krysalis.org/ns^barcode

This indicates that the Barcode4J FOP extension is not correctly set up
with FOP. Please note that FOP 0.95 needs a different extension than FOP
0.20.5 because the extension APIs have changed. Please put
"barcode4j-fop-ext-complete.jar" (from Barcode4J 2.0) into your
classpath (and remove the old JAR). The above error message should then
go away and the barcodes should appear.

But that doesn't really explain why you got the "mismatch" error. Maybe
we need to take this one step at a time.

HTH

On 21.08.2008 11:29:57 Miguel Tablado wrote:
> 
> Hello Andreas and others,
> 
> I'm using xalan 2.7.1. And this is the xslt processor guessed from the
> StackTrace (I doubted if Weblogic was discarding it).
> org.xml.sax.SAXException: Mismatch: page-sequence
> (http://www.w3.org/1999/XSL/Format) vs. root
> (http://www.w3.org/1999/XSL/Format)
> StackTrace:
> org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:725))
> org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2339))
> 
> I have generated the fo file and it is correct, furthermore if I launch the
> command line with -d -fo options i get the pdf file and some messages that
> I'd discard as font errors. Wouldn't I?
> - The call:
> 	fop -d -fo
> c:\bea8\user_projects\domains\tributos\logs\tempPdfGaudi\gaudiXMLFOPDF.fo
> out.pdf
> - Messages:
> 21-ago-2008 10:06:43
> org.apache.fop.layoutmgr.inline.LineLayoutManager$LineBreak
> ingAlgorithm updateData2
> ADVERTENCIA: Line 1 of a paragraph overflows the available area by more than
> 50
> points. (fo:block, location: 22/38)
> 
> By the way, looking at BarcodeExt source I have notice that you can work
> using name-spaces or not, and as I wasn't using them I have tryed the
> opposite as follows:
> 		<fo:block>
> 			<fo:instream-foreign-object>
> 				<bc:barcode message="Hello World!"
> xmlns:bc="org.krysalis.barcode4j.xalan.BarcodeExt">
> 					<bc:code128>
> 						<bc:height>8mm</bc:height>
> 						<bc:human-readable>none</bc:human-readable>
> 						<bc:length>25mm</bc:length>
> 					</bc:code128>
> 				</bc:barcode>
> 			</fo:instream-foreign-object>
> 		</fo:block>
> 
> It throws another exception which is (as you mentioned):
> Message:
> org.xml.sax.SAXException: endElement() called for fo:root where there is no
> current element.
> 
> The resultant .fo file is trunked/uncomplete and the last rendered object is
> the generated svg barcode. I know the namespace I'm using is for processing
> the barcode at xslt process and that I could do it at fop process using
> "http://barcode4j.krysalis.org/ns" namespace, let's go!
> FOP is not generating the svg object. Surely the reason is this that I get
> from command line:
> 
> 21-ago-2008 11:16:05 org.apache.fop.fo.ElementMappingRegistry findFOMaker
> ADVERTENCIA: Unknown formatting object
> http://barcode4j.krysalis.org/ns^barcode
> 21-ago-2008 11:16:05 org.apache.fop.fo.ElementMappingRegistry findFOMaker
> ADVERTENCIA: Unknown formatting object
> http://barcode4j.krysalis.org/ns^code128
> 21-ago-2008 11:16:05 org.apache.fop.fo.ElementMappingRegistry findFOMaker
> ADVERTENCIA: Unknown formatting object
> http://barcode4j.krysalis.org/ns^height
> 21-ago-2008 11:16:05 org.apache.fop.fo.ElementMappingRegistry findFOMaker
> ADVERTENCIA: Unknown formatting object
> http://barcode4j.krysalis.org/ns^human-re
> adable
> 21-ago-2008 11:16:05 org.apache.fop.fo.ElementMappingRegistry findFOMaker
> ADVERTENCIA: Unknown formatting object
> http://barcode4j.krysalis.org/ns^length
> 21-ago-2008 11:16:05 org.apache.fop.fo.flow.InstreamForeignObject
> prepareIntrins
> icSize
> GRAVE: Intrinsic dimensions of  instream-foreign-object could not be
> determined
> 21-ago-2008 11:16:05 org.apache.fop.fo.flow.InstreamForeignObject
> prepareIntrins
> icSize
> GRAVE: Intrinsic dimensions of  instream-foreign-object could not be
> determined
> 21-ago-2008 11:16:05 org.apache.fop.fo.flow.InstreamForeignObject
> prepareIntrins
> icSize
> GRAVE: Intrinsic dimensions of  instream-foreign-object could not be
> determined
> 
> But I don't understand why the FOP ElementMapping class doesn't found them
> if I have setted the CLASSPATH to go for barcode-ext-complete jar, any idea?
> 
> Miguel
> -- 
> View this message in context: http://www.nabble.com/Problems-with-Apache-FOP-and-Barcode4j-tp19069996p19085348.html
> Sent from the FOP - Users mailing list archive at Nabble.com.
> 
> 




Jeremias Maerki


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


Re: Problems with Apache FOP and Barcode4j

Posted by Miguel Tablado <mi...@gmail.com>.


Jeremias Maerki-2 wrote:
> 
> An alternative is to just set a simple ErrorListener implementation on
> the Transformer to override Xalan's default ErrorListener. I've attached
> one I've written once I've stumbled over this Xalan bug.
> 
> Jeremias Maerki
> 
> 

I have done it but I got the same report.

Code...
public class AGEstandarXSLTErrorListener implements ErrorListener {

    private final AGMap report;

    public AGEstandarXSLTErrorListener(final AGMap _report) {
        super();
        this.report = _report;
    }

    public void error(final TransformerException exception) throws
TransformerException {
        this.report.put(AGFrontServlet.ERRORES,
this.report.get(AGFrontServlet.ERRORES) + "{ ERROR XSLT =" +
exception.getMessage() + " LOCATION: " + exception.getMessageAndLocation() +
" TRACE: " + AGSystemException.getStackTrace(exception) + "}\n");
    }

    public void fatalError(final TransformerException exception) throws
TransformerException {
        /*More of the same*/
    }

    public void warning(final TransformerException exception) throws
TransformerException {
        /*More of the same*/
    }

}

Where AGMap is a Hashmap wrapper.
-- 
View this message in context: http://www.nabble.com/Problems-with-Apache-FOP-and-Barcode4j-tp19069996p19085814.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: Problems with Apache FOP and Barcode4j

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
On 20.08.2008 18:26:17 Andreas Delmelle wrote:
> On Aug 20, 2008, at 16:56, Miguel Tablado wrote:
> 
> Hi
> 
> > I'm upgrading my FOP version from 0.20 up to 0.95 and I'm getting two
> > problems.
> >
> > The first one, and most important, is that I can't generate  
> > barcodes with
> > Apache FOP and Barcode4j projects. I don't know why but I'm getting  
> > this
> > error:
> > javax.xml.transform.TransformerException: org.xml.sax.SAXException:
> > Mismatch: page-sequence (http://www.w3.org/1999/XSL/Format) vs. root
> > (http://www.w3.org/1999/XSL/Format)
> >
> > I know that this error uses to be a follow-up error but I have no more
> > detail and I'm lost since I have reached a strange situation.
> 
> Just to be sure: Can you try using a different XSLT processor (or  
> simply a more recent version of Xalan)? Reason I'm asking is that I  
> seem to remember that some Xalan versions swallow exceptions. It  
> recovers, hands control back over to FOP, but the node in question  
> (where the error originates; if I judge correctly, the page-sequence  
> in question) will still not have been processed completely, so FOP  
> will have received a startElement(), but no endElement().

An alternative is to just set a simple ErrorListener implementation on
the Transformer to override Xalan's default ErrorListener. I've attached
one I've written once I've stumbled over this Xalan bug.

> Not that this will immediately solve your issue, but if the XSLT  
> processor would terminate, then you should at least get a more  
> appropriate error-message.
> 
> Another thing to try to receive a more meaningful error message:
> - first generate the FO from the XML+XSLT (by means of the '-foout'  
> command-line option), and check if the FO is valid XML
> - if the first step succeeds, then render the resulting FO to the  
> desired output format, preferably in debug-mode ('-d') to receive as  
> much relevant info as possible.
> 
> If this doesn't help, don't hesitate to post back here!
> 
> 
> HTH!
> 
> Andreas


Jeremias Maerki

Re: Problems with Apache FOP and Barcode4j

Posted by Miguel Tablado <mi...@gmail.com>.
Hello Andreas and others,

I'm using xalan 2.7.1. And this is the xslt processor guessed from the
StackTrace (I doubted if Weblogic was discarding it).
org.xml.sax.SAXException: Mismatch: page-sequence
(http://www.w3.org/1999/XSL/Format) vs. root
(http://www.w3.org/1999/XSL/Format)
StackTrace:
org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:725))
org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2339))

I have generated the fo file and it is correct, furthermore if I launch the
command line with -d -fo options i get the pdf file and some messages that
I'd discard as font errors. Wouldn't I?
- The call:
	fop -d -fo
c:\bea8\user_projects\domains\tributos\logs\tempPdfGaudi\gaudiXMLFOPDF.fo
out.pdf
- Messages:
21-ago-2008 10:06:43
org.apache.fop.layoutmgr.inline.LineLayoutManager$LineBreak
ingAlgorithm updateData2
ADVERTENCIA: Line 1 of a paragraph overflows the available area by more than
50
points. (fo:block, location: 22/38)

By the way, looking at BarcodeExt source I have notice that you can work
using name-spaces or not, and as I wasn't using them I have tryed the
opposite as follows:
		<fo:block>
			<fo:instream-foreign-object>
				<bc:barcode message="Hello World!"
xmlns:bc="org.krysalis.barcode4j.xalan.BarcodeExt">
					<bc:code128>
						<bc:height>8mm</bc:height>
						<bc:human-readable>none</bc:human-readable>
						<bc:length>25mm</bc:length>
					</bc:code128>
				</bc:barcode>
			</fo:instream-foreign-object>
		</fo:block>

It throws another exception which is (as you mentioned):
Message:
org.xml.sax.SAXException: endElement() called for fo:root where there is no
current element.

The resultant .fo file is trunked/uncomplete and the last rendered object is
the generated svg barcode. I know the namespace I'm using is for processing
the barcode at xslt process and that I could do it at fop process using
"http://barcode4j.krysalis.org/ns" namespace, let's go!
FOP is not generating the svg object. Surely the reason is this that I get
from command line:

21-ago-2008 11:16:05 org.apache.fop.fo.ElementMappingRegistry findFOMaker
ADVERTENCIA: Unknown formatting object
http://barcode4j.krysalis.org/ns^barcode
21-ago-2008 11:16:05 org.apache.fop.fo.ElementMappingRegistry findFOMaker
ADVERTENCIA: Unknown formatting object
http://barcode4j.krysalis.org/ns^code128
21-ago-2008 11:16:05 org.apache.fop.fo.ElementMappingRegistry findFOMaker
ADVERTENCIA: Unknown formatting object
http://barcode4j.krysalis.org/ns^height
21-ago-2008 11:16:05 org.apache.fop.fo.ElementMappingRegistry findFOMaker
ADVERTENCIA: Unknown formatting object
http://barcode4j.krysalis.org/ns^human-re
adable
21-ago-2008 11:16:05 org.apache.fop.fo.ElementMappingRegistry findFOMaker
ADVERTENCIA: Unknown formatting object
http://barcode4j.krysalis.org/ns^length
21-ago-2008 11:16:05 org.apache.fop.fo.flow.InstreamForeignObject
prepareIntrins
icSize
GRAVE: Intrinsic dimensions of  instream-foreign-object could not be
determined
21-ago-2008 11:16:05 org.apache.fop.fo.flow.InstreamForeignObject
prepareIntrins
icSize
GRAVE: Intrinsic dimensions of  instream-foreign-object could not be
determined
21-ago-2008 11:16:05 org.apache.fop.fo.flow.InstreamForeignObject
prepareIntrins
icSize
GRAVE: Intrinsic dimensions of  instream-foreign-object could not be
determined

But I don't understand why the FOP ElementMapping class doesn't found them
if I have setted the CLASSPATH to go for barcode-ext-complete jar, any idea?

Miguel
-- 
View this message in context: http://www.nabble.com/Problems-with-Apache-FOP-and-Barcode4j-tp19069996p19085348.html
Sent from the FOP - Users mailing list archive at Nabble.com.


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


Re: Problems with Apache FOP and Barcode4j

Posted by Andreas Delmelle <an...@telenet.be>.
On Aug 20, 2008, at 16:56, Miguel Tablado wrote:

Hi

> I'm upgrading my FOP version from 0.20 up to 0.95 and I'm getting two
> problems.
>
> The first one, and most important, is that I can't generate  
> barcodes with
> Apache FOP and Barcode4j projects. I don't know why but I'm getting  
> this
> error:
> javax.xml.transform.TransformerException: org.xml.sax.SAXException:
> Mismatch: page-sequence (http://www.w3.org/1999/XSL/Format) vs. root
> (http://www.w3.org/1999/XSL/Format)
>
> I know that this error uses to be a follow-up error but I have no more
> detail and I'm lost since I have reached a strange situation.

Just to be sure: Can you try using a different XSLT processor (or  
simply a more recent version of Xalan)? Reason I'm asking is that I  
seem to remember that some Xalan versions swallow exceptions. It  
recovers, hands control back over to FOP, but the node in question  
(where the error originates; if I judge correctly, the page-sequence  
in question) will still not have been processed completely, so FOP  
will have received a startElement(), but no endElement().

Not that this will immediately solve your issue, but if the XSLT  
processor would terminate, then you should at least get a more  
appropriate error-message.

Another thing to try to receive a more meaningful error message:
- first generate the FO from the XML+XSLT (by means of the '-foout'  
command-line option), and check if the FO is valid XML
- if the first step succeeds, then render the resulting FO to the  
desired output format, preferably in debug-mode ('-d') to receive as  
much relevant info as possible.

If this doesn't help, don't hesitate to post back here!


HTH!

Andreas

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