GML to SVG transformation
Zahra_T
Posted messages
89
Registration date
Status
Membre
Last intervention
-
Zahra_T Posted messages 89 Registration date Status Membre Last intervention -
Zahra_T Posted messages 89 Registration date Status Membre Last intervention -
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.
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 réponses
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);
}
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);
}
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.
Arf no, it's fine I just found out but I have no idea what it is :)
--
The wolf, solitary and mysterious.
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.
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.
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;-)