dk.brics.dsd
Class Validator

java.lang.Object
  |
  +--dk.brics.dsd.Validator

public class Validator
extends Object

DSD 2.0 validator.

Author:
Anders Møller <amoeller@brics.dk>

Constructor Summary
Validator(ValidationErrorHandler handler)
          Constructs a new DSD 2.0 validator.
 
Method Summary
static String findDSDref(Document doc)
          Finds DSD processing instruction in XML document.
static Document makeDocument(String str, URL context)
          Builds an XML document from a String and expands XInclude instructions.
static Document makeDocument(URL url)
          Retrieves an XML document from a URL and expands XInclude instructions.
 Document process(Document app, Schema dsd)
          Processes an XML document with a DSD 2.0 schema.
 Document process(Document app, Schema dsd, boolean weak)
          Processes an XML document with a DSD 2.0 schema.
 void process(Graph sg, Schema dsd)
          Processes a JWIG summary graph with a DSD 2.0 schema.
 void setRepeatMin(boolean enable)
          Sets repeat-min flag.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Validator

public Validator(ValidationErrorHandler handler)
Constructs a new DSD 2.0 validator.

Parameters:
handler - validation error handler
Method Detail

findDSDref

public static String findDSDref(Document doc)
Finds DSD processing instruction in XML document.

Parameters:
doc - XML document
Returns:
DSD reference URL, or null if not found

makeDocument

public static Document makeDocument(String str,
                                    URL context)
                             throws JDOMException,
                                    MalformedURLException
Builds an XML document from a String and expands XInclude instructions.

Parameters:
str - XML document
context - URL context for resolving relative URLs (null if none)
Returns:
XML document
Throws:
JDOMException - if an error occured during JDOM parsing or XInclude expansion
MalformedURLException - if a malformed URL appears in an XInclude instruction

makeDocument

public static Document makeDocument(URL url)
                             throws JDOMException,
                                    MalformedURLException
Retrieves an XML document from a URL and expands XInclude instructions.

Parameters:
url - URL of XML document
Returns:
XML document
Throws:
JDOMException - if an error occured during JDOM parsing or XInclude expansion
MalformedURLException - if a malformed URL appears in an XInclude instruction

process

public Document process(Document app,
                        Schema dsd)
                 throws SchemaErrorException
Processes an XML document with a DSD 2.0 schema. It is assumed that XInclude expansion has been performed on the input documents. The validation error handler is invoked if validation errors are detected.

Parameters:
app - application document to be validated
dsd - DSD schema document
Returns:
the normalized application document, containing error elements if not valid
Throws:
SchemaErrorException - if a fatal error in the DSD is encountered

process

public Document process(Document app,
                        Schema dsd,
                        boolean weak)
                 throws SchemaErrorException
Processes an XML document with a DSD 2.0 schema. It is assumed that XInclude expansion has been performed on the input documents. The validation error handler is invoked if validation errors are detected.

Parameters:
app - application document to be validated
dsd - DSD schema document
weak - if true, omit uniqueness and pointer checking
Returns:
the normalized application document, containing error elements if not valid
Throws:
SchemaErrorException - if a fatal error in the DSD is encountered

process

public void process(Graph sg,
                    Schema dsd)
             throws SchemaErrorException
Processes a JWIG summary graph with a DSD 2.0 schema. It is assumed that XInclude expansion has been performed on the input documents. The validation error handler is invoked if validation errors are detected.

Parameters:
sg - summary graph to be validated
dsd - DSD schema document
Throws:
SchemaErrorException - if a fatal error in the DSD is encountered

setRepeatMin

public void setRepeatMin(boolean enable)
Sets repeat-min flag. If set, <repeat min="1"> is treated as <repeat min="0"> in summary graph mode. Default: false.



Copyright © 2002 Anders Møller.