0

I have a Sql Server database (version 2008 running databases in 2000 mode) and I want to generate some XML files using data from this db. I have XML schema for this XML.

I've though of 3 ways to do it.

  1. SQL Server select FOR EXPLICIT

    The query would be a little messy, but I am familiar with writing sql statements. The problem is that generated XML will require additional operations like changing some enum ints to strings. So it will look like:

    Sql Server-(XML)-> Java Application

    xml Creation -> Post Processing -> Schema Validation -> xml file

    The dependencies are stored in SQL Query in form like Cases!Case!titles!title!name (pretty messy) and in additional operations in java.

  2. JAXB generated classes and custom sql queries

    XML created in java in application logic I would manually write queries to retrieve data and put them in the right tag/attribute.

    The dependencies are stored in java code:

    1. in select queries (select number,... from ...)
    2. case.setNumber(rs.getInt("number"));
  3. JAXB generated classes with less queries

    So I notice that in case 2 I have the same information in 2 places, so I want to store this bindings field=column. Then I can generate select queries and copy loops using reflection.

    The way of storing:

    -hashmap<String,String> field,column

    -annotations to fields genereted from XML Schema using Annotate Plugin, then I get annotiatons for each field in class and generate query.

Maybe there is another way I have not considered yet.

I want to make it in lets say professional way to practise something new during a quite simple task.

Krystian Lieber
  • 481
  • 3
  • 9

0 Answers0