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

Re: YAXPAPI (Yet Another XML Parser API)- an XDEV proposal

  • From: "Don Park" <donpark@q...>
  • To: "Tim Bray" <tbray@t...>, <xml-dev@i...>
  • Date: Sat, 13 Dec 1997 14:00:15 -0800

xml parser api
Tim and Peter,

From: Tim Bray <tbray@t...>
>It should come in event-stream flavor and tree flavor.
>
>Minimal event stream API:
>
>1. Doctype, returns: root type, external subset system/public idents
>2. Element start, returns: type, element name-value pairs, whether it's
empty
>3. Text
>4. End Element, returns: type
>
>Minimal tree API:
>
>1. Document, with methods: root type, system ID, public ID, root element
>2. Element, with methods: parent, children, attributeValueByName,
allAttributes
>3. Attribute, with methods: name, value
>4. Text (presumably hiding lazy evaluation)


IMHO, it would be major mistake to combine XML parser client API and service
provider API.  I would much rather see something like Swing's TreeModel
interface used as XML parser service provider API with opaque objects.

public interface XmlTreeModel {
    public Object getRoot ();
    public Object getParent (Object child);
    ...
}

public interface XmlEventModel {
    public String getElementName (Object event);
    ...
}

public interface XmlEventProducer {
    public void addConsumer (XmlEventConsumer c);
    public void removeConsumer (XmlEventConsumer c);
    ...
}

public interface XmlEventConsumer {
    public void elementStarted (XmlElementEvent evt);
    public void elementEnd ed (XmlElementEvent evt);
    ...
}

XmlEvent is part of the client API which is mostly convenience class
framework:

public class XmlEvent extends EventObject {
    protected XmlEventModel    model;
    protected Object                    object;
    ...
}

public class XmlElementEvent extends XmlEvent {
    public String getElementName () {
        return model.getElementName(object);
    ...
}

>I acknowledge this is grossly insufficient for basing an editor on. You
want
>that, use the DOM.  Only a few choices have design implications:


I think editing should be supported with another layer of interfaces so that
basic interface can remain simpler.

public interface MutableXmlTreeModel {
    public Object newElement (String name, ...);
    public void addAttribute(Object elem, String name, String value);
    ...
}

XML parser service provider API is mostly just interfaces and deals with
opaque objects returned by XML parser implementations.  XML parser client
API consists of DOM classes uses opaque objects to drive parsers
implementations (see XmlElementEvent above).


Don Park




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.