OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

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

[ Lists Home | Date Index | Thread Index ]
  • From: Peter Murray-Rust <peter@ursus.demon.co.uk>
  • To: XML-L@listserv.hea.ie
  • Date: Fri, 24 Apr 1998 11:43:41

[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@mmdata.kharkov.ua
>< 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@ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo@ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)





 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS