This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Parsing Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Reply Bookmark "Parsing Problem" Watch "Parsing Problem" New topic
Author

Parsing Problem

Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
Hi am trying to parse a XML document using SAX parser. And in the start Element()
public void startElement(String namespaceURI,
String localName,
String qualifiedName,
Attributes attrs) {}

Attributes were coming.. Suppose the attributes are not specified in the document, still this attrs taking the values from DTD. How to avoid this

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32689
    
    4
Too difficult a question for beginners'. Moving.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12269
    
    1
If this was my problem I would experiment with creating an implementation of DTDHandler that did nothing and making the parser use that instead of the default. See the XMLReader docs.

I have no idea if that would work but that is what I would try first.

Bill


Java Resources at www.wbrogden.com
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16483
    
    2

You have an org.xml.sax.Attributes object? See if it can be cast to org.xml.sax.ext.Attributes2. If it can, then there are methods to tell whether an attribute came from a DTD default. Read the API docs for Attributes2 for more information.
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
Unable to cast to Attributes2 am getting classcastException. Even I tried for Attributes2Impl. Please assist me how to proceed further
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
Any suggestions are welcome
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Parsing Problem
 
Similar Threads
Find index by xy ??
Attributes instanceof Attributes2 - Getting failed
Simple Name & Qualified Name
How to Creates more then one new context?
Color specifics words in a JTextPane