cornercorner
FeaturesPluginsDocs & SupportCommunityPartners

SharingJSPParser

Insync/Designer parsing overview

Insync requires JSP parsing to model(read) and code-generate(write) jsp file corresponding to a JSF page. Whereas Designer requires parsing for rendering the JSP page. Designer uses RaveDOMParser which extends from org.apache.xerces.parsers.DOMParser, RaveElement which extends from org.apache.xerces.dom.ElementNSImpl and RaveSourceDocument/RaveRenderedDocument extending from org.apache.xerces.dom.DocumentImpl in order to achieve the following

  • keep some state
  • to implement the StylableElement interface from batik's CSS handling code

Insync triggers the parsing of jsp file is parsed whenever it is modified externally. It holds on to RaveSourceDocument and RaveRenderedDocument as long as the designer is open.

JSP editor parsing overview

Netbeans JSP editor uses jasper parser to parse the jsp file. They copy the Nodes(org.apache.jasper.compiler.Node.Nodes) obtained from the parser into its own internal Nodes object(org.netbeans.modules.web.jsps.parserapi.Node.Nodes). I do not see these internal netbeans specific Nodes being used to generate code, I suspect it is read-only. Whenever you insert code in jsp through code-completion or via drag and drop from palette(non-visualweb), they insert the code directly into the base document unlike in insync where-in the DOM is manipulated and then the diffs are inserted into jsp file.

Common JSP parser

One requirement for common JSP parser is that it should be retouche equivalent for jsp. It should be provide APIs to

  • create DOM elements/nodes
  • modify DOM(Insertion/Deletion of elements/nodes)
  • support jspx/xhtml serializing(for example not minimizing the tag <script></script>)
  • ability to listen to DOM events(For example, CssEngine uses this)

If the common JSP parser is available, Insync will be able to use it for read/write the jsp file. However Designer will not be able to use it right away because of the reasons mentioned in the first paragraph. One option could be to walk through the DOM returned by common JSP parser and to create designer specific DOM. I think more discussion is required on this aspect.