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 Esteban Gonzalez <eg...@outside.com.ar> on 2002/05/30 01:04:25 UTC

Embedding.... newbie problem....

Hi!
I´ve been trying to do some xml --> pdf transformation using FOP.
When I run FOP manually everything is wonderful,  but i don´t seem to really
understand how to embeed it in a running app.
The problem is with the input Source ..
I have both the xml file and the xsl file as org.w3c.dom.Document and I
don´t seem to be able to use them as input for the transformation.
I´ll post a code snippet to make myself clear
<code>
                Document voucher = ...
                Document xsl = ....

                //XSL Formatting.
                Driver driver = new Driver();
                driver.setRenderer( Driver.RENDER_PDF );
                driver.setInputSource( new DocumentInputSource( xsl ) );
                driver.setOutputStream( outStream );
                driver.render( voucher );
</code>

that is almost a copy from the fop documentation
(http://xml.apache.org/fop/embedding.html), the problem is.. I seem to be
setting an XSL file as an input... so where do I set the XML Document as an
input?

I´ve been digging thru the fop api and found out this class XSLTransform
wich seems to take an XLM doc, and a XSL file as inputs and outputs a
org.w3c.dom.Document, but again.. I can´t input the XSL as a document...

there are any workarounds to this problems?...
or maybe some ideas?

Thanks for all your help!

Best Regards,
Esteban González

----------------------------------
Esteban González

Departamento de Sistemas
ASSIST-CARD International



Re: wrong namespace??

Posted by Esteban Gonzalez <eg...@outside.com.ar>.
Yes.. the xsl is outputed exactly as the xsl template...
with small changes in margins but that should not throw the error..

I´ll try moving to sax as soon as i finish some other code....

i´ll keep you updated with any news about this..

thanks for all your help!!

Best Regards,
Esteban

----- Original Message -----
From: "J.Pietschmann" <j3...@yahoo.de>
To: <fo...@xml.apache.org>
Sent: Friday, May 31, 2002 5:48 PM
Subject: Re: wrong namespace??


> Esteban Gonzalez wrote:
> > seems like an error in the code?
> >
> >                // ADDED XML VOUCHER GENERATION
> >                 XMLGenerator xml = new XMLGenerator();
> >                 Document voucher = xml.generateVoucher( voucherGener );
> >                 Document xsl = xml.getXSL();
> >
> >                 // XSL Formatting.
> >                 Driver driver = new Driver();
> >                 driver.setRenderer( Driver.RENDER_PDF );
> >                 file://driver.setInputSource( new
DocumentInputSource() );
> >                 driver.setOutputStream( outStream );
> >
> >                 file://Let's set the input
> >                 Transformer trans =
> > TransformerFactory.newInstance().newTransformer( new DOMSource( xsl ) );
> >                 trans.transform( new DOMSource( voucher ), new
> > AXResult( driver.getContentHandler() ));
>
> This is already driving the formatting, everything from here
> won't have any effect.
>
> >                 file://Let's set all loggin stuff
> >                 Logger log = null;
> >                 Hierarchy hierarchy = Hierarchy.getDefaultHierarchy();
> >                 PatternFormatter formatter = new
> > PatternFormatter("[%{priority}]: %{message}\n%{throwable}");
> >                 LogTarget target = null;
> >                 target = new StreamTarget(System.err, formatter);
> >                 hierarchy.setDefaultLogTarget(target);
> >                 log = hierarchy.getLoggerFor("fop");
> >                 log.setPriority(Priority.DEBUG);
> >                 driver.setLogger(log);
> >
> >                 file://Let's try another thing
> >                 file://XSLTInputHandler input = new XSLTInputHandler(new
> > File(xmlParam), new File(xslParam));
> >
> >                 file://Let's render the Formatting tree
> >                 driver.render( voucher );
>
> This is particularly superflous, as the document has already been
> rendered.
>
> Are you sure this:
>  >                 Document xsl = xml.getXSL();
> gets you the correct DOM for the style sheet? Try dumping it
> to a file using the identity transformer:
>    TransformerFactory.newInstance().newTransformer().transform(
>      new DOMSource(xsl), new StreamResult(new File("dump.xsl")));
>
> BTW Unless you have to manipulate the content, use SAX instead
> of DOM whereever feasible.
>
> J.Pietschmann
>



Re: wrong namespace??

Posted by Esteban Gonzalez <eg...@outside.com.ar>.
Well..
I´ve just got it Working!

It all had to do with a line I commented in the DocumentBuilderFactory...

DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance()
dFactory.setNamespaceAware( true );

uncommenting the setNamespaceAware line did the trick!

I´m still not sure why.. but i´ll try to do a little more research and i´ll
keep the list updated!!!

Thanks J.Pietschman!!

A LOT!!!!


----- Original Message -----
From: "J.Pietschmann" <j3...@yahoo.de>
To: <fo...@xml.apache.org>
Sent: Wednesday, June 05, 2002 9:13 PM
Subject: Re: wrong namespace??


> Esteban Gonzalez wrote:
> > This is taking foreveeeer!
> > So I created PDFGenerator.java ( just for testing... attached ) and did
the
> > transformation as J.Pietschmann pointed out...
>
> Interesting, the test program fails if Xalan 2.0.0 is in the
> classpath but works if Saxon 6.5.4 is substituted for Xalan.
> Seems like you have hit a Xalan bug. The 2.0.0 version
> is quite a bit outdated meanwhile, download the latest
> Xalan version from http://xml.apache.org/dist and see
> whether the problem goes away if you use it.
>
> J.Pietschmann
>



