org.objectledge.xml
Class XMLValidator

java.lang.Object
  extended by org.objectledge.xml.XMLValidator

public class XMLValidator
extends Object

Validates XML files against schemata using MSV library.

The primary schema language used throughout ObjectLedge project is RelaxNG, but the MSV library determines the schema languague using XML namespace of the top level element. At the moment XML based schema languages supported by MSV and thus by XMLValidator are RelaxNG, W3C XSD, and others.

Version:
$Id: XMLValidator.java,v 1.10 2004/06/01 11:13:11 zwierzem Exp $
Author:
Rafal Krzewski, Damian Gajda

Field Summary
private  ExceptionErrorHandler errorHandler
           
private  XMLGrammarCache grammarCache
           
static String RELAXNG_SCHEMA
          Pathname of the relaxng schema.
private  SAXParser saxParser
           
 
Constructor Summary
XMLValidator(XMLGrammarCache grammarCache)
          Creates a new instance of the validator.
 
Method Summary
 com.sun.msv.verifier.Verifier getVerifier(URL schemaUrl)
          Returns a thread-exclusive verifier instance.
 void validate(URL fileUrl, URL schemaUrl)
          Validates given XML file using specified schema.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

grammarCache

private XMLGrammarCache grammarCache

saxParser

private SAXParser saxParser

errorHandler

private ExceptionErrorHandler errorHandler

RELAXNG_SCHEMA

public static final String RELAXNG_SCHEMA
Pathname of the relaxng schema.

See Also:
Constant Field Values
Constructor Detail

XMLValidator

public XMLValidator(XMLGrammarCache grammarCache)
             throws ParserConfigurationException,
                    SAXException
Creates a new instance of the validator.

Parameters:
grammarCache - system grammar cache for retrieving grammars used for validation
Throws:
ParserConfigurationException - if the JAXP parser factory is misconfigured.
SAXException - if the JAXP parser factory is misconfigured.
Method Detail

validate

public void validate(URL fileUrl,
                     URL schemaUrl)
              throws SAXException,
                     ParserConfigurationException,
                     IOException
Validates given XML file using specified schema.

Parameters:
fileUrl - the URL of the file to be validated.
schemaUrl - the URL of the schema to be used.
Throws:
ParserConfigurationException - if parser is badly configured.
IOException - if the schema does not exist.
SAXException - if the schema is malformed.

getVerifier

public com.sun.msv.verifier.Verifier getVerifier(URL schemaUrl)
                                          throws SAXException,
                                                 ParserConfigurationException,
                                                 IOException
Returns a thread-exclusive verifier instance.

Parameters:
schemaUrl - the URL of the schema to be used.
Returns:
a thread-exclusive verifier instance.
Throws:
ParserConfigurationException - if parser is badly configured.
IOException - if the schema does not exist.
SAXException - if the schema is malformed.


Copyright © 2003-2006 objectledge.org. All Rights Reserved.