Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » ServerTools (WTP) » parsing a jst to a dom tree
parsing a jst to a dom tree [message #168976] Wed, 10 May 2006 23:53 Go to next message
Alessandro Fredianelli is currently offline Alessandro FredianelliFriend
Messages: 32
Registered: July 2009
what's the best way to parse a jsp file and produce a dom tree?
This is the way i'm doing it now, but i'm guessing it's not the suitable

IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new
JSPModelLoader l = new JSPModelLoader();
DocumentFactoryForJSP f = new DocumentFactoryForJSP();
DOMModelForJSP jspModel=(DOMModelForJSP)l.newModel();
jspModel.setStructuredDocument((IStructuredDocument)f.create Document());

is there a view other then the content outline useful to display a dom tree?

Re: parsing a jst to a dom tree [message #168992 is a reply to message #168976] Thu, 11 May 2006 02:34 Go to previous message
David Williams is currently offline David WilliamsFriend
Messages: 722
Registered: July 2009
Senior Member
On Wed, 10 May 2006 19:53:49 -0400, Alessandro Fredianelli
<> wrote:

> what's the best way to parse a jsp file and produce a dom tree?

Like you were to get an IFile, then ...

IModelManager mm = StructuredModelManger.getModelManger();
// every 'get' needs a 'release'
IStrucutredModel sm = mm.getModelForEdit(file);

try {
// you should check instanceof and cast here, etc., here, to be sure model
is what you
// expected, and plan to deal with.
Docuemnt dom = sm.getDocument();

// do your DOM work here

finally {
if (sm != null) {

This DOM is, as you'd expect, sort of special (since for possibly
illformed text) and
is "shared" by others accessing it via the model manager ... which is
usually what you'd
want ... but, that's why the try/finally release is needed (as it is with
any shared resource).

the getModelForEdit and getModelForRead differ only in that those who get
it "for edit" are expected so save it if they are the last one hold it
before released. Where as "for read" means you don't care about saving it
... you just want to display what it is, etc.
Previous Topic:About WTP 1.5RC2 and EJB 3.x
Next Topic:Some KB shortcuts break syntax highlighting in JS
Goto Forum:

Current Time: Sun May 20 10:29:57 GMT 2018

Powered by FUDForum. Page generated in 0.02057 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top