Re: wrong namespace??

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Esteban Gonzalez wrote:
> This is taking foreveeeer!
> So I created PDFGenerator.java ( just for testing... attached ) and did the
> transformation as J.Pietschmann pointed out...

Interesting, the test program fails if Xalan 2.0.0 is in the
classpath but works if Saxon 6.5.4 is substituted for Xalan.
Seems like you have hit a Xalan bug. The 2.0.0 version
is quite a bit outdated meanwhile, download the latest
Xalan version from http://xml.apache.org/dist and see
whether the problem goes away if you use it.

J.Pietschmann


Re: wrong namespace??

Posted by Esteban Gonzalez <eg...@outside.com.ar>.
This is taking foreveeeer!
I´ve tried doing the FOP conversion by hand with this command

"java -cp
build/fop.jar:lib/batik.jar:lib/xalan-2.0.0.jar:lib/xerces-1.2.3.jar:lib/ava
lon-framework-4.0.jar:lib/
logkit-1.0b4.jar:lib/jimi-1.0.jar org.apache.fop.apps.Fop  -xsl
/usr/local/assistcard/com/icard/xml/voucher.xsl
 -xml /usr/local/assistcard/com/icard/xml/voucher.xml -pdf
/usr/local/assistcard/com/icard/xml/voucher.pdf"

With no problems at all... but whenever I embeed everything in a java object
i get the same old error.
"javax.xml.transform.TransformerException: stylesheet requires attribute:
version"

So i decided to do a small test class to see if doing everything from
scratch and with J.Pietschmann help it would work out.

So I created PDFGenerator.java ( just for testing... attached ) and did the
transformation as J.Pietschmann pointed out...

Just in case i dumped both the XML and XSL files to dump.xml and dump.xsl...

Everything seems to be fine, but it still is not working... =(

the classpath is set to
export
CLASSPATH=$HOME/assistcard/assistcard:/opt/fop-0.20.3/build/fop.jar:/opt/fop
-0.20.3/lib/batik.jar:/opt/f
op-0.20.3/lib/xalan-2.0.0.jar:/opt/fop-0.20.3/lib/xerces-1.2.3.jar:/opt/fop-
0.20.3/lib/avalon-framework-4.0.jar
:/opt/fop-0.20.3/lib/logkit-1.0.jar:/opt/fop-0.20.3/lib/jimi-1.0.jar

so it uses the same classes that i used when hand-generating the pdf...

Any ideas of what could be wrong?
I´ve tried everything... i´m really lost...

I know i´m being quite anoying.. but it´s just that there´s no place where
to find good documentation about this!

Best Regards,
Esteban González

ps.- sorry for the attachments... don´t know if they are allowed in this
list.

Re: wrong namespace??

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Esteban Gonzalez wrote:
 > I´m running out of ideas.

For a start, if you have still stuff after this:
 >>> trans.transform( new DOMSource( voucher ), new
 >>>    SAXResult( driver.getContentHandler() ));

delete it. Especially delete the call to render().
It is possible that the error is generated by the
second attempt at rendering the DOM document. The
trans.transform() already renders the document.

Further:
> <?xml version="1.0" encoding="UTF-8"?>
> <?xml-stylesheet type="text/xsl"
> href="c:\enhydra\xml1\assistcard\com\icard\xml\voucher.xsl"?>

There is no need for a stylesheet to link to a
stylesheet (or itself). Delete this.
In particular:
 > <?xml-stylesheet type="text/xsl"
there is no such MIME type, if you use such a PI to
link a stylesheet to an XML file (for client side
processing), use text/xml.

If all else fails, use a stylesheet to extract the
version of the style sheet, like

--- dump.xsl ---
<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:template match="/">
     <xsl:value-of select="*/@version"/>
   </xsl:template>
</xsl:stylesheet>


    Document xsl = xml.getXSL();
    Transformer trans = TransformerFactory.newInstance()
      .newTransformer(new StreamSource("dump.xsl"));
    trans.transform( new DOMSource(xsl),
      new StreamResult("dump.result"));
The result should be something like
  <?xml version="1.0" encoding="utf-8"?>1.0

J.Pietschmann


Re: wrong namespace??

Posted by Esteban Gonzalez <eg...@outside.com.ar>.
Hi!
I´ve tried dumping the xsl DOM that xml.getXSL() returned..

this is the header

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl"
href="c:\enhydra\xml1\assistcard\com\icard\xml\voucher.xsl"?>
<xsl:stylesheet version="1.0" xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="vouchers">
                <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">

Still.. I´m getting the error

javax.xml.transform.TransformerException: stylesheet requires attribute:
version
; SystemID: file://///javax.xml.transform.dom.DOMSource
; SystemID: file://///javax.xml.transform.dom.DOMSource

I´m running out of ideas.

I think it might be a problem with SAX or DOM?
this is my classpath

wrapper.classpath=/opt/fop-0.20.3/build/fop.jar
wrapper.classpath=/opt/fop-0.20.3/lib/logkit-1.0.jar
wrapper.classpath=/opt/fop-0.20.3/lib/avalon-framework-4.0.jar
wrapper.classpath=/opt/fop-0.20.3/lib/batik.jar
wrapper.classpath=/opt/fop-0.20.3/lib/tools.jar
wrapper.classpath=/opt/fop-0.20.3/lib/xalan-2.0.0.jar
wrapper.classpath=/opt/fop-0.20.3/lib/jpda.jar
wrapper.classpath=/opt/fop-0.20.3/lib/xalan-2.0.0.jar
wrapper.classpath=/opt/fop-0.20.3/lib/xalanj1compat.jar
wrapper.classpath=/opt/fop-0.20.3/lib/xerces-1.2.3.jar
wrapper.classpath=/opt/fop-0.20.3/lib/jimi-1.0.jar
#wrapper.classpath=/opt/xerces2.0/xercesImpl.jar
#wrapper.classpath=/opt/xerces2.0/xmlParserAPIs.jar

There´s anything wrong there?
----- Original Message -----
From: "J.Pietschmann" <j3...@yahoo.de>
To: <fo...@xml.apache.org>
Sent: Friday, May 31, 2002 5:48 PM
Subject: Re: wrong namespace??


> Esteban Gonzalez wrote:
> > seems like an error in the code?
> >
> >                // ADDED XML VOUCHER GENERATION
> >                 XMLGenerator xml = new XMLGenerator();
> >                 Document voucher = xml.generateVoucher( voucherGener );
> >                 Document xsl = xml.getXSL();
> >
> >                 // XSL Formatting.
> >                 Driver driver = new Driver();
> >                 driver.setRenderer( Driver.RENDER_PDF );
> >                 file://driver.setInputSource( new
DocumentInputSource() );
> >                 driver.setOutputStream( outStream );
> >
> >                 file://Let's set the input
> >                 Transformer trans =
> > TransformerFactory.newInstance().newTransformer( new DOMSource( xsl ) );
> >                 trans.transform( new DOMSource( voucher ), new
> > AXResult( driver.getContentHandler() ));
>
> This is already driving the formatting, everything from here
> won't have any effect.
>
> >                 file://Let's set all loggin stuff
> >                 Logger log = null;
> >                 Hierarchy hierarchy = Hierarchy.getDefaultHierarchy();
> >                 PatternFormatter formatter = new
> > PatternFormatter("[%{priority}]: %{message}\n%{throwable}");
> >                 LogTarget target = null;
> >                 target = new StreamTarget(System.err, formatter);
> >                 hierarchy.setDefaultLogTarget(target);
> >                 log = hierarchy.getLoggerFor("fop");
> >                 log.setPriority(Priority.DEBUG);
> >                 driver.setLogger(log);
> >
> >                 file://Let's try another thing
> >                 file://XSLTInputHandler input = new XSLTInputHandler(new
> > File(xmlParam), new File(xslParam));
> >
> >                 file://Let's render the Formatting tree
> >                 driver.render( voucher );
>
> This is particularly superflous, as the document has already been
> rendered.
>
> Are you sure this:
>  >                 Document xsl = xml.getXSL();
> gets you the correct DOM for the style sheet? Try dumping it
> to a file using the identity transformer:
>    TransformerFactory.newInstance().newTransformer().transform(
>      new DOMSource(xsl), new StreamResult(new File("dump.xsl")));
>
> BTW Unless you have to manipulate the content, use SAX instead
> of DOM whereever feasible.
>
> J.Pietschmann
>



