On Thu, 2004-08-12 at 23:24, Martin GÃlich wrote: > Hello! > > I am wondering if anyone knows of a way to start parsing an XML-file > and giving the corresponding DTD or XML Schema definition as input, > with the purpose of somehow making Xerces automatically use a separate > callback method for each element. Suppose this is the XML file: > > <TAG1>â</TAG1> > > <TAG2>â</TAG2> > > > > If the DTD specifies this then I want Xerces to automatically provide > and call callback methods startTAG1() and startTAG2(), instead of just > calling startElement() with me having to specify lots of conditions to > find out which tag it was. > > > > Does anyone know if this is possible? I am new to Xerces so if this is > trivial please tell me anyway J.
I'm pretty sure that Xerces does not support this directly. However it is fairly simple for you to write a startElement method that uses java reflection to locate an appropriately named method and invoke it. This should take only a dozen or so lines of code to implement. You'll have to consider what to do about xml namespaces. eg <ns1:TAG1/> <ns2:TAG1/> <TAG1 xmlns="foo"/> are really completely different tags, so which methods should be called? Regards, Simon --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]