private ValidatorHandler getValidator() throws SAXException {
        ValidatorHandler validatorHandler = null;

        if (schemaValidation && schemaPool != null) {
            // Put back the old schema if we need to.
            returnCurrentSchema();

            sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
            sb.append("<xsd:schema xmlns:xsd=\"");
            sb.append(schemaLanguage);
            sb.append("\"");
            final CharBuffer namespaces = new CharBuffer(100);
            final CharBuffer locations = new CharBuffer(100);
            for (final String prefix : prefixes.keySet()) {
                final String namespace = prefixes.get(prefix);
                final String location = schemaLocations.get(namespace);
                if (location != null) {
                    namespaces.append(" xmlns");
                    if (!prefix.isEmpty()) {
                        namespaces.append(":");
                        namespaces.append(prefix);
                    }
                    namespaces.append("=\"");
                    namespaces.append(namespace);
                    namespaces.append("\"");

                    locations.append("<xsd:import namespace=\"");
                    locations.append(namespace);
                    locations.append("\" schemaLocation=\"");
                    locations.append(location);
                    locations.append("\"/>\n");
                }
            }
            sb.append(namespaces.toString());
            sb.append(">\n");
            sb.append(locations.toString());
            sb.append("</xsd:schema>");

            final String data = sb.toString();
            sb.clear();

            // Get another schema.
            final SchemaKey schemaKey = new SchemaKey(schemaLanguage, data, schemaConstraint);
            poolItem = schemaPool.borrowObject(schemaKey, true);
            final StoredSchema storedSchema = poolItem.getValue();

            // Replay errors generated when creating schema.
            try {
                for (final StoredError storedError : storedSchema.getErrorReceiver().getList()) {
                    errorReceiverProxy.log(storedError.getSeverity(),
                            locationFactory.create(1, 1),
                            getElementId(),
                            storedError.toString(),
                            null);
                }
            } catch (final RuntimeException e) {
                errorHandler.fatalError(new SAXParseException(e.getMessage(), null));
            }

            // Create a validator handler.
            final Schema schema = storedSchema.getSchema();
            if (schema != null) {
                validatorHandler = schema.newValidatorHandler();
                validatorHandler.setDocumentLocator(locator);
                validatorHandler.setErrorHandler(errorHandler);

                validatorHandler.startDocument();
                for (final String prefix : prefixes.keySet()) {
                    validatorHandler.startPrefixMapping(prefix, prefixes.get(prefix));
                }
            }
        }

        return validatorHandler;
    }
Sends characters to the current validator handler.

@param ch     Characters.
@param start  Start of char buffer.
@param length Number of chars to send.
@throws SAXException Not thrown.
@see stroom.pipeline.filter.AbstractXMLFilter#characters(char[],
int, int)
stroom-pipeline/src/main/java/stroom/pipeline/filter/SchemaFilter.java