Book a Demo

Author Topic: Suppress <<stereotype>> strings in HTML export  (Read 3914 times)

lfgcasey

  • EA User
  • **
  • Posts: 33
  • Karma: +0/-0
    • View Profile
Suppress <<stereotype>> strings in HTML export
« on: May 31, 2018, 01:29:16 am »
Hello,

We have the <<stereotype>> strings suppressed/hidden in our model's Project Browser using EA 14. Unfortunately, the HTML export's corresponding navigator panel doesn't respect those options. So, in the HTML view we still see <<database>>, <<image>>, etc. which can really clutter up the panel.

I found this thread from 2010 which suggests modifying the JavaScript tocBuildItem() function in the Web Style Templates. That works...mostly.

Code: [Select]
    if (tocTab[i][2] == "")
        tocTab[i][2] = "               ";

    // ********** BEGIN Modified Code ************
    var ndx = tocTab[i][2].indexOf('«');
    if (tocTab[i][2].indexOf('«') != -1)
    {
        //XXX CRB: This will remove the <<stereotype>> strings from the Project Browser pane
        const regex = /[«]+.*[»]+/gm;
        tocTab[i][2] = tocTab[i][2].replace(regex, "");
    }
    // ********** END Modified Code ************


    nodeText = tocText.appendChild(document.createTextNode(tocTab[i][2]));

If I copy/paste this code directly into the js/displayToc.js after generating the HTML, it works as intended. However, when I add the same code to the JavaScript Web Style Template, then save the template, then re-open, all of the '«' and '»' characters get converted to '<' and '>' respectively, which makes the find/replace not work. I've tried using the corresponding &#171;, &laquo; and other Unicode strings but they don't work either e.g.  tocTab[2].indexOf('«'); returns the expected value but  tocTab[2].indexOf('&laquo;'); always returns -1.

So, two questions: First, is this even the recommended approach to suppressing the <<stereotype>> strings in the HTML output; and 2) if this approach is sane, how do I get the '«' and '»' characters to persist in the template?

Thanks!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Suppress <<stereotype>> strings in HTML export
« Reply #1 on: May 31, 2018, 02:30:03 am »
Just a thought; could that be a unicode issue?
Do you have the same problem on an SQL Server database or a Jet4 .eap(x)?

Geert

lfgcasey

  • EA User
  • **
  • Posts: 33
  • Karma: +0/-0
    • View Profile
Re: Suppress <<stereotype>> strings in HTML export
« Reply #2 on: May 31, 2018, 04:42:27 am »
I thought about that, which is why I tried used the Entity Names e.g. '&laquo;' in the JavaScript, which didn't work. I must be missing something.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Suppress <<stereotype>> strings in HTML export
« Reply #3 on: May 31, 2018, 04:19:29 pm »
It seems like trying to use the xml escaped character is not going to solve your issue if indeed it is related to unicode support.

It will probably find try to find the index of the literal string "&laquo;", which will not return anything.

Trying on a Jet4 or "real" database such as SQL server would be my first guess.

If that doesn't work you can try something like
Code: [Select]
indexOf(String.fromCharCode(171))That won't have the replacement issue I guess.

Geert

lfgcasey

  • EA User
  • **
  • Posts: 33
  • Karma: +0/-0
    • View Profile
Re: Suppress <<stereotype>> strings in HTML export
« Reply #4 on: May 31, 2018, 11:52:52 pm »
Hi Geert,

Sorry, forgot to mention our project is stored in an Oracle (I know and don't ask) DB.

I'll give your code a try and report back.

Thanks!

lfgcasey

  • EA User
  • **
  • Posts: 33
  • Karma: +0/-0
    • View Profile
Re: Suppress <<stereotype>> strings in HTML export
« Reply #5 on: June 01, 2018, 12:37:31 am »
I can confirm that this code does work and persists in the model Web Template just fine.

Code: [Select]
    var ndx = tocTab[i][2].indexOf(String.fromCharCode(171)); // 171 = char code '<<' "double-left quote"
    if (tocTab[i][2].indexOf(String.fromCharCode(171)) != -1)
    {
        //XXX CRB: This will remove the <<stereotype>> strings from the Project Browser pane
// 181 = char code '>>' "double-right quote"
        // const regex = /[«]+.*[»]+/gm;
        const regex = new RegExp('[' + String.fromCharCode(171) + ']+.*[' + String.fromCharCode(187) + ']+', 'gm');
        tocTab[i][2] = tocTab[i][2].replace(regex, "");
    }

Thanks again Geert!