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

RE: Maybe a newbie question: Awful OO software structure with

  • To: <gbernd@g...>,<xml-dev@l...>
  • Subject: RE: Maybe a newbie question: Awful OO software structure with SAX!?
  • From: "Michael Kay" <mike@s...>
  • Date: Mon, 30 Jan 2006 00:51:29 -0000
  • In-reply-to: <9723.1138535249@w...>
  • Thread-index: AcYkytHj/Dh2c/sKT3ysj5RjMsrrwwAa/+uQ

software structure
There are two architectures you can use that solve this problem, I've used
them both satisfactorily. One is to write a ContentHandler that multicasts
events to recipients who have registered themselves: typically a recipient
registers itself as interested in element X, and when an X arrives you mark
that recipient as active and send it all events until the matching
end-element. The other approach is more of a pipeline: each event is
processed by the first filter in the pipeline, which then (if appropriate)
passes it on to further filters.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: gbernd@g... [mailto:gbernd@g...] 
> Sent: 29 January 2006 11:47
> To: xml-dev@l...
> Subject:  Maybe a newbie question: Awful OO software 
> structure with SAX!?
> 
> Hi,
> 
> I have a software project holding its configuration data in an XML
> structured file. Currently I'm using DOM to load this 
> configuration data and
> then kick off (instantiate) the relevant Java objects by providing the
> relevant DOM subtree to their constructor. Within each 
> management object,
> this hierarchical evaluation of the configuration data is 
> repeated as deep
> as necessary. For the example (see below), the "Evaluation" management
> receives the subtree below the <Evaluation>-node and provides 
> DOM subtrees
> to the "Plot_2D" and "Plot_3D" management objects when 
> instantiating them.
> 
> <Main>
> 	<General>
> 		...
> 	</General>
> 	<Evaluation>
> 		<Plot_2D>
> 			...
> 		</Plot_2D>
> 		<Plot_2D>
> 			...
> 		</Plot_2D>
> 		<Plot_3D>
> 			...
> 		</Plot_3D>
> 	</Evaluation>
> </Main>
> 
> When using the DOM concept, I like that each management 
> object (General,
> Evaluation, Plot_2D, Plot_3D...) is responsible for parsing 
> its own section
> of the configuration file. This reflects the OO software 
> approach of putting
> the code to the data and simplifies code maintenance.
> 
> Now, due the problem of determining line numbers in DOM, I'm 
> considering
> using a SAX parser. But when reading the SAX tutorials, I'm 
> horrified. All
> examples show one centralized event handler, which knows 
> about all keywords
> and dispatches the values to the JAVA objects.
> 
> This is against all OO approaches and requires changes in a 
> central module
> each time a subsection of the configuration data is made. Now 
> my question:
> Is this the intended way of using SAX? Or is there a way of 
> forwarding the
> SAX-events to sub-eventhandlers located in the management 
> objects, which I
> didn't find yet?
> 
> With kind regards
> Bernd
> 
> -- 
> DSL-Aktion wegen gro_er Nachfrage bis 28.2.2006 verldngert:
> GMX DSL-Flatrate 1 Jahr kostenlos* http://www.gmx.net/de/go/dsl
> 
> -----------------------------------------------------------------
> The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
> initiative of OASIS <http://www.oasis-open.org>
> 
> The list archives are at http://lists.xml.org/archives/xml-dev/
> 
> To subscribe or unsubscribe from this list use the subscription
> manager: <http://www.oasis-open.org/mlmanage/index.php>
> 
> 



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.