Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: Advanced
May 27, 2008

Validate an XML Document Only When a DTD Exists

Learn how to use the DOMImplementationDS and DOMConfiguration classes to validate an XML document only when a DTD document can be found:

DOMImplementationLS DOMiLS=null;
?
  //get a LSParser object
  LSParser LSP=DOMiLS.createLSParser( 
               DOMImplementationLS.MODE_SYNCHRONOUS,                                     
               "http://www.w3.org/TR/REC-xml");      
  //get a DOMConfiguration object
  DOMConfiguration DOMc=LSP.getDomConfig();

  //use validate-if-schema option
  if(DOMc.canSetParameter("validate-if-schema",true))
     DOMc.setParameter("validate-if-schema",true);
        else System.out.println("Error...");
?
Leonard Anghel
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap