Hi, Anne,
Thanks very much for the reply. What you describe is exactly the approach I am 
taking. I will use your suggestion of marking up the strings with "para://" and 
"img://" as leading type indicators. I will be happy to share the code once it 
is working.

Rather than write my own HTML parser, I am trying to work with 
javax.swing.text.html. It is part of the Topcased build. If you have a better 
suggestion, let me know. Thanks.

By the way, I worked through the GenDoc2 developer tutorial but found a bug : 
on page 9, the invoke statement would not work for me. I eventually discovered 
that it needed to use the argument 'removeSpecialCharacters(java.lang.String)' 
instead of just 'removeSpecialCharacters'. I think I am using a recent build of 
Topcased4.3.0. Is this the right forum to pass on discoveries like this ?

Best regards, Peter

Hello Peter,

You are right : nothing has been developped on Gendoc2 to handle correctly 
images from RichText content.
On ODT documents, it is not possible currently.
But HTML content is handled natively by MS Word : images links are kept but are 
image files are not embedded into the document, so the linked image file has to 
be accessible.
I suppose that is not exactly what you expect : in this case, you actually have 
to develop a new Acceleo service to split HTML documentation into paragraph or 
images and do something like the following :

[for (XXX e : splitDocumentation(getDocumentation()))]
[if( e.isParagraph()]
                [e/]
[else]
                <image filePath='[e.getImageFilePath()/]'>
</image>
[/if]
[/for]
The problem is that for Acceleo to work correctly, XXX must be a VALID type 
from a meta-model, type that we do not have currently.
The simplest solution we have found is to use the simplest type that you can 
handle : String .
Combined with a specific notation (Ex. : "para://text of your paragraph" or 
"img://image file path"),
and additional methods (Ex. : isParagraph(String),   isImage(String) , 
getImageFilePath(String) ) ,
you can get the same behavior.

Please keep us in touch on this problem.

Note :  The full description on how to create external bundles from your own 
Java services is detailed in the Gendoc2 developer tutorial  available here : 
http://gforge.enseeiht.fr/docman/view.php/102/4045/TPC_GenDoc2_v1.1.0_developer_tutorial.pdf

Best regards,
Anne

De : 
[email protected]<mailto:[email protected]>
 
[mailto:[email protected]]<mailto:[mailto:[email protected]]>
 De la part de Topcased user list where issues are discussed
Envoyé : jeudi 9 juin 2011 22:39
À : '[email protected]'
Objet : [Topcased-users] Translating HTML documentation with GenDoc2

I am creating Topcased tutorials using SysML 
(http://thinksysml.org/Tutorials/index.html). I now want to use GenDoc2 to 
export the tutorials in a .docx or .odt format. The problem is that the html 
formatting and images I am using in the documentation properties are lost in 
translation. I must use .getDocumentation().clean() to convert to strings. I 
don't mind losing the text formatting but the images are critical to the 
tutorial application.

It would seem that I need to write an Acceleo service to provide a more 
sophisticated getDocumentation function. Has anyone already done this?

I am thinking that the service could break the documentation into a list of 
objects (paragraphs and images) and return the list as a sequence. Then I could 
use the Acceleo for-loop to go through the list and depending on whether the 
object is a paragraph or an image, print the string or display the image. Are 
there any examples of custom sequences like this?
Thanks, Peter


Peter L. Jackson
Director of Graduate Studies,
Systems Engineering Program
Professor,
School of Operations Research
and Information Engineering
Rhodes Hall 218
(607) 255-9122
[email protected]<mailto:[email protected]>


Peter L. Jackson
Director of Graduate Studies,
Systems Engineering Program
Professor,
School of Operations Research
and Information Engineering
Rhodes Hall 218
(607) 255-9122
[email protected]

_______________________________________________
Topcased-users mailing list
[email protected]
http://lists.gforge.enseeiht.fr/cgi-bin/mailman/listinfo/topcased-users

Reply via email to