Re: wrong namespace??

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Esteban Gonzalez wrote:
> seems like an error in the code?
> 
>                // ADDED XML VOUCHER GENERATION
>                 XMLGenerator xml = new XMLGenerator();
>                 Document voucher = xml.generateVoucher( voucherGener );
>                 Document xsl = xml.getXSL();
> 
>                 // XSL Formatting.
>                 Driver driver = new Driver();
>                 driver.setRenderer( Driver.RENDER_PDF );
>                 //driver.setInputSource( new DocumentInputSource() );
>                 driver.setOutputStream( outStream );
> 
>                 //Let's set the input
>                 Transformer trans =
> TransformerFactory.newInstance().newTransformer( new DOMSource( xsl ) );
>                 trans.transform( new DOMSource( voucher ), new
> AXResult( driver.getContentHandler() ));

This is already driving the formatting, everything from here
won't have any effect.

>                 //Let's set all loggin stuff
>                 Logger log = null;
>                 Hierarchy hierarchy = Hierarchy.getDefaultHierarchy();
>                 PatternFormatter formatter = new
> PatternFormatter("[%{priority}]: %{message}\n%{throwable}");
>                 LogTarget target = null;
>                 target = new StreamTarget(System.err, formatter);
>                 hierarchy.setDefaultLogTarget(target);
>                 log = hierarchy.getLoggerFor("fop");
>                 log.setPriority(Priority.DEBUG);
>                 driver.setLogger(log);
> 
>                 //Let's try another thing
>                 //XSLTInputHandler input = new XSLTInputHandler(new
> File(xmlParam), new File(xslParam));
> 
>                 //Let's render the Formatting tree
>                 driver.render( voucher );

This is particularly superflous, as the document has already been
rendered.

Are you sure this:
 >                 Document xsl = xml.getXSL();
gets you the correct DOM for the style sheet? Try dumping it
to a file using the identity transformer:
   TransformerFactory.newInstance().newTransformer().transform(
     new DOMSource(xsl), new StreamResult(new File("dump.xsl")));

BTW Unless you have to manipulate the content, use SAX instead
of DOM whereever feasible.

J.Pietschmann


Re: wrong namespace??

Posted by Esteban Gonzalez <eg...@outside.com.ar>.
Our designer did all transformations using Fop via command line...

so the transformation should be working fine...

seems like an error in the code?

               // ADDED XML VOUCHER GENERATION
                XMLGenerator xml = new XMLGenerator();
                Document voucher = xml.generateVoucher( voucherGener );
                Document xsl = xml.getXSL();

                // XSL Formatting.
                Driver driver = new Driver();
                driver.setRenderer( Driver.RENDER_PDF );
                //driver.setInputSource( new DocumentInputSource() );
                driver.setOutputStream( outStream );

                //Let's set the input
                Transformer trans =
