fionn_colvin Posted January 17, 2011 Share Posted January 17, 2011 Hello all,I'm very new to Jasper Reports and trying to get my head around this great looking tool. I am trying to build a report with XML datasources as thats what our company can easily create. Outlined below is an example XML file and then the type of report I'm trying to create. <?xml version="1.0" encoding="utf-8"?> <teams count="5"> <squad name="s_aaa" field1="111" field2="222" field3="333"> <person name="p_abc" field1="22" field2="24" field3="13" /> <person name="p_def" field1="22" field2="24" field3="13" /> <person name="p_ghi" field1="22" field2="24" field3="13" /> <person name="p_jkl" field1="22" field2="24" field3="13" /> <person name="p_mno" field1="22" field2="24" field3="13" /> <person name="p_xyz" field1="22" field2="24" field3="13" /> </squad> <squad name="s_bbb" field1="111" field2="222" field3="333"> <person name="abc" field1="22" field2="24" field3="13" /> <person name="abc" field1="22" field2="24" field3="13" /> <person name="abc" field1="22" field2="24" field3="13" /> <person name="abc" field1="22" field2="24" field3="13" /> <person name="abc" field1="22" field2="24" field3="13" /> <person name="abc" field1="22" field2="24" field3="13" /> </squad> <squad name="s_ccc" field1="111" field2="222" field3="333"> <person name="abc" field1="22" field2="24" field3="13" /> <person name="abc" field1="22" field2="24" field3="13" /> <person name="abc" field1="22" field2="24" field3="13" /> <person name="abc" field1="22" field2="24" field3="13" /> <person name="abc" field1="22" field2="24" field3="13" /> <person name="abc" field1="22" field2="24" field3="13" /> </squad> <squad name="s_ddd" field1="111" field2="222" field3="333"> <person name="abc" field1="22" field2="24" field3="13" /> <person name="abc" field1="22" field2="24" field3="13" /> <person name="abc" field1="22" field2="24" field3="13" /> <person name="abc" field1="22" field2="24" field3="13" /> <person name="abc" field1="22" field2="24" field3="13" /> <person name="abc" field1="22" field2="24" field3="13" /> </squad> <squad name="s_eee" field1="111" field2="222" field3="333"> <person name="abc" field1="22" field2="24" field3="13" /> <person name="abc" field1="22" field2="24" field3="13" /> <person name="abc" field1="22" field2="24" field3="13" /> <person name="abc" field1="22" field2="24" field3="13" /> <person name="abc" field1="22" field2="24" field3="13" /> <person name="xyz" field1="22" field2="24" field3="13" /> </squad> </teams> FIELD 1 FIELD 2 FIELD 3 P_ABC 22 24 13 ... ... ... ... P_XYZ 22 24 13 S_AAA 111 222 333 ... ... ... ... S_EEE 111 222 333 So for the squads I'd use an xpath of /teams/squadFor players it would be /teams/squad/person Can I use a table element to render this?How do I get the report to break on each new squad and display that data before going onto the the next person record? Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
walmillard Posted January 24, 2011 Share Posted January 24, 2011 Your output table is unclear.However if you Group the elements you want to print it should be quite ezy to print the attributes of each person in squad order.You could set your xml datasource to /teams/squad/personThen have Squad "name" with a description of ../@nameand have person "name with a description of /@name and the other attributes "field1" "field" and "field" are defined similarly.Set the Group Expression to the name field of the respective element. If you want to print all the duplicated data in the example then it may be a bit more tricky W Link to comment Share on other sites More sharing options...
fionn_colvin Posted January 24, 2011 Author Share Posted January 24, 2011 Thanks so much. I've got it all working. Much appreciated. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now