eclipse / epsilon

Epsilon is a family of Java-based scripting languages for automating common model-based software engineering tasks, such as code generation, model-to-model transformation and model validation, that work out of the box with EMF (including Xtext and Sirius), UML (including Cameo/MagicDraw), Simulink, XML and other types of models.
https://eclipse.org/epsilon
Eclipse Public License 2.0
55 stars 11 forks source link

Embedding non-XML views in Picto #14

Closed kolovos closed 1 year ago

kolovos commented 1 year ago

Trying to embed views which are not valid XML in other Picto views fails at the moment as reported in this forum post. A minimal example with a standalone Picto file and two custom HTML views follows.

<!--example.picto-->
<?nsuri picto?>
<picto standalone="true">
    <view path="Root, View1" format="html" source="view1.html"/>
    <view path="Root, View2" format="html" source="view2.html"/>
</picto>
<!--view1.html-->
View 1
<!--view2.html-->
<html>
<h1>View 2</h1>
<picto-view path="Root, View1"/>
</html>

Trying to render Root/View2 produces a Content is not allowed in prolog. error message in Picto because view1.html is not valid XML.

To fix this we could try to parse the content of the view to embed as XML and if this fails, put it in an iframe instead.

It would also be nice to support a custom iframe attribute in <picto-view> elements to allow the user to force an iframe (e.g. if the other view is XHTML but the user doesn’t want its CSS/JavaScript to mess up the host page’s style/functionality).

alfonsodelavega commented 1 year ago

I have found a solution that also solves an extra problem with iframes: detecting the proper height and width of the contents.

Using the iFrame Resizer library, it's possible to fix iframe weight at 100% and then determine the height of the contents after rendering (example).

This library requires adding a js file to the upper html, and another js file to the inner one (i.e. the one contained in the iframe). Would this last part be much of a hussle?