You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by BEGUE Pierre <pb...@iftechnologies.net> on 2005/07/20 12:18:51 UTC

set attribut

hi Thomas,

i do a copy svg to svg with the svgTranscoder and into the copy i want 
to change the attribut by svgRoot.setAttribut(). But he don't change the 
attribut

this my code :

//declaration variable
    String Entree = "batik3D.svg";
    String Sortie = "SortieFlux.svg";
    //String rep = "c:/pierrestage/WebApplication3/build/web/Lege/";
    String rep = "c:/batik/batik/samples/";


    //Creation d un SVG transcoder
    SVGTranscoder t = new SVGTranscoder();

    // Creation d un transcoder input
    //String svgURI = new File(rep+Entree).toURL().toString();
    FileInputStream instream = new FileInputStream(rep+Entree);
    InputStreamReader istream  = new InputStreamReader(instream);
    TranscoderInput input = new TranscoderInput(istream);

    // Creation d un transcoder output
    /*OutputStream ostream */
    FileOutputStream outstream = new FileOutputStream(rep+Sortie);
    OutputStreamWriter ostream = new OutputStreamWriter(outstream);
    TranscoderOutput output = new TranscoderOutput(ostream);

    // Sauvegarde de l image
    t.transcode(input,output);


    String svgURI = new File(rep+Sortie).toURL().toString();


    //methode de recuperation du document
    String parser = XMLResourceDescriptor.getXMLParserClassName();
    SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
    Document doc = f.createDocument(svgURI);

    //recuepere l element root de mon document svg
    Element svgRoot = doc.getDocumentElement();

    //je lui affecte les attributs
    //String viewBoxAtt = (String) request.getParameter("viewBox");

    /* ++++ UTILISATION SEULE D ECRITURE AVEC DOCUMENT ++++*/
    String moi = svgRoot.getAttributeNS(null,"width");
    out.println("width = "+moi);
    svgRoot.setAttribute("width","350");
    svgRoot.setAttributeNS(null, "height","400");
    //svgRoot.setAttributeNS(SVGURI, "viewBox",viewBoxAtt);


or if i use domutilities.writedocument() i can change the attribut but 
he don't write completely my svg (don't write </svg> and some other code)


why , can you explain me, thanks



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: set attribut

Posted by Thomas DeWeese <Th...@Kodak.com>.
Hi Begue,

BEGUE Pierre wrote:

> or if i use domutilities.writedocument() i can change the attribut but 
> he don't write completely my svg (don't write </svg> and some other code)
> 
> why , can you explain me, thanks

    You probably need to flush the output stream/Writers that you pass
to the writeDocument call.

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org