本文整理了Java中javax.xml.transform.Transformer.setErrorListener()
方法的一些代码示例,展示了Transformer.setErrorListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Transformer.setErrorListener()
方法的具体详情如下:
包路径:javax.xml.transform.Transformer
类名称:Transformer
方法名:setErrorListener
[英]Set the error event listener in effect for the transformation.
[中]为转换设置有效的错误事件侦听器。
代码示例来源:origin: apache/nifi
transformer.setErrorListener(new ErrorListener() {
@Override
public void warning(final TransformerException exception) throws TransformerException {
代码示例来源:origin: marytts/marytts
public MaryData process(MaryData d) throws Exception {
DOMSource domSource = new DOMSource(d.getDocument());
Transformer transformer = stylesheet.newTransformer();
// Log transformation errors to client:
if (doWarnClient) {
// Use custom error handler:
transformer.setErrorListener(new LoggingErrorHandler(Thread.currentThread().getName() + " client.Sable transformer"));
}
// Transform DOMSource into a DOMResult
Document maryxmlDocument = docBuilder.newDocument();
DOMResult domResult = new DOMResult(maryxmlDocument);
transformer.transform(domSource, domResult);
MaryData result = new MaryData(outputType(), d.getLocale());
result.setDocument(maryxmlDocument);
return result;
}
}
代码示例来源:origin: marytts/marytts
public MaryData process(MaryData d) throws Exception {
DOMSource domSource = new DOMSource(d.getDocument());
Transformer transformer = stylesheet.newTransformer();
// Log transformation errors to client:
if (doWarnClient) {
// Use custom error handler:
transformer.setErrorListener(new LoggingErrorHandler(Thread.currentThread().getName() + " client.SSML transformer"));
}
// Transform DOMSource into a DOMResult
Document maryxmlDocument = docBuilder.newDocument();
DOMResult domResult = new DOMResult(maryxmlDocument);
transformer.transform(domSource, domResult);
MaryData result = new MaryData(outputType(), d.getLocale());
result.setDocument(maryxmlDocument);
return result;
}
}
代码示例来源:origin: marytts/marytts
public MaryData process(MaryData d) throws Exception {
DOMSource domSource = new DOMSource(d.getDocument());
Transformer transformer = stylesheet.newTransformer();
// Log transformation errors to client:
if (doWarnClient) {
// Use custom error handler:
transformer.setErrorListener(new LoggingErrorHandler(Thread.currentThread().getName() + " client.APML transformer"));
}
// Transform DOMSource into a DOMResult
Document maryxmlDocument = docBuilder.newDocument();
DOMResult domResult = new DOMResult(maryxmlDocument);
transformer.transform(domSource, domResult);
MaryData result = new MaryData(outputType(), d.getLocale());
result.setDocument(maryxmlDocument);
return result;
}
}
代码示例来源:origin: marytts/marytts
public MaryData process(MaryData d) throws Exception {
DOMSource domSource = new DOMSource(d.getDocument());
Transformer transformer = stylesheet.newTransformer();
// Log transformation errors to client:
if (doWarnClient) {
// Use custom error handler:
transformer.setErrorListener(new LoggingErrorHandler(Thread.currentThread().getName() + " client.Sable transformer"));
}
// Transform DOMSource into a DOMResult
Document maryxmlDocument = docBuilder.newDocument();
DOMResult domResult = new DOMResult(maryxmlDocument);
transformer.transform(domSource, domResult);
MaryData result = new MaryData(outputType(), d.getLocale());
result.setDocument(maryxmlDocument);
return result;
}
}
代码示例来源:origin: marytts/marytts
public MaryData process(MaryData d) throws Exception {
DOMSource domSource = new DOMSource(d.getDocument());
Transformer transformer = stylesheet.newTransformer();
// Log transformation errors to client:
if (doWarnClient) {
// Use custom error handler:
transformer.setErrorListener(new LoggingErrorHandler(Thread.currentThread().getName() + " client.APML transformer"));
}
// Transform DOMSource into a DOMResult
Document maryxmlDocument = docBuilder.newDocument();
DOMResult domResult = new DOMResult(maryxmlDocument);
transformer.transform(domSource, domResult);
MaryData result = new MaryData(outputType(), d.getLocale());
result.setDocument(maryxmlDocument);
return result;
}
}
代码示例来源:origin: marytts/marytts
public MaryData process(MaryData d) throws Exception {
DOMSource domSource = new DOMSource(d.getDocument());
Transformer transformer = stylesheet.newTransformer();
// Log transformation errors to client:
if (doWarnClient) {
// Use custom error handler:
transformer.setErrorListener(new LoggingErrorHandler(Thread.currentThread().getName() + " client.SSML transformer"));
}
// Transform DOMSource into a DOMResult
Document maryxmlDocument = docBuilder.newDocument();
DOMResult domResult = new DOMResult(maryxmlDocument);
transformer.transform(domSource, domResult);
MaryData result = new MaryData(outputType(), d.getLocale());
result.setDocument(maryxmlDocument);
return result;
}
}
代码示例来源:origin: org.apache.ant/ant
transformer.setErrorListener(this);
if (uriResolver != null) {
transformer.setURIResolver(uriResolver);
代码示例来源:origin: marytts/marytts
transformer.setErrorListener(new LoggingErrorHandler(Thread.currentThread().getName()
+ " client.EmotionML transformer"));
代码示例来源:origin: marytts/marytts
transformer.setErrorListener(new LoggingErrorHandler(Thread.currentThread().getName()
+ " client.EmotionML transformer"));
代码示例来源:origin: plutext/docx4j
xformer.setErrorListener(errorListener);
代码示例来源:origin: xalan/xalan
transformer.setErrorListener(new DefaultErrorHandler(false));
serializer.setErrorListener(new DefaultErrorHandler(false));
代码示例来源:origin: spring-projects/spring-restdocs
@Override
public byte[] prettyPrint(byte[] original) throws Exception {
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount",
"4");
transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, "yes");
ByteArrayOutputStream transformed = new ByteArrayOutputStream();
transformer.setErrorListener(new SilentErrorListener());
transformer.transform(createSaxSource(original),
new StreamResult(transformed));
return transformed.toByteArray();
}
代码示例来源:origin: org.zkoss.common/zcommon
/** Set the error event listener in effect for the transformation.
*/
public final void setErrorListener(ErrorListener listener) {
_tfmr.setErrorListener(listener);
}
}
代码示例来源:origin: org.ikasan/ikasan-common
/**
* Sets the error event listener in effect for the transformation.
*
* @param listener - a new error listener.
*/
public void setErrorListener(ErrorListener listener)
{
// No need to scream as we've already got ErrorListener
if (listener == null) return;
this.transformer.setErrorListener(listener);
}
代码示例来源:origin: org.geoserver/gs-wfs
public void transform(InputStream in, DOMSource xslt, OutputStream out)
throws TransformerException {
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer =
(xslt == null ? factory.newTransformer() : factory.newTransformer(xslt));
transformer.setErrorListener(new TransformerErrorListener());
transformer.transform(new StreamSource(in), new StreamResult(out));
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public void setErrorListener(
javax.xml.transform.ErrorListener errorListener)
throws java.lang.IllegalArgumentException {
try {
materialize();
m_realTransformer.setErrorListener(errorListener);
} catch (TransformerException e) {
// will be caught later
}
}
代码示例来源:origin: jboss-switchyard/core
private void addTransformer() throws Exception {
Transformer transformer = _templates.newTransformer();
if (_errorListener != null) {
transformer.setErrorListener(_errorListener);
}
_count.incrementAndGet();
boolean result = _pool.offer(transformer);
if ((!result) && (_logger.isDebugEnabled())) {
_logger.debug("Unable to add " + transformer.toString() + " to blocking queue");
}
}
代码示例来源:origin: com.enonic.xp/lib-xslt
protected void createTransformer()
throws Exception
{
this.factory.setErrorListener( this.errors );
this.factory.setURIResolver( uriResolver );
this.transformer = this.factory.newTransformer( this.xsltSource );
this.transformer.setErrorListener( this.errors );
this.transformer.setOutputProperty( OutputKeys.OMIT_XML_DECLARATION, "yes" );
}
代码示例来源:origin: org.pustefixframework/pustefix-core
@Override
public void doErrorListening(Transformer transformer, boolean traceLocation) {
if(traceLocation) {
Saxon1LocationTraceListener tl = new Saxon1LocationTraceListener();
ErrorListener el = new Saxon1ErrorListener(tl);
transformer.setErrorListener(el);
((Controller)transformer).addTraceListener(tl);
} else {
transformer.setErrorListener(new ErrorListenerBase());
}
}
内容来源于网络,如有侵权,请联系作者删除!