Here is a version of the code. I've inlined it for illustration purposes.
String uRI = "http://mywebserver/batik1.5/samples/mapSpain.svg"; //step 1 create a Document from a URI String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); Document document = f.createDocument(uRI); //step 2 write it so a string... SVGTranscoder trans = new SVGTranscoder(); trans.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(.8)); TranscoderInput input = new TranscoderInput(document); StringWriter writer = new StringWriter(); TranscoderOutput output = new TranscoderOutput(writer); trans.transcode(input, output); String svgDocString = writer.toString(); //step 3 convert the string to a Document StringReader reader = new StringReader(svgDocString ); String parser = XMLResourceDescriptor.getXMLParserClassName(); SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); Document anotherDocument = f.createDocument(uRI, reader); If I insert the code below between step 2 and step 3 then the Document created in step 3 is correctly constructed: svgDocString = svgDocString.replaceAll("<style xml:space=\"preserve\" type=\"text/css\" xml:space=\"preserve\">" ,"<style type=\"text/css\">"); if I don't insert the code above I get an error reporting that the xml:space tag is appears more than once. It seems that the <style> tag has the xml:space tags added to it when it is written to the StringWriter??? /Cory -----Original Message----- From: Vincent Hardy [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 21, 2002 6:28 AM To: Batik Users Subject: Re: Bug in transcoder. Cory, Could you send more details telling us what you are doing exactly with the transcoders? Thanks, Vincent. Cory Sanoy wrote: > I checked the bugs database and this does not seem to be listed. The problem > is with the transcoder. When transcoding a document with a style tag: > > <style type="text/css"> > > the transcoder inserts xml:space tags into the style element: > > <style xml:space="preserve" type="text/css" xml:space="preserve"> > > when the document is parsed back in via: > > StringReader reader = new StringReader(docString); > String parser = XMLResourceDescriptor.getXMLParserClassName(); > SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser); > Document document = f.createDocument(uRI, reader); > > The parser throws an exception complaining that xml:space is defined more > than once. > > To get arround the problem I simple replace the erroneous style element with > the original style element and the parser works correctly. > > Is there a better way of doing this? Perhaps I should be using a different > parser?? > > /Cory > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
