• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

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: 27366
88
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?
 
Look! I laid an egg! Why does it smell like that? Tiny ad, does this smell weird to you?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic