• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Java code to genarate xml ,for uncontinuous data....

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I am geting data from database as

Year Month Series name Values
2008 7 CARDIAC 100
2008 7 DU- IT 100
2008 7 MULTIVENDOR 100
2008 8 CARDIAC 100
2008 8 DU- IT 67
2008 8 P-TECH 100
2008 9 CARDIAC 100
2008 9 DU- IT 67
2008 9 NETWORKING 0
2008 9 P-TECH 100
2008 10 CARDIAC 100
2008 10 DU- IT 100
2008 10 MULTIVENDOR 100
2008 10 NETWORKING 50
2008 10 P-TECH 100
2008 11 CARDIAC 100
2008 11 DU- IT 100
2008 11 MULTIVENDOR 100
2008 12 CARDIAC 67
2008 12 DU- IT 100
2008 12 MULTIVENDOR 50
2008 12 P-TECH 100
2009 3 CARDIAC 100
2009 3 DU- IT 100
2009 3 MULTIVENDOR 100
2009 3 NETWORKING -100
2009 3 P-TECH 100
2009 6 CARDIAC 50
2009 6 DU- IT 100
2009 6 MULTIVENDOR 100

now i have to generate xml,for preparing fusion cahrt.because fusion chart accepts data in xml format.

I am getting xml file like this.

<chart connectNullData='1' labelDisplay='Rotate' slantLabels='1' baseFont='Ge Inspira' useRoundEdges='1' legendPosition='RIGHT' imageSave='1' link='javaScript:onClick()' yAxisName='Values' legendBorderAlpha='0' shownames='1' showvalues='0' ><categories><category label='Jul-2008'/><category label='Aug-2008'/><category label='Sep-2008'/><category label='Oct-2008'/><category label='Nov-2008'/><category label='Dec-2008'/><category label='Mar-2009'/><category label='Jun-2009'/></categories><dataset seriesName='P-TECH'><set value='0.0'/><set value='100.0'/><set value='100.0'/></dataset><dataset seriesName='CARDIAC'><set value='100.0'/><set value='0.0'/><set value='75.0'/><set value='0.0'/><set value='100.0'/><set value='100.0'/><set value='33.0'/></dataset><dataset seriesName='MULTIVENDOR'><set value='0.0'/><set value='0.0'/><set value='100.0'/><set value='75.0'/><set value='100.0'/><set value='50.0'/></dataset><dataset seriesName='NETWORKING'><set value='0.0'/><set value='100.0'/><set value='100.0'/></dataset><dataset seriesName='DU- IT'><set value='100.0'/><set value='100.0'/><set value='100.0'/><set value='75.0'/><set value='100.0'/><set value='100.0'/><set value='50.0'/><set value='100.0'/></dataset></chart>I am trying to plot msline chart using msline.swf file in jsp.

but my problem is

i have several months as categorie labels.

in database for dataset p-tech,i have values according to month dec-2008,mar-2009,apr-2009.

but it is ploating on jul-2008,aug-2008,sep-2008 respectivley.

The reason is.....

Just to reiterate, i am passing category labels as follows:

<category label='Jul-2008'/>
<category label='Aug-2008'/>
<category label='Sep-2008'/>
<category label='Oct-2008'/>
<category label='Nov-2008'/>
<category label='Dec-2008'/>
<category label='Mar-2009'/>
<category label='Jun-2009'/>

Now, for example, when i am passing the data values for the series "P-Tech", i m passing the set values, which, i assume are to correspond to the categories of Dec, Mar and Jun, is as follows:

<set value='0.0'/>
<set value='100.0'/>
<set value='100.0'/>

Here, what is happening is that the <set> elements given as input are three in number and thereby they are corresponding to the first three categories in the category list which are that of Jul, Aug and Sep.

Here, we need to pass empty <set> elements so that the values, say in the "P-Tech" series, refer/correspond to the correct category label.

Foe example:

<chart ....... >
<categories>
<category label='Jul-2008'/>
<category label='Aug-2008'/>
<category label='Sep-2008'/>
<category label='Oct-2008'/>
<category label='Nov-2008'/>
<category label='Dec-2008'/>
<category label='Mar-2009'/>
<category label='Jun-2009'/>
</categories>
<dataset seriesName='P-TECH'>
<set />
<set />
<set />
<set />
<set />
<set value='0.0'/>
<set value='100.0'/>
<set value='100.0'/>
</dataset>
..
..
..
<chart/>

How to create empty set tags at coresponding positions.
I have each column values in one bean with database order.

Let me know any suggestions to do this.

Thanks,
Anila....


 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Honey gonugunta. Welcome to javaranch. Your question was difficult to follow. Please post XML / code in code tags. They will be easier to understand

So what you are asking is - 'How do I generate empty elements in a XML ?'. There are ways to do it based on the API that you use. Which one are you using to generate the XML ?
 
anila honey
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Deepak,

Thanks for your reply.
Here i am not generating xml by using any parsers,apis.
I am just forming the data as xml nodes which has to pass to fussion charts.

From database i was getting data like this,which has below.




I am trying to plot msline chart using msline.swf file in jsp.
I am storing each column in one bean whch are coming from database.
After tat i m using prepareList(vB_CL_Cust_NPS.getYr4_data(),nps_mn1,vB_CL_Cust_NPS.getSegment4_data(),vB_CL_Cust_NPS.getNps4_data()) whch accepts 4 columns as beans from dtabase.

prepareList() cretas one list object with data whch are passed to that method.
After that i am using readData(List list),whch accepts above list as parameter.



By iterating mapOfCategory, i am getting category lables.
and mapOfDataSet generates dataset with corresponding set values.

The above hashmaps passed to below methods to get categories and datasets wth set values.




I am calling all these methods from jsp as fallows ....



At last i have final xml string(strXML1) like this ...




tats wat i am doing to get xml file.
i hope now you understood my problem.

Thanks,
Anila....



 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im not sure I understand your problem but-

If I wanted to have an array of objects where the number of objects is required but not all would have data, I would.

1. Create array of the required size with empty objects
2. while reading the input data, set values into the appropriate objects (you will have to program setter methods)
3. rejoice, you are done

Bill

 
anila honey
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks for your reply.
here length was dynamic.
According to xml file,I have to create category lables with month and year combination.
After tat i need to create dataset on segment name(db column name),set tags with appropriate values.

But data is in permitation and combination,year month will repeat for individual segment.
One more is while ploating graph postion also problem.

For example 2009-july,CARDIAC doen nt have the value,then i have to create one empty set elemnet in tat postion.

Do not consider my earlier posted code.
Please sea the data coming from database,xml structure.

Due to tat suggest me wat could be the best way to do this.......

 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

then i have to create one empty set elemnet in tat postion.



Isnt that what I just said? Start with empty objects for all positions and fill them as you parse the data.

Bill
 
anila honey
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks to reply.
Any sample code to do?
 
no wonder he is so sad, he hasn't seen this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic