Home
Analytics
String Conconcatenation - Hitting Character Limit Issue
richardc
Hi,
I am using the BIRT CONCATENATE function for an aggregation element which is inside a group footer in my report layout.
I would like to concatenate several large pieces of text (over 1000 characters each) but there seems to be a limit on the number of characters that can be concatenated.
The total number of characters in the concatenated string seems to be limited to just over 1000 chars - anything over is ignored and no error messages are displayed.
I am using an XML dataset to read an XML datasource file.
Results from my tests (Birt version 2.3.2.2):
Test 1 - concatenate two strings - String 1 with 490 chars and String 2 with 495 chars.
Result: correctly concatenates - (concatenated string has total of 985 chars)
Test 2 - concatenate two strings - String 1 with 615 chars and String 2 with 605 chars.
Result: only shows String 1 as the concatenated result (totally ignores String 2 and no error message is displayed. - (resulting string has total of only 615 chars)
Test 3 - concatenate ten strings - each with less than 120 chars
Result: only concatenates the first 8 Strings (totally ignores the last two Strings) - (resulting string has total of only 947 chars)
Some questions:
1) Is there a StringBuffer being used in the concatenation - if yes, why is there a limitation on the concatenated result?
2) Is there a way that I can code my own concatenation without using the BIRT CONCATENATE function? I would need a way to determine when to start and stop the concatenation whilst inside a group - can you please advise on how to do this? i.e. if I use script in the onFetch method for the XML dataset, is there a way that I can determine when I'm in the first row of the group and when I'm in the last row of the group?
Find more posts tagged with
Comments
mwilliams
Hi richardc,
If you've got the dataSet bound to a table, you can probably create a variable in your report's initialize script method and add each row to the variable in the onCreate method of the detail row in your table. Then display the variable in a dynamic text box in your group footer. You can reset the variable to an empty string in the onCreate of the group header of the table so it starts fresh as a new group starts.
richardc
Great! Thanks Michael.
All worked fine with a java StringBuffer - details below:
onPrepare method for table:
importPackage(Packages.java.lang);
textStrBuff = new StringBuffer();
onCreate method for table group header:
importPackage(Packages.java.lang);
// clear the StringBuffer
textStrBuff.setLength(0);
onCreate method for table detail:
importPackage(Packages.java.lang);
textStrBuff.append(row["Note_Text"] + " ");
Then in the report layout - table group footer - dynamic text field:
textStrBuff + "";
Cheers,
Richard
mwilliams
Richard,
Always glad to help. Let us know whenever you have questions.
richardc
Hi Michael,
As mentioned above, I can do the concatenation ok now.
However, I've noticed that the dynamic text field does not show newline formatting. This seems to be a bug, so I will need to find an alternative as the output is required to be formatted.
I tried using a data field instead of a dynamic text field to display the concatenated text - this honored the newline formatting but the output seems to lag by one detail row so the resulting string is not correct for the grouping.
Can you please recommend a way to resolve this?
(I'm using Birt version 2.3.2.2)
Cheers,
Richard
mwilliams
Richard,
Can you explain what you mean by "new line" formatting? Thanks.
richardc
Hi Michael,
-- for newline formatting I mean the BIRT dynamic text field doesn't seem to recognize carriage returns - in the report output the carriage returns have been replaced with single spaces:
For example: "anb" gives the following output (using a dynamic text field):
a b
instead of
a
b
However if I log the text in the detail of the table before it reaches the dynamic text field, the log shows the text with correct formatting i.e.
a
b
So it seems that the dynamic text field does not recognize control characters. Any ideas?
Cheers,
Richard
richardc
Hi Michael,
Any thoughts on how to work around the dynamic text field formatting issue?
Cheers,
Richard
mwilliams
Richard,
Sorry for the delay. I'll have to give this a closer look. What is the reason for using a dynamic text box rather than a data element if you're saying the data slement within the table works? Why not use a data element where the dynamic text box is now?
richardc
Hi Michael,
Just getting back on this:
In version 2_3_2_2 as noted above:
1) The dynamic text field does not honor formatted text. i.e. tabs and newline formatting in original data is not displayed when using the dynamic text field - instead, the dynamic text field just displays text with any tab and newline formatting removed.
2) The data field honors tab and newline formatting, BUT it is not synchronised to work as a substitute for the dynamic text field. i.e. if I substitute the data field for the dynamic text field in the report layout, and use the same expression that I had in the dynamic text field, then then the result displayed in the report is one iteration behind. So for example if I have 5 pieces of text data that I want to concatenate, then the result only shows the first 4 pieces of data concatenated.
Is there any other way to display data in the report without using the dynamic text field or data field?
Also, have any of these issues been fixed in a later version?
Cheers,
Richard
mwilliams
Richard,
If you set up a quick example of this issue with the sample database, I'll run it in later versions to see if anything has changed.
richardc
Hi Michael,
I've attached a sample report and xml data file
(xml datasource in the report should be updated to point to the data file when testing).
If you can find a way to display the formatted data correctly it would be greatly appreciated
Cheers,
Richard
mwilliams
Richard,
Well, the same result happens in the latest version. I'll have to look into the issue a bit further and get back to you if I find anything.
richardc
Hi Michael,
Any news with this one?
Is there any way I could achieve formatting (modify source code?) with version 2_3_2_2?
Also what is the process for bug reporting - do you add forum issues to the bug list - if not can you point me to where I should log bugs?
Cheers,
Richard
mwilliams
Richard,<br />
<br />
Sorry, I have not found anything to work as of yet. Here is the link to log bugs. This is definitely something that is probably bug worthy. Be sure to include the report that you posted in here to help show the formatting issue.<br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/bug-reporting/'>Report
Bugs - BIRT Exchange</a><br />
<br />
On your question about modifying the source to get this to work, I would assume that you could, but it may be a tough chore.
richardc
I created bug: <a class='bbc_url' href='
https://bugs.eclipse.org/bugs/show_bug.cgi?id=299888'>https://bugs.eclipse.org/bugs/show_bug.cgi?id=299888</a>
; for the formatting issue
richardc
The solution for including formatting for the dynamic text field is:
Thanks to Gang Lui:
You should change the property "Content Type" to "Plain" for the dynamic
text field. By default this property is set to "html", the text value is regarded
as html text, all line-breaks and tabs are ignored.
To set the "Content Type" to "Plain" - use the Property Editor - Properties window for the dynamic text field.
All is working as required now.
mwilliams
Great! Thanks for the update!