Book a Demo

Author Topic: Output of an RTF Script without linebreaks  (Read 9396 times)

Dan M

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Output of an RTF Script without linebreaks
« on: October 13, 2014, 10:49:43 pm »
Hi,

I'm working on a RTF-Template for database modeling. Thereby I use a JScript within a template fragment which generates an output similar to the example on http://www.sparxsystems.com/enterprise_architect_user_guide/10/reporting/example_output_of_an_rtf_templ.html .

Now I am facing the following problem: When using the parameter formatted="1" no line break from the script output is displayed in the generated rtf-document. Without the parameter formatted="1" line breaks are displayed, but ofcourse without any formatting (e.g. bold, italic ...).

For example, let this be the script output:
<?xml version="1.0"?><EADATA><Dataset_0><Data><Row><testfield formatted="1">&lt;i&gt;textone&lt;/i&gt;\n\ntexttwo</testfield></Row></Data></Dataset_0></EADATA>      

In the generated rtf_document it looks like this:
textone texttwo

But with formatted="0" it looks like this:
<i>textone</i>

texttwo

Is there a way to preserve linebreaks when using the parameter formatted="1" ?

Thank you!

Dan

Screwtape

  • EA User
  • **
  • Posts: 93
  • Karma: +4/-0
    • View Profile
Re: Output of an RTF Script without linebreaks
« Reply #1 on: October 23, 2014, 02:43:18 am »
Hi,

I noticed the same. I was using a custom fragment script to display notes fields with formatting, and what you describe happend to me too. I noticed that the formatted seemed to be translating html tags to RFT, so I tried enclosing my notes data in <pre></pre> tags in a CDATA section, but they just appeared as text before and after my notes.

It seems that is only interprets certain tags.

I tried using
curElem.Notes.replace("\n","<br/>")
to replace line breaks with forced formatting, but that doesn't work either.

I suspect this is a bug, as the behavior is very inconsistent.
Screwtape

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Output of an RTF Script without linebreaks
« Reply #2 on: October 23, 2014, 09:01:21 am »
I would try replacing \n with \r\n.

Screwtape

  • EA User
  • **
  • Posts: 93
  • Karma: +4/-0
    • View Profile
Re: Output of an RTF Script without linebreaks
« Reply #3 on: October 23, 2014, 05:16:17 pm »
Thanks for the idea Simon, but it still just printed the <br/> rather than interpreting it. I suspect that it translates certain formatting tags, but not everything.
Screwtape

Screwtape

  • EA User
  • **
  • Posts: 93
  • Karma: +4/-0
    • View Profile
Re: Output of an RTF Script without linebreaks
« Reply #4 on: October 25, 2014, 02:14:25 am »
Interestingly, I've just noticed, that the linebreaks are only removed if there are formatting tags in the note. If there aren't, and formatted="1" is still in place, the line breaks are fine.

I just changed single word to bold in the notes, re-generated the document and the word appeared bold, and the line break disappeared!
« Last Edit: October 25, 2014, 02:14:53 am by Screwtape »
Screwtape

Dan M

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Output of an RTF Script without linebreaks
« Reply #5 on: October 25, 2014, 02:23:42 am »
Hi,

I see the same behaviour in my environment. It really has the taste of a bug.

Regards
Dan

alesliehughes

  • EA Administrator
  • EA User
  • *****
  • Posts: 104
  • Karma: +0/-0
    • View Profile
Re: Output of an RTF Script without linebreaks
« Reply #6 on: November 10, 2014, 09:29:04 am »
Quote
seems that is only interprets certain tags.

I tried using
curElem.Notes.replace("\n","<br/>")
quote]
try
curElem.Notes.replace("\n","&lt;br/&gt;")

Dan M

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Output of an RTF Script without linebreaks
« Reply #7 on: November 11, 2014, 12:23:30 am »
Hello,

I tried it but still it doesn't work.

 var xmlNotes = xmlDOM.createElement( "testfield" );
 xmlNotes.text=attribute.Notes.replace(/\r\n/g,"&lt;br/&gt;");

This gives the following XML:
<?xml version="1.0"?>
<EADATA>
      <Dataset_0>
            <Data>
                  <Row>
                        <testfield formatted="1">&lt;i&gt;textone&lt;/i&gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;&amp;lt;br/&amp;gt;texttwo</testfield>
                  </Row>
            </Data>
      </Dataset_0>
</EADATA>

In RTF it looks like this:
textone<br/><br/><br/>texttwo

As Screwtape mentioned the following way doesn't work either:

  var xmlNotes = xmlDOM.createElement( "testfield" );
  xmlNotes.text=attribute.Notes.replace(/\r\n/g,"<br/>");

This produces the following XML:

<?xml version="1.0"?>
<EADATA>
      <Dataset_0>
            <Data>
                  <Row>
                        <testfield formatted="1">&lt;i&gt;textone&lt;/i&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;texttwo</testfield>
                  </Row>
            </Data>
      </Dataset_0>
</EADATA>

and in RTF it looks like:
textone<br/><br/><br/>texttwo

Do you have a running example? Could you please publish it?
Tank you.

Dan


alesliehughes

  • EA Administrator
  • EA User
  • *****
  • Posts: 104
  • Karma: +0/-0
    • View Profile
Re: Output of an RTF Script without linebreaks
« Reply #8 on: November 11, 2014, 11:24:40 am »
Hi Dan,

After looking at this issue, I couldn't find a way to get the carriage return to obey. Please file a bug report and we'll start the process of correcting this issue.

Alistair.
« Last Edit: November 11, 2014, 11:25:01 am by alesliehughes »

Screwtape

  • EA User
  • **
  • Posts: 93
  • Karma: +4/-0
    • View Profile
Re: Output of an RTF Script without linebreaks
« Reply #9 on: November 11, 2014, 09:15:16 pm »
Hi!

I've raised a bug (ref 14109186) along very similar lines a couple of weeks ago.

Yours,

Screwtape.
Screwtape