[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XML, MVC and Swing (was Re: better searching!!)

  • From: Peter Murray-Rust <peter@u...>
  • To: XML-L@l...
  • Date: Fri, 24 Apr 1998 11:43:41

mvc swing
[crossposted to XML-DEV because I think the software aspects are relevant
to current endeavours].
At 11:10 22/04/98 +0300, Alexander Evsukov wrote:
[...]
>I guess that this approach is also close to the Model/View/Controller
>architecture. With application to XML, it looks like XML plays a role of a
>Model (data to be displayed), XSL determines a View (how data should be
>rendered) and XML browser acts as a Controller. Right?

I think this is a useful analogy, though I'm not an expert on MVC. I have
been cutting my teeth on SwingSet, Javasoft's classes for building
graphical applications and these are based on MVC. [There is a lot to learn
about!].

I have implemented JUMBO2 using SwingSet MVC and an example is the following:

An XML document is tree-structured and/or eventStream-structured. If we
take the first, we can read an XML document via SAX and build a tree using
the Swing classes. I subclass DefaultMutableTreeNode (not as bad as it
sounds!) to create an XNode which holds data for any ELEMENT. Each child is
added by something like:
	XNode fooNode = new XNode("FOO");
	XNode barNode = new XNode("BAR");
	fooNode.add(barNode);
and so on. This builds a tree (I also treat PIs and PCDATA as special
subclasses of XNode).
	To display it I create a SAXTree (subclassed from JTree), with something like
	SAXTree tree = new SAXTree(fooNode);
	tree.display();   // display routine lifted from Swing examples

Note that JTree is a View of a treeModel (fooNode and children). There
could be several displays of the treeModel, including eventStream-based
ones (haven't hacked that yet :-). [BTW the SwingSet text model says it is
SGML-oriented, so well worth a look].

the SAXTree displays... If I click on "FOO" the standard behaviour is to
display its children and the tree expands. This does not affect the model.
If I delete the barNode from the treeModel, a signal is passed to the JTree
which automatically updates the display to reflect the disappearance of the
node from the model.  If I had an eventstream-based view (e.g text) then it
would be simultaneously updated). Very powerful.

So I think your analogy is very close. There is a very strong mapping from
XML to Java, and the SwingSet appears to take this even further. As I said,
I'm still exploring this, but it's much better than writing all my own code
(as in JUMBO1). Obviously I don't know how the stylesheets will be
implemented (see Jon Bosak's announcement on XML-DEV that XSL will look
very different from the last draft). What I do in JUMBO2 is allow some
manually switchable heuristics for different ways of rendering. Thus an XML
document can be rendered in a number of tree- and stream-based forms
(although the full MVC power is not used yet).

All JUMBO2 code will be publicly released in a few days if anyone is
interested. Any communal help with learning Swingset would be appreciated
:-) - there are 50 classes alone for managing Trees!

	P.



 
>
>---
>Sincerely,
>Alexander Evsukov (a.k.a. Sanders)
>M&M Data Systems, Ukraine
>mailto:sanders@m...
>< Standard Disclaimer >
>
Peter Murray-Rust, Director Virtual School of Molecular Sciences, domestic
net connection
VSMS http://www.nottingham.ac.uk/vsms, Virtual Hyperglossary
http://www.venus.co.uk/vhg

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo@i... the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)


PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.