GML to SVG transformation

Hello
I am programming in Java a button that allows opening a JFileChooser to open a GML file.
My problem is how I can convert this GML file into a SVG file so that I can display it using the Batik library.
Could you please help me, that would be very kind
Thank you in advance.
Configuration: Windows XP Internet Explorer 6.0

4 answers

  • Votes
  • Date
  • Descending date
  1. Visit here:

    http://www.lsis.org/~colonnafm/oldies.php

    ;-)
    HackTrack
    1. Thank you for your help.
    2. Thank you again, but that's not what I'm looking for.
      In fact, I can't integrate or study it to be able to program.
      What I'm looking for is whether I can manipulate the Transformer class from javax.xml.transform.
      I tried, but nothing is displaying in the JSVGCanvas;-)
  2. Can I use the transformer class?

    If yes, I tried these few lines in my application and nothing displayed knowing that I need to show the SVG result in a JSVGCanvas for it to be interactive:

    DocumentBuilderFactory factoryD = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factoryD.newDocumentBuilder();
    File fileGml = new File(s);
    //s is the path I get when I choose my GML file via a JFileChooser
    Document document = builder.parse(fileGml);
    Source source = new DOMSource(document);

    File fileSVG= new File("SVG.svg");
    Result result = new StreamResult(fileSVG);

    // Transformer configuration
    TransformerFactory factoryT = TransformerFactory.newInstance();
    StreamSource stylesource = new StreamSource("file.xsd");
    Transformer transformer = factoryT.newTransformer(stylesource);
    transformer.setOutputProperty(OutputKeys.METHOD, "SVG");

    // Transformation
    transformer.transform(source, result);
    }
    1. Contributor
      What is Bib Batik? Is it for making backups?

      Arf no, it's fine I just found out but I have no idea what it is :)
      --
      The wolf, solitary and mysterious.
      1. The Batik package allows for the manipulation of vector images presented in SVG format, such as zooming in and out, rotating, translating, etc.
        You can visit the official Batik website:
        http://xml.apache.org/batik/architecture.html
    2. I have the same problem converting a GML file to SVG
      I tried everything but there's nothing
      SOS.
      1. Hello Jojo
        it's been a while for this problem, and I haven't found a solution
        what I can tell you is that gml and svg are two versions of xml, for the transformation try to head towards xslt, I believe that's the only direction that can solve the whole issue but I'm not exactly sure how.
        Good luck and don't forget to publish the solution if you find it, I and others would find it useful.