Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 323320 - XML Content Model View
Summary: XML Content Model View
Status: RESOLVED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.xml (show other bugs)
Version: 3.2   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: 3.3 M3   Edit
Assignee: David Carver CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-21 21:48 EDT by David Carver CLA
Modified: 2010-10-15 16:40 EDT (History)
1 user (show)

See Also:
nsand.dev: review+


Attachments
Adds an XML Content Model View (19.45 KB, text/plain)
2010-08-23 09:58 EDT, David Carver CLA
no flags Details
hierarchy.gif file, place in icons/full directory (209 bytes, image/gif)
2010-08-23 10:00 EDT, David Carver CLA
no flags Details
Synched icon, place in icons/full (160 bytes, image/gif)
2010-08-23 10:01 EDT, David Carver CLA
no flags Details
patch with CMVisitor (16.66 KB, patch)
2010-10-14 19:37 EDT, Nick Sandonato CLA
no flags Details | Diff
patch - lazy-loaded CM (18.86 KB, patch)
2010-10-15 12:01 EDT, Nick Sandonato CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Carver CLA 2010-08-21 21:48:02 EDT
Many commercial XML editors provide a view for viewing the Content Model of a node (i.e. what elements, attributes, data types, and children a node has).

While the Hover Assistance, and the XML Graphical Tree editor provide some of this, there is no current way to navigate the content model for a particular node.   The view should allow for navigation of the underlying content model, the min/max occurrences, optional/required, and if known the datatype associated.

I have a basic view working, but will be adding a few more tweaks.  Once I have something I'll attach a patch for review here.
Comment 1 David Carver CLA 2010-08-23 09:58:56 EDT
Created attachment 177219 [details]
Adds an XML Content Model View

Adds an XML Content model view, for navigating the content model of an underlying DOM node.  Works best so far with DTD or Schema backed models, can read an inferred model but needs work on interpretting the content.
Comment 2 David Carver CLA 2010-08-23 10:00:19 EDT
Created attachment 177220 [details]
hierarchy.gif file, place in icons/full directory
Comment 3 David Carver CLA 2010-08-23 10:01:02 EDT
Created attachment 177221 [details]
Synched icon, place in icons/full
Comment 4 David Carver CLA 2010-08-24 09:31:52 EDT
Adding nick to the bug.

Nick this still needs some work for inferred grammars, it isn't getting occurrences correctly for these.
Comment 5 David Carver CLA 2010-09-30 09:58:47 EDT
Nick any possibility of getting this reviewed and committed?
Comment 6 Nick Sandonato CLA 2010-10-04 16:22:13 EDT
(In reply to comment #5)
> Nick any possibility of getting this reviewed and committed?

Hey, Dave. This is kind of interesting. It looks like inferred CMElementDeclarations will always set the max to 1.

I had trouble with DTD-backed models. CMElementDeclaration#getLocalElements() was returning an empty list when I would create an XML from the XHTML Transitional catalog entry. (Similar things happened for Inferred grammars).

Would it be possible to use the ModelQuery utilities to get content model information? It might make the DTD & inferred grammar cases a bit simpler when calculating available child nodes and will also allow for models that have been contributed to through ModelQuery Extension.

Also, inferred grammars have an inherent delay in loading the CMDocument, this may also impact the view.
Comment 7 David Carver CLA 2010-10-04 17:25:50 EDT
(In reply to comment #6)
> (In reply to comment #5)
> > Nick any possibility of getting this reviewed and committed?
> 
> Hey, Dave. This is kind of interesting. It looks like inferred
> CMElementDeclarations will always set the max to 1.
> 
> I had trouble with DTD-backed models. CMElementDeclaration#getLocalElements()
> was returning an empty list when I would create an XML from the XHTML
> Transitional catalog entry. (Similar things happened for Inferred grammars).

Okay, I only did testing with XML Schema backed content model, will need to do some tests for how DTD and Inferred grammars are done.

> 
> Would it be possible to use the ModelQuery utilities to get content model
> information? It might make the DTD & inferred grammar cases a bit simpler when
> calculating available child nodes and will also allow for models that have been
> contributed to through ModelQuery Extension.

I believe ModelQuery util is being used to get Content Model information based on the Element Node that is passed into it.   I'm open to any suggestions and patches along this line.


> 
> Also, inferred grammars have an inherent delay in loading the CMDocument, this
> may also impact the view.

Yes, it could, we might want to look at running that on a background thread?
Comment 8 Nick Sandonato CLA 2010-10-14 19:37:39 EDT
Created attachment 180920 [details]
patch with CMVisitor

Hey Dave,

Here's an attempt at getting inferred and DTD-based grammars to work along. I'm still working on seeing if I can work in support for modelquery extensions. I'll probably only be able to provide that information for the currently selected node.
Comment 9 David Carver CLA 2010-10-14 20:30:10 EDT
(In reply to comment #8)
> Created an attachment (id=180920) [details]
> patch with CMVisitor
> 
> Hey Dave,
> 
> Here's an attempt at getting inferred and DTD-based grammars to work along. I'm
> still working on seeing if I can work in support for modelquery extensions.
> I'll probably only be able to provide that information for the currently
> selected node.

Thanks Nick.  It may be a bit before I get back to this so preceed as you see fit.  My day job is cutting into my open source time. :(
Comment 10 Nick Sandonato CLA 2010-10-15 12:01:46 EDT
Created attachment 180982 [details]
patch - lazy-loaded CM

Bummer to hear that, Dave.

I tweaked the patch some more. Inferred grammars are handled a little better now (the groups containing individual elements are unbounded so, the individual element declarations are shown as such now).

Also, I'm now lazy-loading the child contents of each node. So now the content models for HTML or XHTML documents should be viewable. Selection responses should also be faster too since we're not calculating the entire tree.
Comment 11 Nick Sandonato CLA 2010-10-15 16:19:32 EDT
Thanks for the new view, Dave. I've released the changes from the most recent touch-up. If you think I missed anything, let me know.
Comment 12 David Carver CLA 2010-10-15 16:40:11 EDT
(In reply to comment #11)
> Thanks for the new view, Dave. I've released the changes from the most recent
> touch-up. If you think I missed anything, let me know.

Thanks for fixing the final issues.  Glad to see it made it for Indigo.