Customizing HTML generation

 

Automatic hypertext links

When generating HTML, hypertext links can be generated automatically during the generation of a model element.

 

The generation of hypertext links can be parameterized by redefining a J method defined on the model element.

 

The hypertext links defined on ...

retrieve a file with the identifier ...

packages

of the package

classes

of the class

parameters

of the class which gives the parameter type

roles

of the class which is the destination of the association

 

 

The following method is used to define a hypertext link for a model element:

default#external#Documentation#getHyperLink return String

 

It should return the name of the file to which the link is referring to.

 

Note:      During the generation of the hypertext link, the existence of the file is not checked.  Indeed, the file can be generated after the hypertext link is generated by a document item that will be defined later in the document template.

 

 

Example of automatic hypertext links

This method returns the name of a file to which the hypertext link should point to.  This name is made up of the name of the class and the "html" extension.

Class:default#external#Documentation#MyDocPov#getHyperLink

{

   return.strcat (Name, ".html");

}

 

 

Generated file names

In HTML generation, a document item may need to generate the information for each model element scrolled through in a specific file.  The file name is customizable by redefining a J method.

The following method allows you to define the name of the file that will be generated for a model element:

ItemDocumentation:default#external#Documentation#

  getFileName

                      (element : in DescribedCRElement,

                      path : out String,

                fileName : out String,

                      suffix : out String)

 

It is called for each model element during the generation of a document item. This document item is called as parameter.

 

The ... parameter

corresponding to ...

is by default ...

path

directory

the directory defined in the document work product

fileName

file name

the identifier of the model element scrolled through

suffix

suffix

out" (a file is formatted with TPF which only accepts files with the "out" extension). It renames the file with the correct suffix after formatting

 

 

This method returns the name of the file that must be created by the document item for a specific model element.  This name is made up of the name of the model element and the "out" extension (TPF will translate this extension adequately when the files are formatted in the desired targeted format.)

 

ItemDocumentation:default#external#Documentation#

MyDocPov#getFileName

(element : in DescribedCRElement,

path : out string,

fileName : out string,

suffix : out string)

{

   path     = "";

   fileName = element.Name;

   suffix   = "out";

}

 

 

Generating hypertext links

The following method is a service used to generate hypertext links:

Object:generateHyperLink (link : in String,

text : in String) return String

 

If the content of the "link" parameter is empty or if the generation is not HTML, then the method returns the content of the "text" parameter.

In other cases, a character string with the following type is returned:

<A HREF="link">text</A>

 

 

Example of generating hypertext links

The following method is used to generate the name of the parent of a NameSpace with a hypertext link towards it.

String NameSpace::generateOwner ()

{

String fileName;

    String result;

 

    if (isHtmlGeneration()) {

        result.strcat (getMulMessage

(MSG_FILE, "Owner"),

generateHyperLink (OwnerNameSpace.<getHyperLink(),

OwnerNameSpace.<Name),

generateCarriageReturn());

    }

    return result;

}   // method generateOwner

 

 

HTML generation

The following method is used to find out whether the current generation generates in HTML format.  The target format information is retrieved in the document work product that ran the generation.

Object:isHtmlGeneration() return boolean