This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parsing Problem

 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48406
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Too difficult a question for beginners'. Moving.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13056
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paul Clapham
Sheriff
Pie
Posts: 20758
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unable to cast to Attributes2 am getting classcastException. Even I tried for Attributes2Impl. Please assist me how to proceed further
 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any suggestions are welcome
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic