/** * Get a TransformerHandler object that can process SAX * ContentHandler events into a Result. The transformation * is defined as an identity (or copy) transformation, for example * to copy a series of SAX parse events into a DOM tree. * * @return A non-null reference to a TransformerHandler, that may * be used as a ContentHandler for SAX parse events. * * @throws TransformerConfigurationException If for some reason the * TransformerHandler cannot be created. */ public TransformerHandler newTransformerHandler() throws TransformerConfigurationException { Controller controller = new IdentityTransformer(config); return new IdentityTransformerHandler(controller); }
/** * Create a IdentityTransformerHandler and initialise variables. The constructor is protected, because * the Filter should be created using newTransformerHandler() in the SAXTransformerFactory * class * @param controller the Controller for this transformation */ protected IdentityTransformerHandler(Controller controller) { this.controller = controller; setPipelineConfiguration(controller.makePipelineConfiguration()); }
/** * Override the behaviour of startDocument() in ReceivingContentHandler */ public void startDocument() throws SAXException { if (result==null) { result = new StreamResult(System.out); } try { Properties props = controller.getOutputProperties(); PipelineConfiguration pipe = controller.makePipelineConfiguration(); SerializerFactory sf = getConfiguration().getSerializerFactory(); setReceiver(sf.getReceiver(result, pipe, props)); setPipelineConfiguration(pipe); } catch (XPathException err) { throw new SAXException(err); } super.startDocument(); }
/** * Override the behaviour of startDocument() in ReceivingContentHandler */ public void startDocument() throws SAXException { if (result==null) { result = new StreamResult(System.out); } try { Properties props = controller.getOutputProperties(); PipelineConfiguration pipe = controller.makePipelineConfiguration(); Configuration config = getConfiguration(); SerializerFactory sf = config.getSerializerFactory(); Receiver out = sf.getReceiver(result, pipe, props); setPipelineConfiguration(pipe); int stripSpace = config.getStripsWhiteSpace(); if (stripSpace == Whitespace.ALL) { Stripper s = new AllElementStripper(); s.setStripAll(); s.setPipelineConfiguration(pipe); s.setUnderlyingReceiver(out); out = s; } setReceiver(out); } catch (XPathException err) { throw new SAXException(err); } super.startDocument(); }
/** * Create a IdentityTransformerHandler and initialise variables. The constructor is protected, because * the Filter should be created using newTransformerHandler() in the SAXTransformerFactory * class * @param controller the Controller for this transformation */ protected IdentityTransformerHandler(Controller controller) { this.controller = controller; setPipelineConfiguration(controller.makePipelineConfiguration()); }
/** * Get a TransformerHandler object that can process SAX * ContentHandler events into a Result. The transformation * is defined as an identity (or copy) transformation, for example * to copy a series of SAX parse events into a DOM tree. * * @return A non-null reference to a TransformerHandler, that may * be used as a ContentHandler for SAX parse events. * * @throws TransformerConfigurationException If for some reason the * TransformerHandler cannot be created. */ public TransformerHandler newTransformerHandler() throws TransformerConfigurationException { Controller controller = new IdentityTransformer(config); return new IdentityTransformerHandler(controller); }