TransformerFactory.newInstance().newTransformer( new DOMSource( xsl ) );
                trans.transform( new DOMSource( voucher ), new
AXResult( driver.getContentHandler() ));

                //Let's set all loggin stuff
                Logger log = null;
                Hierarchy hierarchy = Hierarchy.getDefaultHierarchy();
                PatternFormatter formatter = new
PatternFormatter("[%{priority}]: %{message}\n%{throwable}");
                LogTarget target = null;
                target = new StreamTarget(System.err, formatter);
                hierarchy.setDefaultLogTarget(target);
                log = hierarchy.getLoggerFor("fop");
                log.setPriority(Priority.DEBUG);
                driver.setLogger(log);

                //Let's try another thing
                //XSLTInputHandler input = new XSLTInputHandler(new
File(xmlParam), new File(xslParam));

                //Let's render the Formatting tree
                driver.render( voucher );

any help would be appreciated


----- Original Message -----
From: "Ralf Steppacher" <st...@esteam.de>
To: <fo...@xml.apache.org>
Sent: Friday, May 31, 2002 1:44 PM
Subject: Re: wrong namespace??


> I´ve copied your xsl and tried doing a transformation...
>
> unfortunately i´m still getting the same error...

Have you tried to do the transformation on the command line?
How does the code you use look like?

Ralf




Re: wrong namespace??

Posted by Ralf Steppacher <st...@esteam.de>.
> I´ve copied your xsl and tried doing a transformation...
> 
> unfortunately i´m still getting the same error...

Have you tried to do the transformation on the command line?
How does the code you use look like?

Ralf


Re: wrong namespace??

Posted by Esteban Gonzalez <eg...@outside.com.ar>.
I´ve copied your xsl and tried doing a transformation...

unfortunately i´m still getting the same error...

