Helder Magalhães wrote:
> 
> Does it happen with documents which already contain the "xml:space"
> attribute or whose attribute ("xml:space") was inserted there by you
> (through DOM manipulation)?
> 
> Can you atatch a reduced test case (original SVG document and
> potentially a code snippet)? This will enable more informed feedback
> on this (weird) behavior... ;-)
> 

hello and thanks for your quick reply.

yes this happens with documents that contain the xml:space="preserve" and
here is a quick testcase that produces the behaviour with this svg

http://deviantsart.com/upload/c314e36136de3bd75fe974bdc7cfef2e.svg

thank you!




import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.StringWriter;

import org.apache.batik.dom.svg.SVGOMDocument;
import org.apache.batik.dom.util.DocumentFactory;
import org.apache.batik.transcoder.SVGAbstractTranscoder;
import org.apache.batik.transcoder.TranscoderException;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;
import org.apache.batik.transcoder.svg2svg.SVGTranscoder;
import org.apache.batik.util.XMLResourceDescriptor;
import org.w3c.dom.DOMException;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;

public class Batik extends SVGAbstractTranscoder {

        
        public static void main(String [] args) {
                new Batik();
        }
        
        
        String namespaceURI;
        
        public Batik() {
                SVGOMDocument doc = null;
                FileInputStream is;
                try {
                        is = new 
FileInputStream("data/textures/interface/arrow.svg");
                        TranscoderInput input = new TranscoderInput(is);
                        doc = getDocument(input);
                        
                        is.close();
                } catch (Exception e) {
                        e.printStackTrace();
                }

                
                
                StringWriter sw = new StringWriter();
                TranscoderOutput to = new TranscoderOutput(sw);
                TranscoderInput ti = new TranscoderInput(doc);
                SVGTranscoder pt = new SVGTranscoder();


                try {
                        pt.transcode(ti, to);
                } catch (TranscoderException e) {
                        e.printStackTrace();
                }
                System.out.println(sw.toString());
                
                                
        }
        
        protected SVGOMDocument getDocument(TranscoderInput input) throws
TranscoderException {           
                String uri = input.getURI();
                Document document = input.getDocument();
                if (document == null) {
                        
                        String parserClassname = (String) 
hints.get(KEY_XML_PARSER_CLASSNAME);
                        namespaceURI = (String) 
hints.get(KEY_DOCUMENT_ELEMENT_NAMESPACE_URI);
                        String documentElement = (String) 
hints.get(KEY_DOCUMENT_ELEMENT);
                        DOMImplementation domImpl = (DOMImplementation)
hints.get(KEY_DOM_IMPLEMENTATION);

                        if (parserClassname == null) {
                                parserClassname = 
XMLResourceDescriptor.getXMLParserClassName();
                        }
                        if (domImpl == null) {
                                throw new TranscoderException("Unspecified 
transcoding hints:
KEY_DOM_IMPLEMENTATION");
                        }
                        if (namespaceURI == null) {
                                throw new TranscoderException("Unspecified 
transcoding hints:
KEY_DOCUMENT_ELEMENT_NAMESPACE_URI");
                        }
                        if (documentElement == null) {
                                throw new TranscoderException("Unspecified 
transcoding hints:
KEY_DOCUMENT_ELEMENT");
                        }
                        // parse the XML documentetz
                        DocumentFactory f = createDocumentFactory(domImpl, 
parserClassname);
                        boolean b = ((Boolean)
hints.get(KEY_XML_PARSER_VALIDATING)).booleanValue();
                        f.setValidating(b);
                        try {
                                if (input.getInputStream() != null) {
                                        document = 
f.createDocument(namespaceURI, documentElement,
input.getURI(), input.getInputStream());
                                } else if (input.getReader() != null) {
                                        document = 
f.createDocument(namespaceURI, documentElement,
input.getURI(), input.getReader());
                                } else if (input.getXMLReader() != null) {
                                        document = 
f.createDocument(namespaceURI, documentElement,
input.getURI(), input.getXMLReader());
                                } else if (uri != null) {
                                        document = 
f.createDocument(namespaceURI, documentElement, uri);
                                }
                        } catch (DOMException ex) {
                                throw new TranscoderException(ex);
                        } catch (FileNotFoundException ex) {
                                ex.printStackTrace();
                        } catch (IOException ex) {
                                ex.printStackTrace();
                                throw new TranscoderException(ex);
                        }
                }
                return (SVGOMDocument) document;
        }

        
}


-- 
View this message in context: 
http://www.nabble.com/a0%3Aspace%3D%22preserve%22-tp18750776p18751414.html
Sent from the Batik - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to