Is there any java API available for reading and writing Graph Modeling Language (GML) files.
In fact, I am looking for any popular graph file format --that is supported by some handy graph editor and visualizer (with good layout management) tools-- and a convenient java API that is provided to reading and writing graphs in this popular format.
My intention is to generate graphs in my application, save it in this standard format, then feed it to the graph editor I mentioned above in order to further manipulate it, and save it again in the same format (that would be naturally readable again in my application).
Among the graph editors, I found yEd a handy one which supports GML (Graph Modeling Language) format as well. In the GML website, it seems there exist a C language API. So I am looking to see if there is any API in java (scala) that I can read and write this format conveniently.
Try graphstream. API can be found at: http://graphstream-project.org/api/gs-core/
Related
I have created an Ecore metamodel and generated an editor through EMF. To generate my output code I parse the resource set (XMI) when a diagram is created and then map these resources to my own Java classes. These Java classes are responsible for generating my output which is some javascript files based on few template files (.stg).
Everything works fine but my question is where do technologies such as Xtend/Acceleo come in? Do I need any of them? I know that they are template based but since I have my own templates that are rendered through my Java classes why would I need to use Xtend for example? I am totally confused.
Thank you so much
Xtend is a general purpose language. You could call it a "better Java". This is especially true for templating, because Xtend has nice template expressions. So if you want your generator code to be more readable, you could replace some Java classes with Xtend classes. You don't need to rewrite everything, Xtend interoperates seamlessly with Java. Just rewrite the parts that benefit most from Xtend's rich language features.
You are using the eclipse Enterprise Modelling Framework (EMF). This provides you with the ECore meta modell and can generate basic dialog based editors. Basically EMF brings your diagrams from the XMI file format to a standardized object model, similar to a DOM.
Probably you also use the Graphical Editor Framework (GEF) to visualize your diagrams. It takes your DOM and renders it to a graphical representation. Usually you can also modify the graphics using graphical user interface, which will then also change the contents of your DOM.
Parallel to the GEF there also exists a textual editor framework called xText. It brings your DOM to a textual representation. You can then use a text editor to change the textual representation. xText can parse this changed text and change the DOM accordingly. Additionally it generates a nice Eclipse editor with syntax high lightning, code folding, code completion and possibilities for extensions for custom code completion and refactoring.
xText can be augmented by XBase. XBase is a basic programming language that runs on the Java VM. You can then provide a mapping from your ECore artefacts to XBase concepts (e.g. which ECore object represents an if statement or a loop). XBase can then generate Java bytecode and hence convert your ECore model to runnable code.
XTend is a general purpose language. It is often used as a very advanced template engine to to convert your ECore model to text. In contrast to xText there is no way back to convert the generated text back to the ECore DOM. Of course you can use any template engine or even xText/xbase to generate your runnable code according to your needs.
Could any one please recommend a tutorial or tell me how can I build a java program for extracting information from xml files and produce the out put as RDF triples using an existing ontology. an example would be really helpful.
Thanks
There are ready-made tools that address this problem, such as XSPARQL. You can write an XSPARQL query that queries the XML and produces RDF triples as output. This example should be pretty close to what you're looking for.
Your problem is really two problems:
parsing XML
writing RDF
For Java XML parsing, there are numerous examples on the web:
Java and XML - Tutorial
Java Examples in a Nutshell, Chapter 19, XML
Working with XML: The Java/XML Tutorial
For RDF there are fewer resources, it's a much more specialized field:
What are some good Java RDF libraries?
In the past I worked with Jena – it offers a friendly API to the semantic web stack.
I would recommend the XmlToRdf Java library.
XmlToRdf offers incredibly fast conversion by using the built in Java SAX parser to stream convert your XML file to RDF. A vast selection of configurations (with sane defaults) makes it simple to adjust the conversion for your needs, including element renaming and advanced IRI generation with composite identifiers.
Output from the conversion can be written directly to file as RDF Turtle or added to a Sesame Repository or Jena Dataset for further processing. With Sesame and Jena it is possible to do further, SPARQL based, transformations on the data and outputting to formats such as RDF Turtle and JSON-LD.
I am software written in Java which read an external XML file (let's call it "datasource.xml").
This file contains different information and this information are extracted using XPath queries.
The fact is that, according to what kind of information is extracted from that file (datasource.xml) a different work flow is needed. At the moment workflows are "hard coded" in my Java classes but I want to make my software indipedent so that it can work with any datasource.xml, no matter of its structure. But of course I have to specify somewhere how to deal with the extracted data. I was thinking to use (again) JAXB and specify inside the XML file (and from its XSD I will create JAXB classes) the kind of workflow is needed.
Could it be a good solution??
Thanks
have you checked out Drools (a project from JBoss) very easy to learn & is an excellent workflow tool.
building your own workflow engine is quite complex & there are a lot of considerations to be taken into account.
You can think of using activiti, Another workflow solution. It has APIs available and can be used as a workflow service layer in your application.
Like others, I think you will be better off using a higher-level tool for this rather than hand-coding the logic in Java. Take a look at XProc (for example the Calabash implementation), or Orbeon, or Cocoon. They all have a learning curve associated with them, but once mastered, you will have a much more flexible architecture than with hard-coded Java logic.
Are there any well known solutions that meet/exceed below requirements?
conversion from multiple non-graphical document formats to and from HTML (e.g. doc<->HTML, pdf<->html, odt<->html, etc.)
command line or API (Java API is preferable)
cross-platform
commercial or open source
OpenOffice has a rich API that supports conversion between the various supported formats. Check out this question. It recommends using JODConverter.
With DocBook you can export to various output formats, but reverting is always hard. For pdf you can try iText
I (having written an all in one Tex/LaTeX -> HTML and ASCII text and RTF convertor),
would say this would be quite an undertaking.
The problem with this, is these various 'document' formats are intended for rather different purposes.
And while there are indeed such conversion tools between some of these formats,
there is often a conceptual disparity in the structure, meaning and implementation of 'document'
and it is very often is necessary to trade off on features supported by one format to hack together
an acceptable output in another.
For example, PDF is very strong in presentation, precise positioning and support for fonts, where
as HTML is more concerned about structure with practically no considuration for these things
(without CSS).
I am curious how do you envision such an API being used,
when usually someone simply wants a conversion program?
Is there any clear documentation on the binary formats used to serialize the various MFC data structures? I've been able to view some of my own classes in a hex editor and use Java's ByteBuffer class to read them in (with automatic endianness conversions, etc).
However, I am currently running into issues while trying to bring over the CObArray data, as there seems to be a rather large header that is opaque to me, and it is unclear how it is persisting object type information.
Is there a set of online documentation that would be helpful for this? Or some sample Java code from someone that has dealt with this in the past?
Since MFC ships with source code I would create a test MFC application that serializes a CObArray and step through the serialization code. This should give you all the information you need.
I agree with jmatthias: use the MFC source code.
There's also this page on MSDN that may be useful.