Package org.xwiki.validator.framework
Class AbstractXMLValidator
- java.lang.Object
-
- org.xwiki.validator.framework.AbstractXMLValidator
-
- All Implemented Interfaces:
Validator
- Direct Known Subclasses:
AbstractHTML5Validator
,RSSValidator
public abstract class AbstractXMLValidator extends Object implements Validator
XML based standard validator.- Version:
- $Id: cd50cb47400f0a6ffc568879cfbc7d293ad4f033 $
-
-
Field Summary
Fields Modifier and Type Field Description protected Document
document
Document to be validated.protected DocumentBuilder
documentBuilder
XML document builder.protected XMLErrorHandler
errorHandler
Error handler.
-
Constructor Summary
Constructors Constructor Description AbstractXMLValidator()
Constructor.AbstractXMLValidator(boolean validateXML)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addError(ValidationError.Type errorType, int line, int column, String message)
Add an error message to the list.void
clear()
Clear the validator errors.protected XMLErrorHandler
createXMLErrorHandler()
Document
getDocument()
protected XMLErrorHandler
getErrorHandler()
List<ValidationError>
getErrors()
Get the list of validation errors.void
setDocument(InputStream document)
Set document to validate.void
setValidateXML(boolean validateXML)
List<ValidationError>
validate()
Run validation.protected void
validate(Document document)
-
-
-
Field Detail
-
document
protected Document document
Document to be validated.
-
errorHandler
protected XMLErrorHandler errorHandler
Error handler.
-
documentBuilder
protected DocumentBuilder documentBuilder
XML document builder.
-
-
Method Detail
-
createXMLErrorHandler
protected XMLErrorHandler createXMLErrorHandler()
- Returns:
- the error handler to use when parsing the xml content
-
setValidateXML
public void setValidateXML(boolean validateXML)
- Parameters:
validateXML
- indicate if the XML input should be validated.
-
setDocument
public void setDocument(InputStream document)
Description copied from interface:Validator
Set document to validate.- Specified by:
setDocument
in interfaceValidator
- Parameters:
document
- document to validate
-
validate
public List<ValidationError> validate()
Description copied from interface:Validator
Run validation.
-
validate
protected void validate(Document document)
- Parameters:
document
- the XML document
-
getErrors
public List<ValidationError> getErrors()
Description copied from interface:Validator
Get the list of validation errors.
-
getDocument
public Document getDocument()
- Returns:
- the XML document
-
getErrorHandler
protected XMLErrorHandler getErrorHandler()
- Returns:
- the XML error handler
-
addError
protected void addError(ValidationError.Type errorType, int line, int column, String message)
Add an error message to the list.- Parameters:
errorType
- type of the errorline
- line where the error occurredcolumn
- where the error occurredmessage
- the message to add
-
-