本文整理汇总了Java中javax.xml.transform.Transformer.getErrorListener方法的典型用法代码示例。如果您正苦于以下问题:Java Transformer.getErrorListener方法的具体用法?Java Transformer.getErrorListener怎么用?Java Transformer.getErrorListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.transform.Transformer
的用法示例。
在下文中一共展示了Transformer.getErrorListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setEncoding
import javax.xml.transform.Transformer; //导入方法依赖的package包/类
/**
* Sets the character encoding coming from the xsl:output encoding stylesheet attribute.
* @param encoding the character encoding
*/
public void setEncoding(String encoding)
{
String old = getEncoding();
super.setEncoding(encoding);
if (old == null || !old.equals(encoding)) {
// If we have changed the setting of the
m_encodingInfo = Encodings.getEncodingInfo(encoding);
if (encoding != null && m_encodingInfo.name == null) {
// We tried to get an EncodingInfo for Object for the given
// encoding, but it came back with an internall null name
// so the encoding is not supported by the JDK, issue a message.
String msg = Utils.messages.createMessage(
MsgKey.ER_ENCODING_NOT_SUPPORTED,new Object[]{ encoding });
try
{
// Prepare to issue the warning message
Transformer tran = super.getTransformer();
if (tran != null) {
ErrorListener errHandler = tran.getErrorListener();
// Issue the warning message
if (null != errHandler && m_sourceLocator != null)
errHandler.warning(new TransformerException(msg, m_sourceLocator));
else
System.out.println(msg);
}
else
System.out.println(msg);
}
catch (Exception e){}
}
}
return;
}
示例2: getXMLVersion
import javax.xml.transform.Transformer; //导入方法依赖的package包/类
/**
* This method checks for the XML version of output document.
* If XML version of output document is not specified, then output
* document is of version XML 1.0.
* If XML version of output doucment is specified, but it is not either
* XML 1.0 or XML 1.1, a warning message is generated, the XML Version of
* output document is set to XML 1.0 and processing continues.
* @return string (XML version)
*/
private String getXMLVersion()
{
String xmlVersion = getVersion();
if(xmlVersion == null || xmlVersion.equals(XMLVERSION10))
{
xmlVersion = XMLVERSION10;
}
else if(xmlVersion.equals(XMLVERSION11))
{
xmlVersion = XMLVERSION11;
}
else
{
String msg = Utils.messages.createMessage(
MsgKey.ER_XML_VERSION_NOT_SUPPORTED,new Object[]{ xmlVersion });
try
{
// Prepare to issue the warning message
Transformer tran = super.getTransformer();
ErrorListener errHandler = tran.getErrorListener();
// Issue the warning message
if (null != errHandler && m_sourceLocator != null)
errHandler.warning(new TransformerException(msg, m_sourceLocator));
else
System.out.println(msg);
}
catch (Exception e){}
xmlVersion = XMLVERSION10;
}
return xmlVersion;
}