Book a Demo

Author Topic: RTF: How to omit a title when section empty  (Read 8984 times)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
RTF: How to omit a title when section empty
« on: December 11, 2015, 02:07:13 am »
I'm struggling a bit with the RTF editor.
I have a section that shows the constraints on an element:
Code: [Select]
element >
[b]Attribute Restrictions[/b]
constraint >
- {ElemConstraint.Name}
{ElemConstraint.Notes}
< constraint
< element
I would like to omit the titile Attribute Restrictions if there are no constraints defined, but I seem to have a hard time finding a solution.

I know about the bookmarks like ElemConstraint.Name.Start and ElemConstraint.Name.End, but those work only on the individual constraint level. I'm looking for the equivalent for all contraints.

Is there a bookmark or something else I can use for this?

Geert

PS. Possible workarounds are:
- Create a custom fragment, add a table with a table header and you can add a title just above the table. Works fine if you need tables, but not if you don't.
- Create a model document only for this part, and omit it if you don't have constraint. That could work, but it would kind of blow up the number of model documents in this case.

OpenIT Solutions

  • EA User
  • **
  • Posts: 555
  • Karma: +9/-1
    • View Profile
Re: RTF: How to omit a title when section empty
« Reply #1 on: December 11, 2015, 02:56:40 am »
Hi Geert,

The only way i have found to do this is via a fragment. If the SQL returns nothing the fragment is not included....

Regards,

Jon.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: RTF: How to omit a title when section empty
« Reply #2 on: December 11, 2015, 08:48:24 am »
You can do it by inserting bookmarks around the header you don't want.

Unfortunately, it's currently documented somewhere I would have never looked when writing a template. I'll get that portion moved into the template authoring section.

http://www.sparxsystems.com/enterprise_architect_user_guide/12.1/building_models/hyperlinks_and_bookmarks.html

Anyway, it should look something like this (Where red denotes the bookmark with the label inside the {}):

[highlight]element >
constraint >[/highlight]
{Pkg_Element_Att_FeatConstraint_TITLE_Begin}Attribute Restrictions
{Pkg_Element_Att_FeatConstraint_TITLE_End}- {ElemConstraint.Name}
{ElemConstraint.Notes}
[highlight]< constraint
< element[/highlight]

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: RTF: How to omit a title when section empty
« Reply #3 on: December 11, 2015, 02:49:43 pm »
Thanks Simon I'll try that when I get in the office.

I actually did find that part of the manual (you see I DO read the manual sometimes ;)) but I couldn't have guessed that the result of adding these bookmarks would have been that my title would be omitted if the section was empty.

Quote
All Begin and End bookmarks containing the string _TITLE_ will add a line break and a value title to the field, and present the values extracted from the model as a vertical list underneath the title; for example:
     -  The bookmarks Pkg_Element_Meth_FeatTagVal_TITLE_Begin and
        Pkg_Element_Meth_FeatTagVal_TITLE_End in the Tagged Value section insert a line space and the
        heading 'Properties', underneath which is printed, in the report, the names and values of the parameter
        Tagged Values
So when you're (or Roy I guess) are at it you can maybe clarify that part a bit

Geert

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: RTF: How to omit a title when section empty
« Reply #4 on: December 11, 2015, 07:15:14 pm »
Quote
Anyway, it should look something like this (Where red denotes the bookmark with the label inside the {}):

[highlight]element >
constraint >[/highlight]
{Pkg_Element_Att_FeatConstraint_TITLE_Begin}Attribute Restrictions
{Pkg_Element_Att_FeatConstraint_TITLE_End}- {ElemConstraint.Name}
{ElemConstraint.Notes}
[highlight]< constraint
< element[/highlight]

Almost, but it got me to where I wanted to go.
What did the trick was the following:

<H3>Restrictions<H3>
{Template - LDM_Datatype_Constraints}
[highlight]constraint >[/highlight]{Pkg_Element_ElemConstraint_TITLE_Begin}
<H2>Attribute Restrictions<H2>
{Pkg_Element_Att_FeatConstraint_TITLE_End}- {ElemConstraint.Name}
{ElemConstraint.Notes}
[highlight]< constraint[/highlight]
[highlight]<element[/highlight]

Note that the heading level of Attribute Restriction has to be one level up from the expected heading level.
The result is that both titles, Restrictions and Attribute Restrictions have the same heading level <H3>

The result looks like this:


The only minor problem is the missing "-" before the second constraint, but I guess I can live with that.

Geert

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: RTF: How to omit a title when section empty
« Reply #5 on: December 14, 2015, 08:29:16 am »
Quote
The only minor problem is the missing "-" before the second constraint, but I guess I can live with that.
Looks like it's including one character too many when removing between those bookmarks.