Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "MoDisco/Components/JSP/Architecture/0.9"
(→JSP Parser) |
|||
Line 2: | Line 2: | ||
=JSP Parser= | =JSP Parser= | ||
− | Modisco JSP Parser has been developed using an ANTLR grammar | + | Modisco JSP Parser has been developed using an ANTLR grammar. |
+ | |||
It can support JSP file, as well as HTML files, TAG files, and JSP/TAG fragment files | It can support JSP file, as well as HTML files, TAG files, and JSP/TAG fragment files | ||
Line 8: | Line 9: | ||
The ANTLR grammar is composed with rules representing what could be founded in a JSP file : | The ANTLR grammar is composed with rules representing what could be founded in a JSP file : | ||
+ | |||
+ | The root element for the grammar is "Page" | ||
+ | |||
+ | A "Page" can contain JSP items, as well as Doctype declarations, comments, CData items or simply HTML tags | ||
+ | |||
+ | Tags are the basic element to describe a JSP file. A tag can contain xml-like attributes, possibly composed with JSP elements. | ||
+ | |||
==Updating the Grammar== | ==Updating the Grammar== | ||
Line 13: | Line 21: | ||
===Non XML Conformity=== | ===Non XML Conformity=== | ||
− | The | + | The JSP Grammar take in consideration the non XML conformity of a JSP file. |
Knowing that it can contain html or javascript tags, an opened tag is not necessarily closed by one | Knowing that it can contain html or javascript tags, an opened tag is not necessarily closed by one | ||
Revision as of 11:12, 5 July 2010
DEPRECATED use Template:MoDiscoTabs and Template:MoDiscoTab as explain here : Wiki Template for MoDisco
Contents
JSP Parser
Modisco JSP Parser has been developed using an ANTLR grammar.
It can support JSP file, as well as HTML files, TAG files, and JSP/TAG fragment files
Grammar Architecture
The ANTLR grammar is composed with rules representing what could be founded in a JSP file :
The root element for the grammar is "Page"
A "Page" can contain JSP items, as well as Doctype declarations, comments, CData items or simply HTML tags
Tags are the basic element to describe a JSP file. A tag can contain xml-like attributes, possibly composed with JSP elements.
Updating the Grammar
Non XML Conformity
The JSP Grammar take in consideration the non XML conformity of a JSP file. Knowing that it can contain html or javascript tags, an opened tag is not necessarily closed by one
Example :
<img src="./img/myImage.png">
In order to build the inheritance tree, we had to store all the found tags, and each time a closing one is detected, rebuild the inheritance tree.
Example :
<p>
<img src="./img/myImage.png">
</p>
This fragment of code will add the <img> tag to the children of the <p> tag when </p> is detected, and so on.
User Code in the generated one
Because we do not know if a tag will be closed later in the code, we had to manually implement some text concatenation.
Let's say we meet a new opening tag:
<p>
This is some HTML content
</p>
We cannot declared a rule "'<p>' 'any letter' '</p>'" because </p> might never appears, or a JSP expression could be there. That is why we concatenate manually the potentially present content after an opening tag, and wait till we found a known token.