/** * javax.xml.transform.sax.TransformerFactory implementation. * Create a Transformer object that copies the input document to the result. * * @return A Transformer object that simply copies the source to the result. * @throws TransformerConfigurationException */ public Transformer newTransformer() throws TransformerConfigurationException { TransformerImpl result = new TransformerImpl(new Properties(), _indentNumber, this); if (_uriResolver != null) { result.setURIResolver(_uriResolver); } if (_isSecureProcessing) { result.setSecureProcessing(true); } return result; }
protected TransformerImpl(Translet translet, Properties outputProperties, int indentNumber, TransformerFactoryImpl tfactory) { _translet = (AbstractTranslet) translet; _properties = createOutputProperties(outputProperties); _propertiesClone = (Properties) _properties.clone(); _indentNumber = indentNumber; _tfactory = tfactory; //_isIncremental = tfactory._incremental; }
/** * This class wraps an ErrorListener into a MessageHandler in order to * capture messages reported via xsl:message. */ static class MessageHandler extends org.apache.xalan.xsltc.runtime.MessageHandler { private ErrorListener _errorListener; public MessageHandler(ErrorListener errorListener) { _errorListener = errorListener; } public void displayMessage(String msg) { if(_errorListener == null) { System.err.println(msg); } else { try { _errorListener.warning(new TransformerException(msg)); } catch (TransformerException e) { // ignored } } } }
/** * Cosntructor - pass in reference to a TransformerImpl object */ public TransformerHandlerImpl(TransformerImpl transformer) { // Save the reference to the transformer _transformer = transformer; if (transformer.isIdentity()) { // Set initial handler to the empty handler _handler = new DefaultHandler(); _isIdentity = true; } else { // Get a reference to the translet wrapped inside the transformer _translet = _transformer.getTranslet(); } }
/** * Implements org.xml.sax.ContentHandler.endDocument() * Receive notification of the end of a document. */ public void endDocument() throws SAXException { // Signal to the DOMBuilder that the document is complete _handler.endDocument(); if (!_isIdentity) { // Run the transformation now if we have a reference to a Result object if (_result != null) { try { _transformer.setDOM(_dom); _transformer.transform(null, _result); } catch (TransformerException e) { throw new SAXException(e); } } // Signal that the internal DOM is built (see 'setResult()'). _done = true; // Set this DOM as the transformer's DOM _transformer.setDOM(_dom); } if (_isIdentity && _result instanceof DOMResult) { ((DOMResult)_result).setNode(_transformer.getTransletOutputHandlerFactory().getNode()); } }
_transformer.getOutputHandler(result); _transformer.transferOutputProperties(outputHandler); _transformer.setDOM(_dom); _transformer.transform(null, _result);
transferOutputProperties(_translet); final SerializationHandler toHandler = getOutputHandler(result); if (toHandler == null) { ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_NO_HANDLER_ERR); transferOutputProperties(toHandler); transform(source, toHandler, _encoding);
if (isDefaultProperty(name, properties)) continue; if (validOutputProperty(name)) { _properties.setProperty(name, properties.getProperty(name));
StreamSource streamSource = new StreamSource( SystemIDResolver.getAbsoluteURI(href, baseURI)); return getDOM(streamSource) ; return getDOM(resolvedSource); postErrorToListener("File not found: " + e.getMessage()); return(null);
private void createParent() throws SAXException { XMLReader parent = null; try { SAXParserFactory pfactory = SAXParserFactory.newInstance(); pfactory.setNamespaceAware(true); if (_transformer.isSecureProcessing()) { try { pfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); } catch (SAXException e) {} } SAXParser saxparser = pfactory.newSAXParser(); parent = saxparser.getXMLReader(); } catch (ParserConfigurationException e) { throw new SAXException(e); } catch (FactoryConfigurationError e) { throw new SAXException(e.toString()); } if (parent == null) { parent = XMLReaderFactory.createXMLReader(); } // make this XMLReader the parent of this filter setParent(parent); }
(XSLTCDTMManager)_transformer.getTransformerFactory() .getDTMManagerClass() .newInstance();
_transformer.getOutputHandler(result); _transformer.transferOutputProperties(outputHandler); _transformer.setDOM(_dom); _transformer.transform(null, _result);
/** * Implements org.xml.sax.ContentHandler.endDocument() * Receive notification of the end of a document. */ public void endDocument() throws SAXException { // Signal to the DOMBuilder that the document is complete _handler.endDocument(); if (!_isIdentity) { // Run the transformation now if we have a reference to a Result object if (_result != null) { try { _transformer.setDOM(_dom); _transformer.transform(null, _result); } catch (TransformerException e) { throw new SAXException(e); } } // Signal that the internal DOM is built (see 'setResult()'). _done = true; // Set this DOM as the transformer's DOM _transformer.setDOM(_dom); } if (_isIdentity && _result instanceof DOMResult) { ((DOMResult)_result).setNode(_transformer.getTransletOutputHandlerFactory().getNode()); } }
transferOutputProperties(_translet); final SerializationHandler toHandler = getOutputHandler(result); if (toHandler == null) { ErrorMsg err = new ErrorMsg(ErrorMsg.JAXP_NO_HANDLER_ERR); transferOutputProperties(toHandler); transform(source, toHandler, _encoding);
/** * Cosntructor - pass in reference to a TransformerImpl object */ public TransformerHandlerImpl(TransformerImpl transformer) { // Save the reference to the transformer _transformer = transformer; if (transformer.isIdentity()) { // Set initial handler to the empty handler _handler = new DefaultHandler(); _isIdentity = true; } else { // Get a reference to the translet wrapped inside the transformer _translet = _transformer.getTranslet(); } }
if (isDefaultProperty(name, properties)) continue; if (validOutputProperty(name)) { _properties.setProperty(name, properties.getProperty(name));
StreamSource streamSource = new StreamSource( SystemIDResolver.getAbsoluteURI(href, baseURI)); return getDOM(streamSource) ; return getDOM(resolvedSource); postErrorToListener("File not found: " + e.getMessage()); return(null);
private void createParent() throws SAXException { XMLReader parent = null; try { SAXParserFactory pfactory = SAXParserFactory.newInstance(); pfactory.setNamespaceAware(true); if (_transformer.isSecureProcessing()) { try { pfactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); } catch (SAXException e) {} } SAXParser saxparser = pfactory.newSAXParser(); parent = saxparser.getXMLReader(); } catch (ParserConfigurationException e) { throw new SAXException(e); } catch (FactoryConfigurationError e) { throw new SAXException(e.toString()); } if (parent == null) { parent = XMLReaderFactory.createXMLReader(); } // make this XMLReader the parent of this filter setParent(parent); }
(XSLTCDTMManager)_transformer.getTransformerFactory() .getDTMManagerClass() .newInstance();
/** * Implements JAXP's Templates.newTransformer() * * @throws TransformerConfigurationException */ public synchronized Transformer newTransformer() throws TransformerConfigurationException { TransformerImpl transformer; transformer = new TransformerImpl(getTransletInstance(), _outputProperties, _indentNumber, _tfactory); if (_uriResolver != null) { transformer.setURIResolver(_uriResolver); } if (_tfactory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING)) { transformer.setSecureProcessing(true); } return transformer; }