com.adactus.mpeg21.xml.schema
Class ValidatingDocumentSource

java.lang.Object
  extended by com.adactus.mpeg21.xml.schema.ErrorHandlerImpl
      extended by com.adactus.mpeg21.xml.schema.DocumentSource
          extended by com.adactus.mpeg21.xml.schema.ValidatingDocumentSource
All Implemented Interfaces:
javolution.lang.Reusable, org.xml.sax.ErrorHandler
Direct Known Subclasses:
DigitalItemDeclarationsDocumentSource

public class ValidatingDocumentSource
extends DocumentSource

Create a w3c XML Document object using validation. Pattern:

1. DocumentBuilderFactory using a SchemaFactory
2. DocumentBuilder
3. Document

Any errors and warnings are printed during the parsing by using the ErrorHandler interface.


Constructor Summary
ValidatingDocumentSource(boolean xincludeAware)
          Create a validating document source.
 
Method Summary
 org.w3c.dom.ls.LSResourceResolver getResourceResolver()
           
 javax.xml.validation.Schema getSchema()
          Get the compiled schema
 void initFactory()
          Initialize DocumentBuilderFactory.
 void setResourceResolver(org.w3c.dom.ls.LSResourceResolver resourceResolver)
           
 void setSchema(java.lang.String[] urls)
           
 void setSchema(java.net.URL[] schema)
           
 void setSources(javax.xml.transform.Source[] sources)
           
 void validate(byte[] document, java.lang.String encoding)
           
 void validate(java.io.InputStream document, java.lang.String encoding)
           
 void validate(javax.xml.transform.Source source)
          Validate a document without building a document
Usage example:

validate(new SAXSource(new InputSource(inputstream)));
 void validate(java.lang.String document)
           
 
Methods inherited from class com.adactus.mpeg21.xml.schema.DocumentSource
getDocument, getDocument, getDocument, getDocument, getEntityResolver, initBuilder, newDocument, newInstance, recycle, setEntityResolver
 
Methods inherited from class com.adactus.mpeg21.xml.schema.ErrorHandlerImpl
error, fatalError, getStatus, reset, warning, wasError, wasFatalError, wasWaring
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidatingDocumentSource

public ValidatingDocumentSource(boolean xincludeAware)
Create a validating document source.

Parameters:
xincludeAware - XInclude enabled
Method Detail

getResourceResolver

public org.w3c.dom.ls.LSResourceResolver getResourceResolver()

getSchema

public javax.xml.validation.Schema getSchema()
Get the compiled schema

Returns:
the compiled schema

initFactory

public void initFactory()
                 throws java.lang.Exception
Description copied from class: DocumentSource
Initialize DocumentBuilderFactory.

Overrides:
initFactory in class DocumentSource
Throws:
java.lang.Exception

setResourceResolver

public void setResourceResolver(org.w3c.dom.ls.LSResourceResolver resourceResolver)

setSchema

public void setSchema(java.lang.String[] urls)
               throws java.io.IOException
Throws:
java.io.IOException

setSchema

public void setSchema(java.net.URL[] schema)
               throws java.io.IOException
Throws:
java.io.IOException

setSources

public void setSources(javax.xml.transform.Source[] sources)

validate

public void validate(byte[] document,
                     java.lang.String encoding)
              throws org.xml.sax.SAXException,
                     java.io.IOException
Throws:
org.xml.sax.SAXException
java.io.IOException

validate

public void validate(java.io.InputStream document,
                     java.lang.String encoding)
              throws org.xml.sax.SAXException,
                     java.io.IOException
Throws:
org.xml.sax.SAXException
java.io.IOException

validate

public void validate(javax.xml.transform.Source source)
              throws org.xml.sax.SAXException,
                     java.io.IOException
Validate a document without building a document
Usage example:

validate(new SAXSource(new InputSource(inputstream)));

Parameters:
source -
Throws:
org.xml.sax.SAXException
java.io.IOException

validate

public void validate(java.lang.String document)
              throws org.xml.sax.SAXException,
                     java.io.IOException
Throws:
org.xml.sax.SAXException
java.io.IOException