On 10/21/2010 7:27 AM, thomas.dewe...@kodak.com wrote:
Hi Fawzib,
Fawzib Rojas <f_ro...@spectron-msim.com> wrote on 10/20/2010 03:37:18 PM:
> I don't know how to do that, never worked with Batik until now. The
> source of the cocoon-batik-block is
> at http://www.megaupload.com/?d=NQBUKM9W
I took a quick look at the code here, in particular SVGBuilder.
The code in that class looks really questionable to me. It subclasses
our SAXSVGDocumentFactory and tries to manipulate the base classes state.
This is in general a bad idea and exactly the sort of hacks that tend to
cause breakage when the baseclass code changes.
So the one thing I noticed that at least looks like real
trouble is
in the override of startDocument the class tries to set the base classes
'document' member. But it then calls the baseclasses startDocument
method,
which is just going to 'null' out the document member.
Also the attempts to manipulate the set of namespace prefixes
seems problematic to me.
That code was made by the cocoon guys dont blame me :)
From looking at that code it is just used to sets (fix?) the namespace.
I was recreating the DOM using DOMUtilities.deepCloneDocument before the
transcode so I thought it was not needed. I removed startDocument and
it made no difference. Gave me the same error so I removed the
DOMUtilities.deepCloneDocument part.
I took a look at SVGSerializerNG and I didn't see anything
wrong but since the problem with the document probably occured
before that I don't think that means much.
BTW I would try printing the namespace and tag name for the root
element of the document passed to the serializer and see if that is
correct
(I suspect it isn't).
Yes the problem comes before that but I have no idea where.
The document I'm using for testing is
http://croczilla.com/bits_and_pieces/svg/samples/tiger/text_view?obj=tiger.svg
I checked the root element like u asked and it looks like this:
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
height="800"
preserveAspectRatio="xMidYMid meet"
zoomAndPan="magnify"
version="1.1"
contentScriptType="text/ecmascript"
contentStyleType="text/css"
>
I changed startElement and added a loop to print all attributes in the
svg element. It prints all the attributes except both xmlns
declarations. It seems something somewhere is filtering them out. Since
it cant find the attribute, there is no namespace. I added some code so
that if there is no namespace it adds it. It's basically the same the
cocoon guys did but I added it in startElement just as it creates the
document. The new code is at http://www.megaupload.com/?d=WQNQUDQJ if
you want to look at it.
After those changes things moved along a little bit farther down the
line but now batik gives me a NullPointerException in
JPEGTranscoder.writeImage, I checked the output stream and it is valid,
so must be something else:
Caused by: java.lang.NullPointerException
at
org.apache.batik.transcoder.image.JPEGTranscoder.writeImage(JPEGTranscoder.java:96)
at
org.apache.batik.transcoder.image.ImageTranscoder.transcode(ImageTranscoder.java:130)
at
org.apache.batik.transcoder.XMLAbstractTranscoder.transcode(XMLAbstractTranscoder.java:142)
at
org.apache.batik.transcoder.SVGAbstractTranscoder.transcode(SVGAbstractTranscoder.java:156)
at
org.apache.cocoon.serialization.SVGSerializerNG.notify(SVGSerializerNG.java:219)
at org.apache.cocoon.xml.dom.SVGBuilder.endDocument(SVGBuilder.java:127)