so i guess it´s something else I´m missing.. =(

btw.. most of the xsl style sheet was made using
http://www.dpawson.co.uk/xsl/sect3/bk/index.html. as a reference! it´s a
great link...

Best Regards,
Esteban

----- Original Message -----
From: "Ralf Steppacher" <st...@esteam.de>
To: <fo...@xml.apache.org>
Sent: Friday, May 31, 2002 1:23 PM
Subject: Re: wrong namespace??


>
>
> Esteban Gonzalez wrote:
> > This is the error
> > javax.xml.transform.TransformerConfigurationException: stylesheet
requires
> > attribute: version
> >         at
> >
org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(Transformer
> > And this is the XSL styleSheet
> > [..]
>
> I pruned your stylesheet and transformed a XML document:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <?xml-stylesheet
>      type="text/xsl"
>      href="Z:\steppacher\XML\Temp\voucher.xsl"?>
> <vouchers>
> <voucher/>
> </vouchers>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <?xml-stylesheet
>      type="text/xsl"
>      href="c:\enhydra\xml1\assistcard\com\icard\xml\voucher.xsl"?>
> <xsl:stylesheet version="1.0"
>      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>      xmlns:fo="http://www.w3.org/1999/XSL/Format">
>      <xsl:template match="vouchers">
>          <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
>              <fo:layout-master-set>
>                  <fo:simple-page-master
>                      page-height="14in" page-width="8.5in"
>                      margin-top="35mm" margin-left="28mm"
>                      margin-right="14mm">
>                      <fo:region-body/>
>                      <fo:region-before extent="0mm"/>
>                  </fo:simple-page-master>
>              </fo:layout-master-set>
>              <fo:page-sequence master-name="simple">
>                  <fo:flow flow-name="xsl-region-body">
>                      <fo:block font-size="10pt">
>                          <xsl:call-template name="voucher"/>
>                      </fo:block>
>                  </fo:flow>
>              </fo:page-sequence>
>          </fo:root>
>      </xsl:template>
>
>      <xsl:template match="//vouchers/voucher" name="voucher">
>          <fo:block>Hello World</fo:block>
>      </xsl:template>
>
> </xsl:stylesheet>
>
>
> This worked fine using xalan 2.3.1 from command line and with some test
> code.
> It seems it needs someone more versed to help you with this.
>
> Concerning your FO: You should have a look at
> http://www.dpawson.co.uk/xsl/sect3/bk/index.html.
>
>
> Ralf
>



Re: wrong namespace??

Posted by Ralf Steppacher <st...@esteam.de>.

Esteban Gonzalez wrote:
> This is the error
> javax.xml.transform.TransformerConfigurationException: stylesheet requires
> attribute: version
>         at
> org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(Transformer
> And this is the XSL styleSheet
> [..]

I pruned your stylesheet and transformed a XML document:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet
     type="text/xsl"
     href="Z:\steppacher\XML\Temp\voucher.xsl"?>
<vouchers>
	<voucher/>
</vouchers>


<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet
     type="text/xsl"
     href="c:\enhydra\xml1\assistcard\com\icard\xml\voucher.xsl"?>
<xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:fo="http://www.w3.org/1999/XSL/Format">
     <xsl:template match="vouchers">
         <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
             <fo:layout-master-set>
                 <fo:simple-page-master
                     page-height="14in" page-width="8.5in"
                     margin-top="35mm" margin-left="28mm"
                     margin-right="14mm">
                     <fo:region-body/>
                     <fo:region-before extent="0mm"/>
                 </fo:simple-page-master>
             </fo:layout-master-set>
             <fo:page-sequence master-name="simple">
                 <fo:flow flow-name="xsl-region-body">
                     <fo:block font-size="10pt">
                         <xsl:call-template name="voucher"/>
                     </fo:block>
                 </fo:flow>
             </fo:page-sequence>
         </fo:root>
     </xsl:template>
	
     <xsl:template match="//vouchers/voucher" name="voucher">
         <fo:block>Hello World</fo:block>
     </xsl:template>

</xsl:stylesheet>


This worked fine using xalan 2.3.1 from command line and with some test 
code.
It seems it needs someone more versed to help you with this.

Concerning your FO: You should have a look at 
http://www.dpawson.co.uk/xsl/sect3/bk/index.html.


Ralf


Re: wrong namespace??

Posted by Esteban Gonzalez <eg...@outside.com.ar>.
This is the error
javax.xml.transform.TransformerConfigurationException: stylesheet requires
attribute: version
        at
org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(Transformer
FactoryImpl.java:650)
        at com.icard.handlers.PDFManager.execute(Unknown Source)
        at com.icard.servlet.GenericServlet.doGet(Unknown Source)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:271)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:311)
        at
org.apache.jserv.JServConnection.processRequest(JServConnection.java:317)
        at org.apache.jserv.JServConnection.run(JServConnectio

And this is the XSL styleSheet

<?xml version="1.0" encoding="UTF-8"?>

<?xml-stylesheet type="text/xsl"
href="c:\enhydra\xml1\assistcard\com\icard\xml\voucher.xsl"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">

<xsl:template match="vouchers">

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

<xsl:for-each select="voucher">

<fo:layout-master-set>

<fo:simple-page-master page-height="14in" page-width="8.5in"
margin-top="35mm" margin-left="28mm" margin-right="14mm">

<fo:region-body/>

<fo:region-before extent="0mm"/>

</fo:simple-page-master>

</fo:layout-master-set>

<fo:page-sequence master-name="simple">

<fo:flow flow-name="xsl-region-body">

<fo:block font-size="10pt">

<xsl:call-template name="voucher"/>

</fo:block>

</fo:flow>

</fo:page-sequence>

</xsl:for-each>

</fo:root>

</xsl:template>

<xsl:template match="//vouchers/voucher" name="voucher">

<xsl:apply-templates select="cliente"/>

<xsl:apply-templates select="producto"/>

<xsl:apply-templates select="agencia"/>

<xsl:apply-templates select="seguroEmitido"/>

<xsl:apply-templates select="seguro"/>

<fo:table-cell>

<fo:block margin-left="0mm" padding-top="16pt">

<xsl:apply-templates select="@pais"/>&#160;<xsl:apply-templates
select="@codigo"/>&#160;<xsl:apply-templates select="@tipo_pax_voucher"/>

<xsl:apply-templates select="@sufijo_voucher"/>

</fo:block>

<fo:block margin-left="0mm" padding-top="5mm">EXPIRES:<xsl:apply-templates
select="@fec_vig_fin"/>

</fo:block>

<fo:block margin-left="0mm" padding-top="83mm">

<xsl:apply-templates select="@fecha_emision"/>

</fo:block>

<fo:block margin-left="88mm" padding-top="86pt" font-size="9pt">

<xsl:apply-templates select="@fec_vig_inic"/>

</fo:block>

<fo:block margin-left="88mm" padding-top="1mm"
font-size="9pt">------------</fo:block>

<fo:block margin-left="88mm" padding-top="1mm"
font-size="9pt">------------</fo:block>

<xsl:if test="//seguro/compania != ''">

<fo:block margin-left="0mm" padding-top="82mm">

<xsl:apply-templates select="@cant_dias"/>

</fo:block>

</xsl:if>

</fo:table-cell>

<fo:table-cell>

<fo:block margin-left="90mm" padding-top="16pt">

<xsl:apply-templates select="@pais"/>&#160;<xsl:apply-templates
select="@codigo"/>&#160;<xsl:apply-templates select="@tipo_pax_voucher"/>

<xsl:apply-templates select="@sufijo_voucher"/>

</fo:block>

<fo:block margin-left="90mm" padding-top="5mm">EXPIRES:<xsl:apply-templates
select="@fec_vig_fin"/>

</fo:block>

<fo:block margin-left="90mm" padding-top="117pt">

<xsl:apply-templates select="@pais"/>&#160;<xsl:apply-templates
select="@codigo"/>&#160;<xsl:apply-templates select="@tipo_pax_voucher"/>

<xsl:apply-templates select="@sufijo_voucher"/>

</fo:block>

<fo:block margin-left="90mm" padding-top="5mm">EXPIRES:<xsl:apply-templates
select="@fec_vig_fin"/>

</fo:block>

<fo:block margin-left="111mm" padding-top="179pt" font-size="9pt">

<xsl:apply-templates select="@fec_vig_fin"/>

</fo:block>

<fo:block margin-left="111mm" padding-top="1mm"
font-size="9pt">-------------</fo:block>

<fo:block margin-left="111mm" padding-top="1mm"
font-size="9pt">-------------</fo:block>

<xsl:if test="//seguro/compania != ''">

<fo:block margin-left="45mm" padding-top="82mm">

<xsl:apply-templates select="@fec_vig_inic"/>

</fo:block>

</xsl:if>

</fo:table-cell>

<fo:table-cell>

<fo:block margin-left="110mm" padding-top="93mm">

<xsl:apply-templates select="@pais"/>&#160;<xsl:apply-templates
select="@codigo"/>&#160;<xsl:apply-templates select="@tipo_pax_voucher"/>

<xsl:apply-templates select="@sufijo_voucher"/>

</fo:block>

<fo:block margin-left="133mm" padding-top="39mm" font-size="9pt">

<xsl:apply-templates select="@area"/>

</fo:block>

<fo:block margin-left="133mm" padding-top="1mm"
font-size="9pt">---</fo:block>

<fo:block margin-left="133mm" padding-top="1mm"
font-size="9pt">---</fo:block>

</fo:table-cell>

<fo:table-cell>

<fo:block margin-left="165mm" padding-top="136mm" font-size="9pt">

<xsl:apply-templates select="@tarifa_impresa"/>

</fo:block>

<fo:block margin-left="165mm" padding-top="1mm" font-size="9pt">

<xsl:apply-templates select="@tax_impuesto"/>

</fo:block>

<fo:block margin-left="165mm" padding-top="1mm" font-size="9pt">

<xsl:apply-templates select="@tax_emitida"/>

</fo:block>

<fo:block margin-left="156mm" padding-top="4mm">

<xsl:apply-templates select="@cant_dias"/>

</fo:block>

</fo:table-cell>

</xsl:template>

<xsl:template match="//voucher/cliente" name="cliente">

<fo:table-cell>

<fo:block margin-left="0mm" padding-top="10mm">

<xsl:apply-templates select="apellido"/>&#160;<xsl:apply-templates
select="nombre"/>

</fo:block>

<fo:block margin-left="0mm" padding-top="97mm">

<xsl:apply-templates select="apellido"/>&#160;<xsl:apply-templates
select="nombre"/>

</fo:block>

<fo:block margin-left="0mm" padding-top="4mm">

<xsl:apply-templates select="dom_calle"/>&#160;<xsl:apply-templates
select="dom_nro"/>

</fo:block>

<fo:block margin-left="0mm" padding-top="5mm">

<xsl:apply-templates select="emerg_contacto"/>

</fo:block>

<fo:block margin-left="0mm" padding-top="12pt">

<xsl:apply-templates select="emerg_tel1"/>

</fo:block>

<fo:block margin-left="0mm" padding-top="13pt">

<xsl:apply-templates select="emerg_pais"/>

</fo:block>

<fo:block margin-left="0mm" padding-top="14pt">

<xsl:apply-templates select="emerg_calle"/>&#160;<xsl:apply-templates
select="emerg_nro"/>&#160;<xsl:apply-templates
select="emerg_piso"/>&#160;<xsl:apply-templates select="emerg_puerta"/>

</fo:block>

<xsl:if test="//seguro/compania != ''">

<fo:block margin-left="0mm" padding-top="54mm">

<xsl:apply-templates select="apellido"/>&#160;<xsl:apply-templates
select="nombre"/>

</fo:block>

</xsl:if>

</fo:table-cell>

<fo:table-cell>

<fo:block margin-left="68mm" padding-top="111mm">

<xsl:apply-templates select="sexo"/>

</fo:block>

</fo:table-cell>

<fo:table-cell>

<fo:block margin-left="80mm" padding-top="111mm">

<xsl:apply-templates select="edad"/>

</fo:block>

<fo:block margin-left="78mm" padding-top="4mm">

<xsl:apply-templates select="dom_cp"/>

</fo:block>

</fo:table-cell>

<fo:table-cell>

<fo:block margin-left="90mm" padding-top="10mm">

<xsl:apply-templates select="apellido"/>&#160;<xsl:apply-templates
select="nombre"/>

</fo:block>

<fo:block margin-left="90mm" padding-top="50mm">

<xsl:apply-templates select="apellido"/>&#160;<xsl:apply-templates
select="nombre"/>

</fo:block>

<fo:block margin-left="101mm" padding-top="122pt">

<xsl:apply-templates select="pasaporte"/>

</fo:block>

<fo:block margin-left="113mm" padding-top="4mm">

<xsl:apply-templates select="dom_ciudad"/>

</fo:block>

<fo:block margin-left="95mm" padding-top="5mm">

<xsl:apply-templates select="emerg_email"/>

</fo:block>

</fo:table-cell>

<fo:table-cell>

<fo:block margin-left="140mm" padding-top="111mm">

<xsl:apply-templates select="tel_particular"/>

</fo:block>

<fo:block margin-left="152mm" padding-top="4mm">

<xsl:apply-templates select="dom_country"/>

</fo:block>

</fo:table-cell>

</xsl:template>

<xsl:template match="//voucher/producto" name="producto">

<fo:table-cell>

<fo:block margin-left="0mm" padding-top="55pt">

<xsl:apply-templates select="nombre"/>

</fo:block>

</fo:table-cell>

<fo:table-cell>

<fo:block margin-left="90mm" padding-top="55pt">

<xsl:apply-templates select="nombre"/>

</fo:block>

<fo:block margin-left="90mm" padding-top="50mm">

<xsl:apply-templates select="nombre"/>

</fo:block>

<fo:block margin-left="130mm" padding-top="25mm">

<xsl:apply-templates select="nombre"/>

</fo:block>

</fo:table-cell>

</xsl:template>

<xsl:template match="agencia" name="agencia">

<fo:table-cell>

<fo:block margin-left="60mm" padding-top="102mm" font-size="9pt">

<xsl:apply-templates select="codigo"/>&#160;-&#160;<xsl:apply-templates
select="nombre_comercial"/>

</fo:block>

<xsl:if test="//seguro/compania != ''">

<fo:block margin-left="93mm" padding-top="135mm" font-size="9pt">

<xsl:apply-templates select="codigo"/>&#160;-&#160;<xsl:apply-templates
select="nombre_comercial"/>

</fo:block>

<fo:block margin-left="93mm" padding-top="2mm" font-size="9pt">

<xsl:apply-templates select="ciudad"/>

</fo:block>

</xsl:if>

</fo:table-cell>

</xsl:template>

<xsl:template match="seguroEmitido" name="seguroEmitido">

<fo:table-cell>

<fo:block margin-left="0mm" padding-top="221mm">

<xsl:apply-templates select="nroVoucher"/>

</fo:block>

<fo:block margin-left="0mm" padding-top="14mm">

<xsl:apply-templates select="nro_recibo"/>

</fo:block>

</fo:table-cell>

<fo:table-cell>

<fo:block margin-left="45mm" padding-top="239mm">

<xsl:apply-templates select="fec_recibo"/>

</fo:block>

</fo:table-cell>

<fo:table-cell>

<fo:block margin-left="100mm" padding-top="208mm">

<xsl:apply-templates select="nro_certificado"/>

</fo:block>

</fo:table-cell>

</xsl:template>

<xsl:template match="seguro" name="seguro">

<fo:table-cell>

<fo:block margin-left="0mm" padding-top="203mm">

<xsl:apply-templates select="compania"/>

</fo:block>

</fo:table-cell>

<fo:table-cell>

<fo:block margin-left="155mm" padding-top="208mm">

<xsl:apply-templates select="poliza"/>

</fo:block>

<fo:block margin-left="155mm" padding-top="9mm">

<xsl:apply-templates select="tope"/>

</fo:block>

<fo:block margin-left="155mm" padding-top="1pt">

<xsl:apply-templates select="tope_aereo"/>

</fo:block>

<fo:block margin-left="155mm" padding-top="1pt">

<xsl:apply-templates select="tope_terrestre"/>

</fo:block>

<fo:block margin-left="155mm" padding-top="0pt">

<xsl:apply-templates select="total"/>

</fo:block>

</fo:table-cell>

</xsl:template>

</xsl:stylesheet>


----- Original Message -----
From: "Ralf Steppacher" <st...@esteam.de>
To: <fo...@xml.apache.org>
Sent: Friday, May 31, 2002 12:18 PM
Subject: Re: wrong namespace??


> So looking at what you just said this
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:fo="http://www.w3.org/1999/XSL/Format" >
>
> should be right..

Yes.


> But i´m still getting the same error..
>
> any ideas?

No, sorry. Perhaps someone else?

Could you post your stylesheet?


Ralf

> ----- Original Message -----
> From: "Ralf Steppacher" <st...@esteam.de>
> To: <fo...@xml.apache.org>
> Sent: Friday, May 31, 2002 4:46 AM
> Subject: Re: wrong namespace??
>
>
>
>>><xsl:stylesheet version="1.0"
>>
>> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>> >
>> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>> > xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
>> >
>> > wich one is right?...
>>
>>If you write a stylesheet that contains formatting objects you have to
>>include both the Transform and Format namespace.
>>
>>
>> > i seem to get the error anyway with both namespaces... =(
>>
>>The version attribute has nothing to do with namespace declarations.
>>The version attribute is the only mandatory attribute of the stylesheet
>>element. Be sure there are no typos.
>>
>>See http://www.w3.org/TR/xslt#stylesheet-element.
>>
>>
>>Ralf
>>
>
>
>
>





Re: wrong namespace??

Posted by Ralf Steppacher <st...@esteam.de>.
> So looking at what you just said this
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:fo="http://www.w3.org/1999/XSL/Format" >
> 
> should be right..

Yes.


> But i´m still getting the same error..
> 
> any ideas?

No, sorry. Perhaps someone else?

Could you post your stylesheet?


Ralf

> ----- Original Message -----
> From: "Ralf Steppacher" <st...@esteam.de>
> To: <fo...@xml.apache.org>
> Sent: Friday, May 31, 2002 4:46 AM
> Subject: Re: wrong namespace??
> 
> 
> 
>>><xsl:stylesheet version="1.0"
>>
>> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>> >
>> > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>> > xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
>> >
>> > wich one is right?...
>>
>>If you write a stylesheet that contains formatting objects you have to
>>include both the Transform and Format namespace.
>>
>>
>> > i seem to get the error anyway with both namespaces... =(
>>
>>The version attribute has nothing to do with namespace declarations.
>>The version attribute is the only mandatory attribute of the stylesheet
>>element. Be sure there are no typos.
>>
>>See http://www.w3.org/TR/xslt#stylesheet-element.
>>
>>
>>Ralf
>>
> 
> 
> 
> 



Re: wrong namespace??

Posted by Esteban Gonzalez <eg...@outside.com.ar>.
So looking at what you just said this
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format" >

should be right..

But i´m still getting the same error..

any ideas?

Best Regards,

Esteban

----- Original Message -----
From: "Ralf Steppacher" <st...@esteam.de>
To: <fo...@xml.apache.org>
Sent: Friday, May 31, 2002 4:46 AM
Subject: Re: wrong namespace??


> > <xsl:stylesheet version="1.0"
>  > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>  >
>  > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>  > xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
>  >
>  > wich one is right?...
>
> If you write a stylesheet that contains formatting objects you have to
> include both the Transform and Format namespace.
>
>
>  > i seem to get the error anyway with both namespaces... =(
>
> The version attribute has nothing to do with namespace declarations.
> The version attribute is the only mandatory attribute of the stylesheet
> element. Be sure there are no typos.
>
> See http://www.w3.org/TR/xslt#stylesheet-element.
>
>
> Ralf
>



Re: wrong namespace??

Posted by Ralf Steppacher <st...@esteam.de>.
 > <xsl:stylesheet version="1.0"
 > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 >
 > <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 > xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">
 >
 > wich one is right?...

If you write a stylesheet that contains formatting objects you have to 
include both the Transform and Format namespace.


 > i seem to get the error anyway with both namespaces... =(

The version attribute has nothing to do with namespace declarations.
The version attribute is the only mandatory attribute of the stylesheet 
element. Be sure there are no typos.

See http://www.w3.org/TR/xslt#stylesheet-element.


Ralf


wrong namespace??

Posted by Esteban Gonzalez <eg...@outside.com.ar>.
Hi J.Pietschmann,
    You pointed me into the right path!
    I´m now solved my problems with the parser.. altough now I get a brand
new error...

javax.xml.transform.TransformerConfigurationException: stylesheet requires
attribute: version
at
org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(Transformer
FactoryImpl.java:650)

I´ve been digging thru the docs and seems like my xsl namespace is wrong..
so i´ve found this two possible namespaces defitnitions..

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0">



wich one is right?...

i seem to get the error anyway with both namespaces... =(



Best Regards,
Esteban



----- Original Message -----
From: "J.Pietschmann" <j3...@yahoo.de>
To: <fo...@xml.apache.org>
Sent: Wednesday, May 29, 2002 8:54 PM
Subject: Re: Embedding.... newbie problem....


> Esteban Gonzalez wrote:
> > Hi!
> > I´ve been trying to do some xml --> pdf transformation using FOP.
> > When I run FOP manually everything is wonderful,  but i don´t seem to
really
> > understand how to embeed it in a running app.
> > The problem is with the input Source ..
> > I have both the xml file and the xsl file as org.w3c.dom.Document and I
> > don´t seem to be able to use them as input for the transformation.
> > I´ll post a code snippet to make myself clear
> > <code>
> ...
> >                 Driver driver = new Driver();
> >                 driver.setRenderer( Driver.RENDER_PDF );
> >                 driver.setInputSource( new DocumentInputSource( xsl ) );
>
> This won't work. THe driver expects a FO document at this
> point, no XSLT.
>
> > (http://xml.apache.org/fop/embedding.html), the problem is.. I seem to
be
> > setting an XSL file as an input... so where do I set the XML Document as
an
> > input?
>
> You need an XSLT transformer.
> Something like this:
>
>   Driver driver =new Driver();
>   driver.setOutputStream(response.getOutputStream());
>   driver.setRenderer(Driver.RENDER_PDF);
>   Transformer transformer=TransformerFactory.newInstance()
>           .newTransformer(new DOMSource(xsl));
>   transformer.transform(new DOMSource(xml),
>        new SAXResult(driver.getContentHandler()));
>
> Check the package javax.xml.transform and subpackages.
>
> J.Pietschmann
>
>
>
> > I´ve been digging thru the fop api and found out this class XSLTransform
> > wich seems to take an XLM doc, and a XSL file as inputs and outputs a
> > org.w3c.dom.Document, but again.. I can´t input the XSL as a document...
> >
> > there are any workarounds to this problems?...
> > or maybe some ideas?
> >
> > Thanks for all your help!
> >
> > Best Regards,
> > Esteban González
> >
> > ----------------------------------
> > Esteban González
> >
> > Departamento de Sistemas
> > ASSIST-CARD International
> >
> >
>
>
>



Re: Embedding.... newbie problem....

Posted by "J.Pietschmann" <j3...@yahoo.de>.
Esteban Gonzalez wrote:
> Hi!
> I´ve been trying to do some xml --> pdf transformation using FOP.
> When I run FOP manually everything is wonderful,  but i don´t seem to really
> understand how to embeed it in a running app.
> The problem is with the input Source ..
> I have both the xml file and the xsl file as org.w3c.dom.Document and I
> don´t seem to be able to use them as input for the transformation.
> I´ll post a code snippet to make myself clear
> <code>
...
>                 Driver driver = new Driver();
>                 driver.setRenderer( Driver.RENDER_PDF );
>                 driver.setInputSource( new DocumentInputSource( xsl ) );

This won't work. THe driver expects a FO document at this
point, no XSLT.

> (http://xml.apache.org/fop/embedding.html), the problem is.. I seem to be
> setting an XSL file as an input... so where do I set the XML Document as an
> input?

You need an XSLT transformer.
Something like this:

  Driver driver =new Driver();
  driver.setOutputStream(response.getOutputStream());
  driver.setRenderer(Driver.RENDER_PDF);
  Transformer transformer=TransformerFactory.newInstance()
          .newTransformer(new DOMSource(xsl));
  transformer.transform(new DOMSource(xml),
       new SAXResult(driver.getContentHandler()));

Check the package javax.xml.transform and subpackages.

J.Pietschmann



> I´ve been digging thru the fop api and found out this class XSLTransform
> wich seems to take an XLM doc, and a XSL file as inputs and outputs a
> org.w3c.dom.Document, but again.. I can´t input the XSL as a document...
> 
> there are any workarounds to this problems?...
> or maybe some ideas?
> 
> Thanks for all your help!
> 
> Best Regards,
> Esteban González
> 
> ----------------------------------
> Esteban González
> 
> Departamento de Sistemas
> ASSIST-CARD International
> 
>