org.apache.commons.jelly.tags.validate
Class ValidateTag

java.lang.Object
  extended byorg.apache.commons.jelly.TagSupport
      extended byorg.apache.commons.jelly.tags.validate.ValidateTag
All Implemented Interfaces:
org.apache.commons.jelly.Tag
Direct Known Subclasses:
AssertValidTag

public class ValidateTag
extends org.apache.commons.jelly.TagSupport

This tag validates its body using a schema Verifier which can validate against DTDs, XML Schema, RelaxNG, Relax or TREX. Any JARV compliant Verifier could be used. The error messages are output as XML events so that they can be styled by the parent tag.

Version:
$Revision: 155420 $
Author:
James Strachan

Field Summary
 
Fields inherited from class org.apache.commons.jelly.TagSupport
body, context, hasTrimmed, parent, shouldTrim
 
Constructor Summary
ValidateTag()
           
 
Method Summary
 void doTag(org.apache.commons.jelly.XMLOutput output)
           
 org.xml.sax.ErrorHandler getErrorHandler()
           
protected  void handleValid(boolean valid)
          Processes whether or not the document is valid.
protected  void outputException(org.apache.commons.jelly.XMLOutput output, java.lang.String name, org.xml.sax.SAXParseException e)
          Outputs the given validation exception as XML to the output
 void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
          Sets the SAX ErrorHandler which is used to capture XML validation events.
 void setVar(java.lang.String var)
          Sets the name of the variable that will contain a boolean flag for whether or not the XML is valid.
 void setVerifier(org.iso_relax.verifier.Verifier verifier)
          Sets the schema Verifier that this tag will use to verify its body
 
Methods inherited from class org.apache.commons.jelly.TagSupport
findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, getBody, getBodyText, getBodyText, getContext, getParent, invokeBody, isEscapeText, isTrim, setBody, setContext, setEscapeText, setParent, setTrim, trimBody
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ValidateTag

public ValidateTag()
Method Detail

doTag

public void doTag(org.apache.commons.jelly.XMLOutput output)
           throws org.apache.commons.jelly.MissingAttributeException,
                  org.apache.commons.jelly.JellyTagException
Throws:
org.apache.commons.jelly.MissingAttributeException
org.apache.commons.jelly.JellyTagException

setVerifier

public void setVerifier(org.iso_relax.verifier.Verifier verifier)
Sets the schema Verifier that this tag will use to verify its body


getErrorHandler

public org.xml.sax.ErrorHandler getErrorHandler()
Returns:
the ErrorHandler used when validating

setErrorHandler

public void setErrorHandler(org.xml.sax.ErrorHandler errorHandler)
Sets the SAX ErrorHandler which is used to capture XML validation events. If an ErrorHandler is specified then this tag will output its body and redirect all error messages to the ErrorHandler. If no ErrorHandler is specified then this tag will just output the error messages as XML events


setVar

public void setVar(java.lang.String var)
Sets the name of the variable that will contain a boolean flag for whether or not the XML is valid.


handleValid

protected void handleValid(boolean valid)
Processes whether or not the document is valid. Derived classes can overload this method to do different things, such as to throw assertion exceptions etc.


outputException

protected void outputException(org.apache.commons.jelly.XMLOutput output,
                               java.lang.String name,
                               org.xml.sax.SAXParseException e)
                        throws org.xml.sax.SAXException
Outputs the given validation exception as XML to the output

Throws:
org.xml.sax.SAXException


Copyright © 2002-2006 Apache Software Foundation. All Rights Reserved.