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/06/04 18:32:36 UTC

Re: wrong namespace??

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