startElement method not Called

Hi All,

I am trying to parse an XML by extending DefaultHandler.

...

InputSource input = new InputSource(new ByteArrayInputStream(fileContent));

SAXParserFactory spf = SAXParserFactory.newInstance();

spf.setValidating (false);

XMLReader xmlReader = null;

SAXParser sp = spf.newSAXParser();

xmlReader = sp.getXMLReader();

xmlReader.setContentHandler(this);

xmlReader.setErrorHandler(new MyErrorHandler(System.err));

input.setSystemId("file:///d:\\srm52\\dtd\\ContractData.dtd");

xmlReader.parse(input);

the startDocument method is called, but after that the code exit without parsing any Elements. It doesn't enter the startElement method.

I am running this code in Weblogic.

please let me know what could be wrong.

any help will be appreciated(asap).

thanks in adv

ashok

[927 byte] By [asho_kk] at [2007-9-26 3:03:47]
# 1
Hello Ashok,the DefaultHandler implements all method with a empty body, see API-Doc. You must fill all method that you will use.Your problem is probably a parse error. Check your XML-File and your DTD.Roland
rkunzke at 2007-6-29 11:04:04 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

Hi Roland,

The same code running from DOS prompt works fine by parsing all the elements.

But when i run it in weblogic enivronment, it just stops after entering startDocument. There is no error, no exceptions.

I am using the same XML & DTD in both the instances.

I don't know what is wrong..

thanks

ashok

asho_kk at 2007-6-29 11:04:04 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
Hello Ashok,i have no experience with WebLogic, why i works with WebSphere. But when you want send me a code-excample and i will test it under WebSphere. I have no other idea.Good Luck Roland
rkunzke at 2007-6-29 11:04:04 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4

Check your startElement call in DefaultHandler.

It's like this:

public void startElement(String namespaceURI, String localname, String rawName, Attributes atts) throws SAXException {

//do something

}

This works correctly with SAX2.0 parser like Xerces.

In Parser with SAX1.0 startElement has only two params.

I think your problem is due to not exact startElement method overriding

Bye

atonello at 2007-6-29 11:04:04 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 5
Had the same problem.There are two possible methods to override startElement().First, I used the short one (with two parameters) which didn't work, then thesecond and - voil - it worked!Dom
dominicheyden at 2007-6-29 11:04:04 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...