gpenn Posted September 21, 2009 Share Posted September 21, 2009 I am a complete newbie to database reporting in general and iReport in particular. I'm working as a volunteer at a local community college where I've volunteered to help get the new database for the herbarium collection up and running. I know, but no one else has stepped up. We're using a version of iReport 3.0.0 modified for use with Specify (specifysoftware.org).The report I'm working on creates labels for specimens in our collection. Some records cause the report to print the formating tags '<style isItalic='TRUE'>' and '</style>' in the styled text field I use for the scientific name of the specimen. Not surprisingly, the text values of the fields prints without style between the style tags. Try as I might, I can't figure out why some records do this while most do not.The full text of the expression follows: ($F{Genus}!=null ? "<style isItalic='TRUE'>" + $F{Genus} + "</style>" : "") + " " + ($F{Species}!=null ? "<style isItalic='TRUE'>" + $F{Species} + "</style>" : "") +($F{subspecies}!=null ? " subsp. " + "<style isItalic='TRUE'>" + $F{subspecies} + "</style>" : "") + ($F{variety}!=null ? " var. " + "<style isItalic='TRUE'>" + $F{variety} + "</style>" : "") + ($F{Author}!=null ? " " + $F{Author} : "") I don't know how to include in this post examples of records that do and don't print correctly, but I can do so if anyone feels like telling me how. Any ideas from just looking at the expression?Thanks,Gregory p.s. All other expressions in the label work fine on all records, but none of them use styled text. Post Edited by gpenn at 09/22/2009 20:21 Link to comment Share on other sites More sharing options...
mdahlman Posted September 22, 2009 Share Posted September 22, 2009 Gregory, Someone else posted recently that they had this type of problem. In that case it seemed that it was due to "&" (ampersand) appearing in the data. Is it the same issue for you? You could always include a screenshot of the problem. That might be easiest way to show it. Regards,Matt Link to comment Share on other sites More sharing options...
gpenn Posted September 22, 2009 Author Share Posted September 22, 2009 Yes! I hadn't noticed, but that's the commonality. The ampersand in the data appears to determine which records will print with the style tags. I'll try to find the thread you mentioned and hope it mentions a work-around. Thank you! This has been plaguing me for weeks. Link to comment Share on other sites More sharing options...
gpenn Posted September 22, 2009 Author Share Posted September 22, 2009 I found a few posts regarding this issue, but no effective work-around. A find and replace operation on the data might do the trick, but I have a couple problems with that approach. First, I have no idea how to do it. Second, the use of ampersand characters in citing the authors of biological species is an established convention with which I need to be consistent.I can imagine two approaches that might work. One would be replacing all the ampersands in my data with some string that will print as an ampersand but not cause the same problem, like ASCII or something. Of course, the ASCII code for ampersand starts with an ampersand and iReport might not appreciate the somewhat recursive humor of that. Also, it'd be a real nuicance if the string didn't always appears as a simple ampersand in the database front end.The second approach would just be a work-around that'd suffice for my specific application. I don't need the data from the ampersand-containing text field to be styled, so I could put that data in a separate field. The problem with this approach is that I'd like to maintain consistent word spacing in the report, which I'd have no idea how to do between adjacent text-fields where the field on the left contains strings of varying length.Gregory Link to comment Share on other sites More sharing options...
gpenn Posted September 22, 2009 Author Share Posted September 22, 2009 Does anyone know whether this issue effects more recent versions of iReport. I'm using v3.0.0 and probably can't upgrade anytime soon for reasons I'd be happy to discuss but won't bore you with unless you ask. Link to comment Share on other sites More sharing options...
mdahlman Posted September 22, 2009 Share Posted September 22, 2009 Gregory, I cannot reproduce the problem in iReport 3.6. I don't know if it was a bug in v3.0 that got fixed... but this implies maybe that's what happened. Try making a report with a trivally simple query like this one. See if you can get the error reproduced in a minimally complicated .jrxml. From that maybe we can see what's going wrong. select 'customer 1' as cust_nameunionselect 'customer & 2' as cust_name Regards,Matt Link to comment Share on other sites More sharing options...
gpenn Posted September 22, 2009 Author Share Posted September 22, 2009 Matt,I'm sorry to say that I don't understand how to follow your suggestion. I just picked up a book on learning MySQL last week and I've only just made it through the installation and configuration on my personal computer. The database with which I'm having this problem uses a GUI client, which includes its own query builder. I haven't seen what it produces in the way of SQL. That said, I have determined that the ampersand is the issue. I took the ampersand-containing field out of my styled text field and put it in an adjacent non-styled field. That arrangement prints all records I've checked correctly, though the formatting is problematic. Does that answer what you were hoping to find with your instructions?I'm going to look into what would be invloved in upgrading to v3.6, but it's likely to be more than I can do with my limited experience. I know that the Specify Software Project modified iReport somehow to work with their database. I may be able to find out what those modifications are, but since I'm not a programer it's probably beyond me to implement them for the new version. Thanks,Gregory Link to comment Share on other sites More sharing options...
svenn Posted September 22, 2009 Share Posted September 22, 2009 The way to fix this is to replace the "&" with "&". The style tags will then be able to process your data correctly. Now what is the best way to do it well that another question. We run our reports off of temporary reporting tables so we do a search and replace on all our strings before we load up the tables. Link to comment Share on other sites More sharing options...
gpenn Posted September 23, 2009 Author Share Posted September 23, 2009 Thanks. I thought it might take something like that. Looks like I'll need to keep plowing through 'Learning MySQL' until I've figured out how to do find and replace operations. Thanks for your help, both of you. Link to comment Share on other sites More sharing options...
svenn Posted September 23, 2009 Share Posted September 23, 2009 If there are muliple "&" in the string it may be difficult to do the replace as part of your "Select" command. You may have to call a stored function or procedure from your select statement. Link to comment Share on other sites More sharing options...
mdahlman Posted September 24, 2009 Share Posted September 24, 2009 Gregory, svenn is correct: you can fix the string in the select statement. But I think it will be more practical to fix the string in the report. I posted an example of doing that to the recent similar thread here: http://jasperforge.org/plugins/espforum/view.php?group_id=83&forumid=101&topicid=64104 Regards,Matt Link to comment Share on other sites More sharing options...
gpenn Posted September 25, 2009 Author Share Posted September 25, 2009 Matt, Thanks for the tip. I'm out of town for a few days, but I'll try it out as soon as I get back. I would far prefer to change the string in the report rather than in the database. I have a question about how that works, which I'll post it to the thread you referenced for the sake of continuity there. Thanks, Gregory 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