I have an XML format specified with XSD and I want to generate the corresponding Java (or Kotlin) sources including (de)serialization. I know JAXB, but as far as I understand, it heavily relies on reflection. This is no option for me, because I want the generated sources to be ready for transpilation to JavaScript (by GWT or Kotlin/JavaScript for example). Because of this, these are the requirements:
Using an XSD schema, generate the corresponding Java or Kotlin source code
Do not use reflection, but plain old Java classes which include serialize/deserialize methods
Inject an XML IO interface (like StaX) with the required methods (which I can instatiate depending on the target: JVM, JavaScript, Android, ...)
Do you know a tool for this task or do I have to create my own solution?
Related
There is a ESTree spec describing JavaScript AST format, which is used in several libraries for JS code transformations (refactoring, transpiling, minification, etc).
Are there any tools/libraries with API focused on generating the ESTree AST from scratch (not from existing JS code) and manipulate it? Preferably in TypeScript to get the advantage of static typing of ESTree nodes.
I am writing a Node.js service that uses various utilities from the Node ecosystem, but the core part of the logic needs to generate a JavaScript AST (ESTree) from some given JSON configuration. It will also include reading various JS files and combining them if required. I am designing the code generation part by defining a domain specific grammar.
The Haskell code will return a ESTree AST which Node.js will convert to JS code using some existing utility.
I am looking for a good way to call Haskell code from Node.js to achieve this.
I am very very new to Spidermonkey Parser and I have two questions. The first one is to have a good documentation (for beginners) about how to generate the AST of a Javascript file with spidermonkeyParser. And the second one is to know how to traverse the AST. My goal is to use the information in the AST to do some static analysis of the JS files (Type analysis, String analysis).
Thank you
The AST of Spidermonkey is exposed as Javascript objects. That means you should write a small Javascript script, use that script to read and parse the actual Javascript source file your want to parse and obtain the AST as Javascript objects.
This feature is available in the standalone SpiderMonkey shell (probably not in the version that comes with Firefox). You need to download the full Spidermonkey source and build it using the bundled python scripts. A Shell will be built along with your standalone Spidermonkey Javascript engine. This shell is just a small console program accepting user commands. The shell can read and execute standalone Javascript scripts. In particular, those Javascript scripts executed by this Shell have access to an extra global object called Reflect which has a method called parse(). The Shell also support extra file I/O functions which is the way you read in the target Javascript source you want to parse.
The description of the full AST is here:
https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API
I have a .net control which is intended for use as an ActiveX control in web pages, instantiated thus:
<object id="TheControl" name="TheControl" classid="clsid:012937D0-E1D8-4a80-A17F-DEADBEEFF00D"></object>
Is there a way to take the XML documentation generated by Visual Studio for TheControl and transform it into a .js file that Visual Studio could then consume to provide intellisense for an instance of the control in a page?
You would either have to use .NET Reflection to get a list of all properties and methods, or write an XML parser tool to get the same list, and then generate .JS source code from it.
I think both of these would take about the same effort to write, but the Reflection approach can also be used with just the ActiveX file- if you don't have Visual Studio handy to generate the documentation XML.
If all you want is an "empty shell" .JS file for the properties and methods, then the code in this article should provide a good basis:
http://www.codeproject.com/KB/dotnet/Reflection.aspx
I have a bit of a trouble understanding GWT's architecture. I can see two packages: com.google.gwt.dom.client and com.google.gwt.xml.client. As far as I understand, the first gives a wrapper for the HTML DOM and the second is for own DOM Documents. Is this correct?
What I need is an own Document (i.e. not the HTML Document) with Mutation Events. What would I use in this case? Is this possible in GWT or do I have to write my own DOM implementation, based on com.google.gwt.xml.client?
com.google.gwt.dom.client Javadoc :
Classes for low-level DOM programming. This package contains classes that expose the W3C standard HTML document object model for programmatic access and manipulation of HTML pages directly in client-side Java source, accounting for most browser variations. These classes provide an efficient, type-safe, and IDE-friendly alternative to writing JavaScript Native Interface (JSNI) methods for many common tasks
com.google.gwt.xml.client Javadoc :
Basic classes used in XML DOM parsing and XML document generation.
The classes in this package support parsing XML documents and creating new XML documents. The implementation uses the underlying browser.
Briefly, dom.client package is html parser (manipulation of HTML pages) and xml.client is for parsing XML documents. In your situation you can use gwt xml parser and here is good example for it xml parser in gwt