Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Non validating XML parser  RSS feed

 
dema rogatkin
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use xpath to parse web.xml. However I noticed that if some validation source isn't available or fails, then my parsing fails as well. For example:

Is any way to turn off validation features of XML parser and ignore all schemas?
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both the DocumentBuilderFactory and the SAXParserFactory have setValidating(boolean) methods. However their default is "false", so I would have thought non-validating would be the default. Maybe there's some other possible reason for your failures? Or maybe you're using some other parser factory, since you say you're using XPath to parse.
 
Reid M. Pinchback
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another wrinkle in this is the difference between validation and entity resolution. Even if you turn off validation, most parsers will still attempt entity resolution. You can have things fail at that point too, or at least experience some performance drag. setValidating(false) has no impact on entity resolution. With some parser APIs (e.g. SAX) you can provide your own entity resolver to basically force it to shut up. You can see an example of this by looking at the source code for Digester.
 
dema rogatkin
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the responses. Generally I use XPathFactory and I do not see any methods for switching validation. Here is a method as setFeature(name,bool), however I do not see where I can get lists of supported features (checked XMLConstants), and is there feature responsible for validating?
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!