Jump to content
Changes to the Jaspersoft community edition download ×
  • Cannot use the && logical operator in report expressions


    djohnson53
    • Version: v5.1, v5.0, v4.8, v4.7, v4.6, v4.5 Product: JasperReports® Library

    If you want to create some complex report expressions in which you have to use the Java AND logical operator, you might be surprised to see an error when compiling you report design. The error message would say something like this:

    "The entity name must immediately follow the '&' in the entity reference." Don't worry! This is because the '&' character is a special XML character and the XML parser is confused when it encounters such characters in the body of an XML element.

    The solution is to use the XML special syntax that allows you to introduce XML special characters in the body of an XML element. Put your expression content between the 

    <![CDATA[

       and   

    ]]>

       character sequences like in the following demo text field expression:

    <textFieldExpression>
        <![CDATA[
            $F{MyNumber}.intValue()>=0 && $F{MyNumber}.intValue()<=25 ? "in range" : "out of range"
        ]]>
    </textFieldExpression>


    References:

     


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...