* module
*/
public DocumentImpl loadStylesheetModule(Source styleSource, StyleNodeFactory nodeFactory)
throws XPathException {
TreeBuilder styleBuilder = new TreeBuilder();
PipelineConfiguration pipe = config.makePipelineConfiguration();
pipe.setURIResolver(uriResolver);
styleBuilder.setPipelineConfiguration(pipe);
styleBuilder.setSystemId(styleSource.getSystemId());
styleBuilder.setNodeFactory(nodeFactory);
styleBuilder.setLineNumbering(true);
StartTagBuffer startTagBuffer = new StartTagBuffer();
UseWhenFilter useWhenFilter = new UseWhenFilter(startTagBuffer);
useWhenFilter.setUnderlyingReceiver(styleBuilder);
startTagBuffer.setUnderlyingReceiver(useWhenFilter);
StylesheetStripper styleStripper = new StylesheetStripper();
styleStripper.setUnderlyingReceiver(startTagBuffer);
CommentStripper commentStripper = new CommentStripper();
commentStripper.setUnderlyingReceiver(styleStripper);
// build the stylesheet document
DocumentImpl doc;
Sender sender = new Sender(pipe);
AugmentedSource aug = AugmentedSource.makeAugmentedSource(styleSource);
aug.setSchemaValidationMode(Validation.STRIP);
aug.setDTDValidationMode(Validation.STRIP);
aug.setLineNumbering(true);
if (aug.getXMLReader() == null && Configuration.getPlatform().isJava()) {
XMLReader styleParser = config.getStyleParser();
aug.setXMLReader(styleParser);
sender.send(aug, commentStripper);
config.reuseStyleParser(styleParser);
} else {
sender.send(aug, commentStripper);
}
doc = (DocumentImpl)styleBuilder.getCurrentRoot();
styleBuilder.reset();
if (aug.isPleaseCloseAfterUse()) {
aug.close();
}