Package org.eclipse.persistence.oxm
Class XMLValidator
- java.lang.Object
-
- org.eclipse.persistence.oxm.XMLValidator
-
public class XMLValidator extends java.lang.ObjectClass used to validate XML. This is used to check if the XML created during a marshal operation would be valid XML before the marshal operation is performed.
Create an XMLValidator from an XMLContext.
Code Sample
XMLContext context = new XMLContext("mySessionName");
XMLValidator validator = context.createValidator();
The validateRoot method is used to validate objects which are mapped to global elements in a schema and which have a default root element specified in the TopLink project. The validate method is used to validate all other mapped objects.
- See Also:
XMLContext
-
-
Field Summary
Fields Modifier and Type Field Description static intDTD_VALIDATIONstatic intNONVALIDATINGstatic intSCHEMA_VALIDATION
-
Constructor Summary
Constructors Modifier Constructor Description protectedXMLValidator(XMLContext xmlContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.xml.sax.ErrorHandlergetErrorHandler()Get the error handler to be used during validationvoidsetErrorHandler(org.xml.sax.ErrorHandler handler)Set the error handler to be used during validationbooleanvalidate(java.lang.Object object)Validate the given object.booleanvalidateRoot(java.lang.Object rootObject)Validate the given root object.
-
-
-
Field Detail
-
NONVALIDATING
public static final int NONVALIDATING
- See Also:
- Constant Field Values
-
SCHEMA_VALIDATION
public static final int SCHEMA_VALIDATION
- See Also:
- Constant Field Values
-
DTD_VALIDATION
public static final int DTD_VALIDATION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
XMLValidator
protected XMLValidator(XMLContext xmlContext)
-
-
Method Detail
-
validateRoot
public boolean validateRoot(java.lang.Object rootObject) throws XMLMarshalExceptionValidate the given root object.- Parameters:
rootObject- A single root object to validate- Returns:
- true if this is a valid object, otherwise false
- Throws:
XMLMarshalException
-
validate
public boolean validate(java.lang.Object object) throws XMLMarshalExceptionValidate the given object.- Parameters:
object- A single object to validate- Returns:
- true if this is a valid object, otherwise false
- Throws:
XMLMarshalException
-
setErrorHandler
public void setErrorHandler(org.xml.sax.ErrorHandler handler)
Set the error handler to be used during validation- Parameters:
handler- the error handler to be used during validation
-
getErrorHandler
public org.xml.sax.ErrorHandler getErrorHandler()
Get the error handler to be used during validation- Returns:
- the error handler associated with this XMLValidator
-
-