public void doTag()

in jelly-tags/validate/src/main/java/org/apache/commons/jelly/tags/validate/ValidateTag.java [52:111]


    public void doTag(final XMLOutput output) throws MissingAttributeException, JellyTagException {
        if ( verifier == null ) {
            throw new MissingAttributeException("verifier");
        }
        boolean valid = false;

        // evaluate the body using the current Verifier
        if ( errorHandler != null ) {

            try {
                // we are redirecting errors to another handler
                // so just filter the body
                VerifierFilter filter = verifier.getVerifierFilter();

                // now install the current output in the filter chain...
                // ####

                ContentHandler handler = filter.getContentHandler();
                handler.startDocument();
                invokeBody( new XMLOutput( handler ) );
                handler.endDocument();
                valid = filter.isValid();
            }
            catch (SAXException e) {
                throw new JellyTagException(e);
            }
        }
        else {
            // outputting the errors to the current output
            verifier.setErrorHandler(
                new ErrorHandler() {
                    @Override
                    public void error(SAXParseException exception) throws SAXException {
                        outputException(output, "error", exception);
                    }

                    @Override
                    public void fatalError(SAXParseException exception) throws SAXException {
                        outputException(output, "fatalError", exception);
                    }

                    public void warning(SAXParseException exception) throws SAXException {
                        outputException(output, "warning", exception);
                    }
                }
            );

            try {
                VerifierHandler handler = verifier.getVerifierHandler();
                handler.startDocument();
                invokeBody( new XMLOutput( handler ) );
                handler.endDocument();
                valid = handler.isValid();
            }
            catch (SAXException e) {
                throw new JellyTagException(e);
            }
        }
        handleValid(valid);
    }