In protégé, I changed the default widget for descriptions to editorpanewidget as I want to get some formatting for this field.
However Essential viewer does not keep the formatting .....
I would like to know which stylesheet(s) I would have to modify in order to get back the original format ...
(v3) : html formatting for descriptions
- neil.walsh
- Posts: 447
- Joined: 16 Feb 2009, 13:45
- Contact:
Hi,
We made the decision to keep the separation of content and formatting between Protege and Viewer to allow a consistent look and feel across the whole of Essential Viewer. As a result we chose to use the TextAreaWidget rather than the EditorPaneWidget as this provides us with clean plain text which we can format accordingly in Essential Viewer.
It is possible to get the content of the EditorPaneWidget to show but it requires some effort to get to work consistently.
First, let's look at the code which the EditorPaneWidget generates in it's most simplest form…
If we clean this up, we can see it's some standard html
You might think that this should parse ok in Viewer however there are the standard xsl query for calling the description of an object is as follows
This outputs the value of the select statement (in this case the description) as plain text and xsl by default "escapes" the code. We can correct this by disabling the output escaping on the query.
This then allows the code fragment for the description to be parsed correctly by the browser and show the description with the formatting… Unfortunately, the code contains a few things that Essential Viewer doesn't like.
Firstly, for bold text the EditorPaneWidget developers have used the <b> tag. This has been superseded by the <strong> tag and the Essential Viewer CSS stylesheets reset this tag. To make it work properly, you can open the essential_typography.css stylesheet (in the CSS folder) and change the following line (26 in the current release)
From:
To:
That will get bold working again on the <b> tag.
Next is a much more difficult problem. As you can see from the html snippet above,, the code contains some CSS styles. Specifically, it contains styles for Body and Paragraph. Due to the cascading nature of CSS, these styles then become the default values for the whole page, overwriting, in effect the predefined values for Essential Viewer. This results in the formatting for the whole page become "corrupted" by these styles.
I've had a think about how you might address this and one possible solution might be to write a xsl function which removes all content between the <head> tags thereby remove the styles. Maybe with a bit of research you could figure this out.
The final problem, is that you'd have to update every xsl stylesheet which had a description on it. This is mostly summary pages but descriptions are often used on tables of objects too. If I was to guess, I'd say you might be looking to update 40 or so xsl templates.
If do go down this route, you need to be aware that future updates to Essential Viewer might overwrite your changes. This might prevent you from upgrading or at least make it more time consuming.
However, all that said, the beauty of Essential is it's open-source and you're free to make any changes you want. I've provided such a detailed answer to help all users better understand how this stuff works. If you do make change that you think others might find useful then do feel free to share them back to the community. We're an open-minded bunch here and are always open to good ideas. If you think something should make it into the next release let us know and which give in serious consideration.
Thanks and good luck
Neil
We made the decision to keep the separation of content and formatting between Protege and Viewer to allow a consistent look and feel across the whole of Essential Viewer. As a result we chose to use the TextAreaWidget rather than the EditorPaneWidget as this provides us with clean plain text which we can format accordingly in Essential Viewer.
It is possible to get the content of the EditorPaneWidget to show but it requires some effort to get to work consistently.
First, let's look at the code which the EditorPaneWidget generates in it's most simplest form…
Code: Select all
<html>
<head>
<style type="text/css">
<!--
body { font-family: arial; font-size: 12pt }
p { margin-left: 2; margin-right: 2; margin-bottom: 2; font-family: arial; margin-top: 2 }
-->
</style>
</head>
<body>
<b>This is Bold</b>
<br>
<i>This is Italic</i>
<br>
<u>This is Underline</u>
<br>
<strike>This is Strikethrough</strike>
<br>
<font style="background-color: yellow" color="blue">This is Highlight</font>
<br>
This is an image
<br>
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/e/e4/Luxor,_Banana_Island,_Banana_Tree,_Egypt,_Oct_2004.jpg/240px-Luxor,_Banana_Island,_Banana_Tree,_Egypt,_Oct_2004.jpg">
</body>
</html>
Code: Select all
<html>
<head>
<style type="text/css">
<!--
body { font-family: arial; font-size: 12pt }
p { margin-left: 2; margin-right: 2; margin-bottom: 2; font-family: arial; margin-top: 2 }
-->
</style>
</head>
<body>
<b>This is Bold</b>
<br>
<i>This is Italic</i>
<br>
<u>This is Underline</u>
<br>
<strike>This is Strikethrough</strike>
<br>
<font style="background-color: yellow" color="blue">This is Highlight</font>
<br>
This is an image
<br>
<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/e/e4/Luxor,_Banana_Island,_Banana_Tree,_Egypt,_Oct_2004.jpg/240px-Luxor,_Banana_Island,_Banana_Tree,_Egypt,_Oct_2004.jpg">
</body>
</html>
Code: Select all
<xsl:value-of select="own_slot_value[slot_reference='description']/value" />
Code: Select all
<xsl:value-of select="own_slot_value[slot_reference='description']/value" disable-output-escaping="yes" />
Firstly, for bold text the EditorPaneWidget developers have used the <b> tag. This has been superseded by the <strong> tag and the Essential Viewer CSS stylesheets reset this tag. To make it work properly, you can open the essential_typography.css stylesheet (in the CSS folder) and change the following line (26 in the current release)
From:
Code: Select all
strong { font-weight: bold;}
Code: Select all
b,strong { font-weight: bold;}
Next is a much more difficult problem. As you can see from the html snippet above,, the code contains some CSS styles. Specifically, it contains styles for Body and Paragraph. Due to the cascading nature of CSS, these styles then become the default values for the whole page, overwriting, in effect the predefined values for Essential Viewer. This results in the formatting for the whole page become "corrupted" by these styles.
I've had a think about how you might address this and one possible solution might be to write a xsl function which removes all content between the <head> tags thereby remove the styles. Maybe with a bit of research you could figure this out.
The final problem, is that you'd have to update every xsl stylesheet which had a description on it. This is mostly summary pages but descriptions are often used on tables of objects too. If I was to guess, I'd say you might be looking to update 40 or so xsl templates.
If do go down this route, you need to be aware that future updates to Essential Viewer might overwrite your changes. This might prevent you from upgrading or at least make it more time consuming.
However, all that said, the beauty of Essential is it's open-source and you're free to make any changes you want. I've provided such a detailed answer to help all users better understand how this stuff works. If you do make change that you think others might find useful then do feel free to share them back to the community. We're an open-minded bunch here and are always open to good ideas. If you think something should make it into the next release let us know and which give in serious consideration.
Thanks and good luck
Neil
- neil.walsh
- Posts: 447
- Joined: 16 Feb 2009, 13:45
- Contact:
The same problem applies really. Just by using this widget, it creates default styles in the output which overwrite the default Viewer styles which means you'll need to write a function to handle this.
If you revert back to the TextAreaWidget you could use the HTML <br/> tag to force a line break in your description. This might look a bit odd in protege but would still be readable.
For example...
A single <br/> tag forces a new line, a double forces a new line and a line space.
You could potentially also use paragraph tags <p> however these might be more problematic in more complex situations such as tables or hidden divs. You'd also still need to disable output escaping for the original query which means updating the query on every relevant page.
We imagined the descriptions being short (1 paragraph) and the content that you might find in the descriptions actually being modelled in Essential itself. Perhaps you could share an example description / screenshot to show how you're using it.
Thanks
Neil
If you revert back to the TextAreaWidget you could use the HTML <br/> tag to force a line break in your description. This might look a bit odd in protege but would still be readable.
For example...
Code: Select all
Apache Tomcat is an open source web server and servlet container developed by the Apache Software Foundation (ASF).
<br/>
Tomcat implements the Java Servlet and the JavaServer Pages (JSP) specifications from Oracle Corporation.
<br/><br/>
It also provides a "pure Java" HTTP web server environment for Java code to run.
You could potentially also use paragraph tags <p> however these might be more problematic in more complex situations such as tables or hidden divs. You'd also still need to disable output escaping for the original query which means updating the query on every relevant page.
We imagined the descriptions being short (1 paragraph) and the content that you might find in the descriptions actually being modelled in Essential itself. Perhaps you could share an example description / screenshot to show how you're using it.
Thanks
Neil
Neil,
I understatnd that most of the description should be captured in the model but ... sometimes -- mainly for app. provider -- I use existing description to verify that I do forgot some aspect of the provider in my model.
In such a situation I find the description more convenient to read when there is some breaks between
the paragraph![Smile :)](./images/smilies/icon_e_smile.gif)
I'll try the <br/> trick ....
Thanks for your help.
I understatnd that most of the description should be captured in the model but ... sometimes -- mainly for app. provider -- I use existing description to verify that I do forgot some aspect of the provider in my model.
In such a situation I find the description more convenient to read when there is some breaks between
the paragraph
![Smile :)](./images/smilies/icon_e_smile.gif)
I'll try the <br/> trick ....
Thanks for your help.