Building HTML document using script

Uploaded report templates and discussions about reports.

Moderators: sarawut_w, Moderators

Building HTML document using script

Postby james.e.hopper@leidos.com » Fri Jul 20, 2018 9:08 pm

We want to create an SDD from our model that matches a specific DID. I know how to do that using Word with embedded velocity, but management wants the document to be an HTML document that they can zip up the directory and send to the customer who will host it on their server or just let their engineers open it from a local browser directly. Looking at the documentation it looks like i can build scripts with things like JavaScript, Groovy, or Ruby (why not python?). But what is unclear from the documentation is how I would actually use the script. Is there some examples of how to build a document using one of the scripting languages without doing it in Word? Can I set up a javascript doc in a text tool and somehow connect that to my model and use that script to retrieve model elements for me that I can via the script format into a document that matches the DID?

Thanks jim
james.e.hopper@leidos.com
Forum Beginner
Forum Beginner
 
Posts: 25
Posts Rating:1
Joined: Thu Apr 13, 2017 11:02 am

Re: Building HTML document using script

Postby sarawut_w » Sun Jul 22, 2018 9:14 pm

Hello Jim,

but management wants the document to be an HTML document

We provide a built-in template, Web Publisher 2.0.
This template would get out elements and their specification into HTML report.
https://docs.nomagic.com/display/MD185/ ... 2.0+Report

If you do not want this template, please let us know, we would try find a solution in the rest of your questions.

Best regards,
Sarawut W.
Support Engineer
sarawut_w
No Magic
No Magic
 
Posts: 336
Posts Rating:23
Joined: Thu Jun 23, 2011 12:47 am

Re: Building HTML document using script

Postby james.e.hopper@leidos.com » Sun Jul 22, 2018 11:20 pm

Thanks for the reply. I saw the web publish templates, but they don't seem to allow one to customize them. I have a required format that the documentation must be in so I need to be able to customize the sections of the report to match the required documentation format the customer has required. The Documentation modeling stuff seems very promising, but the documentation supplied is not sufficient for me to understand how to create a document. There are gui dialogs specified with no description of how to get them, and from looking at the examples there appear to be things that need to be specified that the documentation does not seem to discuss. I could possibly create a document model by cutting and pasting from the examples but that could easily lead to a dead end if i need something not in the example and I don't understand who to create my own views/viewpoints.

The collaborator templates show promise as well, but I can not find any indication that we could publish the resulting document into an independent form that does not require the customer to have anything but a browser to read the document.

thanks jim
james.e.hopper@leidos.com
Forum Beginner
Forum Beginner
 
Posts: 25
Posts Rating:1
Joined: Thu Apr 13, 2017 11:02 am

Re: Building HTML document using script

Postby sarawut_w » Mon Jul 23, 2018 3:09 am

Hello Jim,

Thank you for explanation.

Can I set up a javascript doc in a text tool and somehow connect that to my model and use that script to retrieve model elements for me that I can via the script format into a document that matches the DID?

The Javascript cannot be used to retrieve model, it is used as a tool for doing some functions as you see in:
https://docs.nomagic.com/display/MD185/JavaScript+tool

Is there some examples of how to build a document using one of the scripting languages without doing it in Word?

Please see the sample of html template in this attachment.
SampleHTML.mrzip

SampleProject.mdzip

You could import the MRZIP file and open the template.html to see how to creating HTML template and includes other script files.

Best regards,
Sarawut
You do not have the required permissions to view the files attached to this post.
sarawut_w
No Magic
No Magic
 
Posts: 336
Posts Rating:23
Joined: Thu Jun 23, 2011 12:47 am

Re: Building HTML document using script

Postby james.e.hopper@leidos.com » Mon Jul 23, 2018 2:24 pm

Thanks for the samples. I imported SampleHTML and then looked at whats in the template. I can't see anything in there that lets me customize anything beyond some strings. I can't see anything that indicates you can import scripts. The mdzip file won't open on my 18.5 copy, I will download and install 19 to take a look at it.

best jim
james.e.hopper@leidos.com
Forum Beginner
Forum Beginner
 
Posts: 25
Posts Rating:1
Joined: Thu Apr 13, 2017 11:02 am

Re: Building HTML document using script

Postby sarawut_w » Mon Jul 23, 2018 7:56 pm

Hello Jim,

After import the SampleHTML.mrzip file via Report Wizard dialog, it would locate at:
Code: Select all
C:\Users\{username}\AppData\Local\.magicdraw\{version}\data\reports\SampleHTML

You may start with template.html.

Best regards,
Sarawut
sarawut_w
No Magic
No Magic
 
Posts: 336
Posts Rating:23
Joined: Thu Jun 23, 2011 12:47 am

Re: Building HTML document using script

Postby james.e.hopper@leidos.com » Mon Jul 23, 2018 8:13 pm

Thanks, i downloaded version 19. I can't update our server to use 19 without breaking our 18.5 clients as far as i know so i am limited to the demo version. But I can see how you can build the HTML template. Is there any documentation on this? Is the language the velocity language used with word documents? Can I just follow the rules of scripting in a word document to expand what I can do with this?

Thanks
Jim
james.e.hopper@leidos.com
Forum Beginner
Forum Beginner
 
Posts: 25
Posts Rating:1
Joined: Thu Apr 13, 2017 11:02 am

Re: Building HTML document using script

Postby james.e.hopper@leidos.com » Mon Jul 23, 2018 9:04 pm

Ok made some progress and verified that i can use the velocity scripts. But i can't seem to get it to display a diagram. i added a class diagram to your sample project than in the template I added code to display an image but while it shows the header, it refuses to display the image. Could you perhaps expand your example to include a diagram? Is there any documentation on how to do this with HTML? There appears to be good documentation on doing this with Word which I have used in the past but can't find anything for HTML. I feel like this is possible to make work if i can get some more samples or documentation

thanks jim
james.e.hopper@leidos.com
Forum Beginner
Forum Beginner
 
Posts: 25
Posts Rating:1
Joined: Thu Apr 13, 2017 11:02 am

Re: Building HTML document using script

Postby sarawut_w » Mon Jul 23, 2018 9:37 pm

Hello Jim,

Can I just follow the rules of scripting in a word document to expand what I can do with this?

We are sorry for your inconvenience, we do not have a document for HTML template.
You could apply the Velocity language that you write on the DOCX template to HTML template.

Could you perhaps expand your example to include a diagram?

Please add this below highlighted code to your "template.html".
sample.png


Best regards,
Sarawut
You do not have the required permissions to view the files attached to this post.
sarawut_w
No Magic
No Magic
 
Posts: 336
Posts Rating:23
Joined: Thu Jun 23, 2011 12:47 am

Re: Building HTML document using script

Postby james.e.hopper@leidos.com » Mon Jul 23, 2018 10:48 pm

Thanks that's closer. it now prints out the name of the diagram but no diagram image is displayed. It looks like d1.image is a partial pathname to the image not the full path to the image. is there a way to get the full path or is there some other option?

<h2>Diagram List</h2>
<div>
#foreach ($dl in $sorter.sort($Diagram))
<h4>Diagram #if("$dl.name"=="")$na#else$dl.name#end</h4>
<img src="$d1.image" alt="$d1.name">
<br>
#end
</div>
james.e.hopper@leidos.com
Forum Beginner
Forum Beginner
 
Posts: 25
Posts Rating:1
Joined: Thu Apr 13, 2017 11:02 am

Next

Return to Report Engine

Who is online

Users browsing this forum: No registered users and 0 guests