• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Non validating XML parser

 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic