本文整理汇总了Java中javax.xml.transform.ErrorListener.error方法的典型用法代码示例。如果您正苦于以下问题:Java ErrorListener.error方法的具体用法?Java ErrorListener.error怎么用?Java ErrorListener.error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.transform.ErrorListener
的用法示例。
在下文中一共展示了ErrorListener.error方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSAXSource
import javax.xml.transform.ErrorListener; //导入方法依赖的package包/类
/**
* Converts a supplied <code>Source</code> to a <code>SAXSource</code>.
*
* @param source
* The supplied input source
* @param errorListener
* an ErrorListener object
* @return a <code>SAXSource</code>
*/
public static SAXSource getSAXSource (final Source source,
final ErrorListener errorListener) throws TransformerException
{
if (CSTX.DEBUG)
log.debug ("getting a SAXSource from a Source");
// SAXSource
if (source instanceof SAXSource)
{
if (CSTX.DEBUG)
log.debug ("source is an instance of SAXSource, so simple return");
return (SAXSource) source;
}
// DOMSource
if (source instanceof DOMSource)
{
if (CSTX.DEBUG)
log.debug ("source is an instance of DOMSource");
final InputSource is = new InputSource ();
final Node startNode = ((DOMSource) source).getNode ();
Document doc;
if (startNode instanceof Document)
{
doc = (Document) startNode;
}
else
{
doc = startNode.getOwnerDocument ();
}
if (CSTX.DEBUG)
log.debug ("using DOMDriver");
final DOMDriver driver = new DOMDriver ();
driver.setDocument (doc);
is.setSystemId (source.getSystemId ());
driver.setSystemId (source.getSystemId ());
return new SAXSource (driver, is);
}
// StreamSource
if (source instanceof StreamSource)
{
if (CSTX.DEBUG)
log.debug ("source is an instance of StreamSource");
final InputSource isource = getInputSourceForStreamSources (source, errorListener);
return new SAXSource (isource);
}
final String errMsg = "Unknown type of source";
log.error (errMsg);
final IllegalArgumentException iE = new IllegalArgumentException (errMsg);
final TransformerConfigurationException tE = new TransformerConfigurationException (iE.getMessage (), iE);
if (errorListener != null)
errorListener.error (tE);
else
throw tE;
return null;
}