Wednesday, July 16, 2014



Creating XML file from the General JSON




I have written a Java class with following methods to create XML from the JSON generated by the UI. Here I have used the GSON library, added it as a dependency to my project .


  • parse(s)
  • artifactDetailstoXML(artifactDetails)
  • UItoXML(ui)
  • contentTtoXML(content)
  • relationshiptoXML(relationship)
  • writeToFile(name.getAsString(),XML)


parse(s) method

Is used to create JSON model from JSON.


JsonParser jsonParser = new JsonParser();
JsonElement rxtJsonElement = jsonParser.parse(jsonContentAsString);
JsonObject rxtJsonArtifactTypeObject = rxtJsonElement.getAsJsonObject().getAsJsonObject();


Then passed the JSON file as String content(jsonContentAsString) to parse method.
JsonObject is returned from parse method and that object is used to retrieve the hierarchical information that is needed to create the xml file.


artifactDetailstoXML(artifactDetails) method


Assumption was made that all mandatory fields are filled and only checked if user has input data to namespace, namespaceAttribute and lifecycle fields.

UitoXML(ui) method


Checked if the there are more that one column data exists and if it does JsonArray was created accordingly.

Separate JsonObjects are created for artifactDetails, ui, content and relationship and passed to different methods to create XML content accordingly. Advantage in creating separate XML sections is that it gives flexibility to make changes easily in separate methods.

Then the xml contents returned from each of the methods are added together and created the whole XML content and passed to writeToFile() method to be written to a .rxt file.

JsonObjects, JsonElements, JsonArrays were used to create XML.


JSON generation from UI is halfway done. But I am in difficulty in generating JSON for dynamic UI part and now working on it.


Saturday, July 5, 2014




Update after mid review



Last week I met with WSO2 Governance registry team and I demonstrated the current progress of the Jaggery Application I have developed. We, my mentor and some experienced people in the team then discussed on the project scope and my approach so far and beyond.At the end of the session I was able to clarify my doubts on the problems I faced so far and on future tasks.


As I mentioned in my last update several issues were recorded in the existing RXT , XML model, so there were difficulties in rendering the UI (in ES) only with the information it is providing. The necessity of keeping other meta data along with the xml model was quiet apparent. To overcome this drawback , it was decided to generate a JSON along with sufficient meta data, such that UI rendering can be done without much effort. And then XML which suits the existing model is generated from that JSON to be sent to the stub.


Also I was able to clarify some doubts regarding the RXT definition whether certain data in rxt. sxd, which were apparent to be unused should be considered in the design or not. i. e date,calendar, href,menu,column. Discussions further went on regarding the capability of implementing nested rest support where user can associate rxt to each other on the fly. So that rxt s can be associated automatically.

Ability to add multiple tables and multiple lists in content, delete preferred rows in Relationship and UI sections are discussed in the meeting too. As enhancements it was discussed to consider the ability to populate a browse button to find relationship source /target.

These days I am working on creating JSON from the UI and retrieving the XML from that to be sent to the server side. I am writing a Java class to create XML from JSON, and JSON will be generated from UI in JavaScript.

Herewith I have drawn the updated overall architecture.