You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by "Sureka, Sushil" <su...@tgslc.org> on 2001/03/30 22:48:16 UTC

Content handler based on the XML content??

Hi,

Is it possible to load a particular content handler  based on one of the
field value in the xml file. For example if I have

One record as
<Record1>
 	< BorrName> .... </BorrName>
	.............................
</Record1>


and another record as
<Record2>
	<Response> REJECTED</Respone>
	................
</Record2>

And any of this record can appear in the file 

when I am loading the file I don't know what kind of record it contain, but
based on whether it is AppSend or AppResponse I want to register seperate
content handler for parsing.

The only way I can think of is possible is register a generic handler to
start with and this handler sets some global variable based on if it is
Record1 or Record2.
And then, reparse the file (using the new content handler) based on
this variable. But this is not desirable solution since it parses the file
twice.
The only other way would be to have one handler handle all different kind of
records

Sushil


---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Re: Content handler based on the XML content??

Posted by Andy Clark <an...@apache.org>.
"Sureka, Sushil" wrote:
> Is it possible to load a particular content handler  based on one of the
> field value in the xml file. For example if I have

Since you know the kinds of "records" you are processing in your
XML documents, write a custom multi-plexing content handler. The
multi-plexing handler would change the appropriate content handler
based on the "record" that it sees. In this way you can cleanly
separate your code into separate content handler instances.

-- 
Andy Clark * IBM, TRL - Japan * andyc@apache.org

---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org