You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by "Farmer, Rod (Contractor)" <Ro...@dsto.defence.gov.au> on 2003/11/11 00:35:03 UTC

Calling xerces recursively doesn't procede linearly

Hello,

I'm using SAX to implement a data layer which permits object serialization across Java and C++. Without going into the library which does the grunt work, I'd like to describe a problem I'm facing.

A (Java) class that is code generated from an XML specification can contain a constructor that tries to initialise a class attribute which is a class, which itself takes an XML specification, ie

String default_ship = "<Ships.BattleCruiser><name>XXX</name><type>YYY</type>......</Ships.BattleCruiser>";
Ship my_default_ship = ObjectReader.readObject(default_ship);

As you can see ObjectReader returns the instantiated Ship object.
ObjectReader calls my DefaultHandler to parse the XML and create the object in question.


The problem  I am having is that while parsing an XML document (or string) and creating objects (via reflection), if I try to create an object which in turns performs the above operation in it's constructor, the operation is does not procede linearly. In other words: (In default handler)

while (something) {
clazz = Class.forName(qName); // always called
classObject = clazz.newI	nstance(); // 
}

if clazz.newInstance needs to parse an XML string via XERCES-J, the program execution doesn't procede linearly, with the DefaultHandler somehow continuing without waiting for the newInstance() call to return.

I would have thought, that even if a new call to XERCES was made, that the above code would have blocked until it's return. However, it does not.


Could someone please explain to me how XERCES handles recursive calls (ie multithreaded, process stacks ... ???) and hopefully, how I could make the above code block until the new XERCES parsing returns?


Many thanks to all your help. It is much appreciated.


 
Rod Farmer
 
========================================
Rod Farmer
Software Engineer
KESEM International
Rod.Farmer@kesem.com.au <ma...@kesem.com.au>,



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org