• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Validation against DTD using DOM (Xerces 2)

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can I get the Xerces 2 (1.1.4) DOM parser to validate against a local DTD? When I run my basic test app, it does not throw any exceptions when running through an xml that contains elements not described in the DTD, therefore no validation is occuring.
The closest thing I found on forums was here, which does not work, reference the parser.setFeature(...) method. I was confused by this anyway since this is a SAX call. Other similar forum posts were not answered or had bad links.
(Note that the DTD is structured properly and is successfully loaded by the XML file being parsed. To be sure, I renamed/moved the DTD, which threw an exception on debug when parsing, proving the DTD was originally being loaded)
code snippet:

I did recall using setValidating(boolean) method on an older DOM parser implementation (XML4J, I think). I didn't find anything equivalent to it in Xerces 1.1.4
Thanks in advance.
---
[ October 17, 2002: Message edited by: Toby Davis ]
 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The tutorial at IBM http://www-105.ibm.com/developerworks/education.nsf/dw/xml-onlinecourse-bytitle?OpenDocument&Count=500
may help you.

See the tutorial validating XML,schema validatin etc(at the bottom of the page).
 
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See your answer with code here:
http://www.jguru.com/forums/view.jsp?EID=1008182
[ October 17, 2002: Message edited by: Roseanne Zhang ]
 
Toby Davis
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Now it follows the validation parameters set in my DTD, as I wanted originally. Thanks again!
---
[ October 17, 2002: Message edited by: Toby Davis ]
 
We noticed he had no friends. So we gave him this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic