public Receiver getReceiver(Configuration config) throws SaxonApiException {
return getReceiver(config, null);
}
private Receiver getReceiver(Configuration config, String systemId) throws SaxonApiException {
PipelineConfiguration pipe = config.makePipelineConfiguration();
pipe.setExpandAttributeDefaults(expandAttributeDefaults);
Receiver output = (destination == null ? new Sink() : destination.getReceiver(config));
output.setPipelineConfiguration(pipe);
int topLevelElement = -1;
if (documentElementName != null) {
topLevelElement = config.getNamePool().allocate(
"", documentElementName.getNamespaceURI(), documentElementName.getLocalName());
}
Receiver receiver = config.getDocumentValidator(
output,
systemId,
(lax ? Validation.LAX : Validation.STRICT) | Validation.VALIDATE_OUTPUT,
Whitespace.NONE,
documentElementType,
topLevelElement);
if (errorListener != null) {
pipe.setErrorListener(errorListener);
}
return receiver;
}