example of using Woodstox to parse a simple XML - xml-parsing

Can anyone give me an example of using the Woodstox parser to parser an XML file? Or point me to a place where I can look at some examples?
Thanks

The below link would be a good resource to look into to compare the whole parsing thing along with JAXB and their comparisons. The author has also mentioned about the jaxb2 maven plugin to generate xjc sources as part of your build in case you are inclined towards maven.
xml-unmarshalling-benchmark

Related

Building Rascal from source

I'm thinking it might be easiest if I modify the Java syntax used in Rascal to better fit our Java-like language.
Is there a way I can build Rascal from the source? I've cloned the repo from Github and imported it as a project into Eclipse but there are some compilation errors regarding org.eclipse.imp. Before I head down the rabbit-hole of trying to get this all to work in Eclipse I thought I would post here to see if there is an easy way to handle this.
Thanks!
Sure you could build Rascal from scratch; following the developer instructions at https://github.com/cwi-swat/rascal/wiki/Rascal-Developers-Setup---Step-by-Step
On the other hand, if you wish to simply adapt the Java syntax definition it would be better to clone it into your own files. Grammars may look modular, but in reality there are complex interactions between different parts of the grammar. Better to clone and manage the whole thing as your own than depend on two co-evolving definitions.
If you clone the Java grammar Rascal will generate new parsers for you on-the-fly. If this generation becomes cumbersome, a "cached parser" can help you to optimize the deployment of your tools. Please contact us if you need help with that.

xText parser usage during runtime configuration

I want to use the runtime configuration for running an xText parser. In an example xText project I get the standalone and the runtime configuration for using the parser.
Please can somebody indicate the steps needed to use the parser during runtime in another Eclipse plug-in project. I have no experience with the plugin.xml file and I know I need to create there some extension points.
The xText sample project contain also an ui project which uses the obtained parser during runtime. Still I was not able to understand what things I need from that configuration an what not.
Help is highly appreciated.

Any tools for clojure to parse java source code? [duplicate]

I'm trying to analyze Java source files with Clojure but I couldn't find a way to do that.
First, I thought using Eclipse AST plugin(by copying necessary JAR's to my Clojure project) but I gave up after seeing Eclipse AST's API(visitor based walker).
Then I've tried creating a Java parser with ANTLR. I can only find one Java 1.6 grammar for ANTLR( http://openjdk.java.net/projects/compiler-grammar/antlrworks/Java.g ) and it doesn't compile with latest ANTLR(here's the errors I'm getting ).
Now I have no idea how can I do that. At worst I'll try to go with Eclipse AST.
Does anyone know a better way to parse Java files with Clojure?
Thanks.
Edit: To clarify my point:
I need to find some specific method calls in Java projects and inspect it's parameters(we have multiple definitions of the method, with different type of parameters). Right now I have a simple solution written in Java(Eclipse AST) but I want to use Clojure in this project as much as possible.
... and it doesn't compile with latest ANTLR ...
I could not reproduce that.
Using ANTLR v3.2, I got some warnings, but no errors. Using both ANTLR v3.3 and v3.4 (latest version), I have no problems generating a parser.
You didn't mention how you're (trying) to generate a lexer/parser, but here's how it works for me:
java -cp antlr-3.4.jar org.antlr.Tool Java.g
EDIT 1
Here's my output when running the commands:
ls
wget http://www.antlr.org/download/antlr-3.4-complete.jar
wget http://openjdk.java.net/projects/compiler-grammar/antlrworks/Java.g
java -cp antlr-3.4-complete.jar org.antlr.Tool Java.g
ls
As you can see, the .java files of the lexer and parser are properly created.
EDIT 2
Instead of generating a parser yourself (from a grammar), you could use an existing parser like this one (Java 1.5 only AFAIK) and call it from your Clojure code.
It depends a bit on what you want to do - what are you hoping to get from the analysis?
If you want to actually compile Java or at least build an AST, then you probably need to go the ANTLR or Eclipse AST route. Java isn't that bad of a language to parse, but you still probably don't want to be reinventing too many wheels..... so you might as well build on the Eclipse and OpenJDK work.
If however you are just interesting in parsing the basic syntax and analysing certain features, it might be easier to use a simpler general purpose parser combinator library. Options to explore:
fnparse (Clojure, not sure how well maintained)
jparsec (Java, but can probably be used quite easily from Clojure)

Java library for comparing WSDL elements syntactically

I have WSDL files and would like to compare and match WSDL elements in these files syntactically. Do you have any suggestions for Java libraries that can be used finding syntactical similarities between two terms in Web (for me, wsdl elements)?
Thanks.
There's also WSDL Analyzer which builds upon the most recent version of the Membrane SOA Model. It's a web application which not only allows you to validate and check your
WSDL against best practices but also lets you compare different versions of your WSDL.
Disclaimer: I'm one of it's developers.
Well, you can use SOAPUI to load the wsdl definitions and compare them.
Including link with some documentation relating to your question. Hope is of some help.
http://www.soapui.org/SOAP-and-WSDL/working-with-wsdls.html
edit:
Also, check out http://www.membrane-soa.org, which as some libraries for comparing wsdl files.
Some specific examples are here: http://www.membrane-soa.org/compare-wsdl-java-api.htm

Is it possible to use ant's antlr task to do code generation with stringtemplate?

Is it possible to use ant's antlr task to do code generation with the stringtemplate library?
If not, is it better to just execute a java class from command line to code gen w/ stringtemplate?
I've found this link which is close to what I want, but I am having a hard time setting this up properly. That library is not able to see antlr for some reason. link text
It depends of the complexity of the code that you want to generate. In case of our company, we extended org.apache.tools.ant.Task with the generation logic for java code. After that, both ant task and template files were packaged in a jar file.

Resources