public Sequence<?> call(XPathContext context, Sequence[] arguments) throws XPathException { NodeInfo xml = (NodeInfo) arguments[0].head(); if (xml == null) { return EmptySequence.getInstance(); } boolean indent = false; if (getArity() > 1) { MapItem suppliedOptions = (MapItem) arguments[1].head(); Map<String, Sequence<?>> options = getDetails().optionDetails.processSuppliedOptions(suppliedOptions, context); indent = ((BooleanValue)options.get("indent").head()).getBooleanValue(); } PipelineConfiguration pipe = context.getController().makePipelineConfiguration(); pipe.setXPathContext(context); JsonReceiver receiver = new JsonReceiver(pipe); receiver.setIndenting(indent); Receiver r = receiver; if (xml.getNodeKind() == Type.DOCUMENT) { r = new DocumentValidator(r, "FOJS0006"); } StartTagBuffer stb = new StartTagBuffer(r); pipe.setComponent(StartTagBuffer.class.getName(), stb); stb.setPipelineConfiguration(pipe); stb.open(); xml.copy(stb, 0, ExplicitLocation.UNKNOWN_LOCATION); stb.close(); return new StringValue(receiver.getJsonString()); }
public Sequence<?> call(XPathContext context, Sequence[] arguments) throws XPathException { NodeInfo xml = (NodeInfo) arguments[0].head(); if (xml == null) { return EmptySequence.getInstance(); } boolean indent = false; if (getArity() > 1) { MapItem suppliedOptions = (MapItem) arguments[1].head(); Map<String, Sequence<?>> options = getDetails().optionDetails.processSuppliedOptions(suppliedOptions, context); indent = ((BooleanValue)options.get("indent").head()).getBooleanValue(); } PipelineConfiguration pipe = context.getController().makePipelineConfiguration(); pipe.setXPathContext(context); JsonReceiver receiver = new JsonReceiver(pipe); receiver.setIndenting(indent); Receiver r = receiver; if (xml.getNodeKind() == Type.DOCUMENT) { r = new DocumentValidator(r, "FOJS0006"); } StartTagBuffer stb = new StartTagBuffer(r); pipe.setComponent(StartTagBuffer.class.getName(), stb); stb.setPipelineConfiguration(pipe); stb.open(); xml.copy(stb, 0, ExplicitLocation.UNKNOWN_LOCATION); stb.close(); return new StringValue(receiver.getJsonString()); }
/** * Create a TemplatesHandlerImpl and initialise variables. The constructor is protected, because * the Filter should be created using newTemplatesHandler() in the SAXTransformerFactory * class * * @param processor the Saxon s9api processor */ protected TemplatesHandlerImpl(Processor processor) { this.processor = processor; Configuration config = processor.getUnderlyingConfiguration(); setPipelineConfiguration(config.makePipelineConfiguration()); CompilerInfo info = new CompilerInfo(config.getDefaultXsltCompilerInfo()); Compilation compilation = new Compilation(config, info); nodeFactory = compilation.getStyleNodeFactory(true); builder = new LinkedTreeBuilder(getPipelineConfiguration()); builder.setNodeFactory(nodeFactory); builder.setLineNumbering(true); UseWhenFilter useWhenFilter = new UseWhenFilter(compilation, builder, NestedIntegerValue.TWO); StartTagBuffer startTagBuffer = new StartTagBuffer(useWhenFilter); useWhenFilter.setStartTagBuffer(startTagBuffer); StylesheetSpaceStrippingRule rule = new StylesheetSpaceStrippingRule(config.getNamePool()); Stripper styleStripper = new Stripper(rule, startTagBuffer); CommentStripper commentStripper = new CommentStripper(styleStripper); setReceiver(commentStripper); }
/** * Create a TemplatesHandlerImpl and initialise variables. The constructor is protected, because * the Filter should be created using newTemplatesHandler() in the SAXTransformerFactory * class * * @param processor the Saxon s9api processor */ protected TemplatesHandlerImpl(Processor processor) { this.processor = processor; Configuration config = processor.getUnderlyingConfiguration(); setPipelineConfiguration(config.makePipelineConfiguration()); CompilerInfo info = new CompilerInfo(config.getDefaultXsltCompilerInfo()); Compilation compilation = new Compilation(config, info); nodeFactory = compilation.getStyleNodeFactory(true); builder = new LinkedTreeBuilder(getPipelineConfiguration()); builder.setNodeFactory(nodeFactory); builder.setLineNumbering(true); UseWhenFilter useWhenFilter = new UseWhenFilter(compilation, builder, NestedIntegerValue.TWO); StartTagBuffer startTagBuffer = new StartTagBuffer(useWhenFilter); useWhenFilter.setStartTagBuffer(startTagBuffer); StylesheetSpaceStrippingRule rule = new StylesheetSpaceStrippingRule(config.getNamePool()); Stripper styleStripper = new Stripper(rule, startTagBuffer); CommentStripper commentStripper = new CommentStripper(styleStripper); setReceiver(commentStripper); }
/** * Create a TemplatesHandlerImpl and initialise variables. The constructor is protected, because * the Filter should be created using newTemplatesHandler() in the SAXTransformerFactory * class * @param config the Saxon configuration */ protected TemplatesHandlerImpl(Configuration config) { setPipelineConfiguration(config.makePipelineConfiguration()); nodeFactory = new StyleNodeFactory(config, getPipelineConfiguration().getErrorListener()); builder = new TreeBuilder(); builder.setPipelineConfiguration(getPipelineConfiguration()); builder.setNodeFactory(nodeFactory); builder.setLineNumbering(true); StartTagBuffer startTagBuffer = new StartTagBuffer(); UseWhenFilter useWhenFilter = new UseWhenFilter(startTagBuffer); useWhenFilter.setUnderlyingReceiver(builder); useWhenFilter.setPipelineConfiguration(getPipelineConfiguration()); startTagBuffer.setUnderlyingReceiver(useWhenFilter); startTagBuffer.setPipelineConfiguration(getPipelineConfiguration()); StylesheetStripper styleStripper = new StylesheetStripper(); styleStripper.setUnderlyingReceiver(startTagBuffer); styleStripper.setPipelineConfiguration(getPipelineConfiguration()); CommentStripper commentStripper = new CommentStripper(); commentStripper.setUnderlyingReceiver(styleStripper); commentStripper.setPipelineConfiguration(getPipelineConfiguration()); setReceiver(commentStripper); }
StartTagBuffer startTagBuffer = new StartTagBuffer(useWhenFilter); useWhenFilter.setStartTagBuffer(startTagBuffer);
/** * Create a TemplatesHandlerImpl and initialise variables. The constructor is protected, because * the Filter should be created using newTemplatesHandler() in the SAXTransformerFactory * class * @param config the Saxon configuration */ protected TemplatesHandlerImpl(Configuration config) { setPipelineConfiguration(config.makePipelineConfiguration()); nodeFactory = new StyleNodeFactory(config, getPipelineConfiguration().getErrorListener()); builder = new TreeBuilder(); builder.setPipelineConfiguration(getPipelineConfiguration()); builder.setNodeFactory(nodeFactory); builder.setLineNumbering(true); StartTagBuffer startTagBuffer = new StartTagBuffer(); UseWhenFilter useWhenFilter = new UseWhenFilter(startTagBuffer); useWhenFilter.setUnderlyingReceiver(builder); useWhenFilter.setPipelineConfiguration(getPipelineConfiguration()); startTagBuffer.setUnderlyingReceiver(useWhenFilter); startTagBuffer.setPipelineConfiguration(getPipelineConfiguration()); StylesheetStripper styleStripper = new StylesheetStripper(); styleStripper.setStylesheetRules(config.getNamePool()); styleStripper.setUnderlyingReceiver(startTagBuffer); styleStripper.setPipelineConfiguration(getPipelineConfiguration()); CommentStripper commentStripper = new CommentStripper(); commentStripper.setUnderlyingReceiver(styleStripper); commentStripper.setPipelineConfiguration(getPipelineConfiguration()); setReceiver(commentStripper); }
StartTagBuffer startTagBuffer = new StartTagBuffer(useWhenFilter); useWhenFilter.setStartTagBuffer(startTagBuffer);
styleBuilder.setLineNumbering(true); StartTagBuffer startTagBuffer = new StartTagBuffer();
styleBuilder.setLineNumbering(true); StartTagBuffer startTagBuffer = new StartTagBuffer();
StartTagBuffer startTagBuffer = new StartTagBuffer(useWhenFilter); useWhenFilter.setStartTagBuffer(startTagBuffer);
StartTagBuffer startTagBuffer = new StartTagBuffer(useWhenFilter); useWhenFilter.setStartTagBuffer(startTagBuffer);