本文整理匯總了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;
}