本文整理汇总了Java中javax.xml.transform.TransformerException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java TransformerException.getMessage方法的具体用法?Java TransformerException.getMessage怎么用?Java TransformerException.getMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.xml.transform.TransformerException
的用法示例。
在下文中一共展示了TransformerException.getMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadSource
import javax.xml.transform.TransformerException; //导入方法依赖的package包/类
/**
* This method implements XSLTC's SourceLoader interface. It is used to
* glue a TrAX URIResolver to the XSLTC compiler's Input and Import classes.
*
* @param href The URI of the document to load
* @param context The URI of the currently loaded document
* @param xsltc The compiler that resuests the document
* @return An InputSource with the loaded document
*/
@Override
public InputSource loadSource(String href, String context, XSLTC xsltc) {
try {
if (_uriResolver != null) {
final Source source = _uriResolver.resolve(href, context);
if (source != null) {
return Util.getInputSource(xsltc, source);
}
}
}
catch (TransformerException e) {
// should catch it when the resolver explicitly throws the exception
final ErrorMsg msg = new ErrorMsg(ErrorMsg.INVALID_URI_ERR, href + "\n" + e.getMessage(), this);
xsltc.getParser().reportError(Constants.FATAL, msg);
}
return null;
}
示例2: writeXml
import javax.xml.transform.TransformerException; //导入方法依赖的package包/类
private static void writeXml(final Document doc, final File file) throws IOException {
doc.normalize();
final TransformerFactory transformerFactory = TransformerFactory.newInstance(XML_FACTORY, null);
try {
final Transformer transformer = transformerFactory.newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
transformer.transform(new DOMSource(doc), new StreamResult(file));
} catch (final TransformerException ex) {
throw new IOException(ex.getMessage(), ex);
}
}
示例3: outputXML
import javax.xml.transform.TransformerException; //导入方法依赖的package包/类
private static String outputXML(Document doc) throws CteException {
try {
ByteArrayOutputStream os = new ByteArrayOutputStream();
TransformerFactory tf = TransformerFactory.newInstance();
Transformer trans = tf.newTransformer();
trans.transform(new DOMSource(doc), new StreamResult(os));
String xml = os.toString();
xml = xml.replaceAll("\\r\\n", "");
xml = xml.replaceAll(" standalone=\"no\"", "");
return xml;
} catch (TransformerException e) {
throw new CteException("Erro ao Transformar Documento:" + e.getMessage());
}
}
示例4: getBooleanValue
import javax.xml.transform.TransformerException; //导入方法依赖的package包/类
/**
* @see org.w3c.dom.xpath.XPathResult#getBooleanValue()
*/
public boolean getBooleanValue() throws XPathException {
if (getResultType() != BOOLEAN_TYPE) {
String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_CONVERT_TO_BOOLEAN, new Object[] {m_xpath.getPatternString(), getTypeString(m_resultType)});
throw new XPathException(XPathException.TYPE_ERR,fmsg);
// "The XPathResult of XPath expression {0} has an XPathResultType of {1} which cannot be converted to a boolean."
} else {
try {
return m_resultObj.bool();
} catch (TransformerException e) {
// Type check above should prevent this exception from occurring.
throw new XPathException(XPathException.TYPE_ERR,e.getMessage());
}
}
}
示例5: getSingleNodeValue
import javax.xml.transform.TransformerException; //导入方法依赖的package包/类
/**
* The value of this single node result, which may be <code>null</code>.
* @exception XPathException
* TYPE_ERR: raised if <code>resultType</code> is not
* <code>ANY_UNORDERED_NODE_TYPE</code> or
* <code>FIRST_ORDERED_NODE_TYPE</code>.
*
* @see org.w3c.dom.xpath.XPathResult#getSingleNodeValue()
*/
public Node getSingleNodeValue() throws XPathException {
if ((m_resultType != ANY_UNORDERED_NODE_TYPE) &&
(m_resultType != FIRST_ORDERED_NODE_TYPE)) {
String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_CONVERT_TO_SINGLENODE, new Object[] {m_xpath.getPatternString(), getTypeString(m_resultType)});
throw new XPathException(XPathException.TYPE_ERR,fmsg);
// "The XPathResult of XPath expression {0} has an XPathResultType of {1} which cannot be converted to a single node.
// This method applies only to types ANY_UNORDERED_NODE_TYPE and FIRST_ORDERED_NODE_TYPE."
}
NodeIterator result = null;
try {
result = m_resultObj.nodeset();
} catch (TransformerException te) {
throw new XPathException(XPathException.TYPE_ERR,te.getMessage());
}
if (null == result) return null;
Node node = result.nextNode();
// Wrap "namespace node" in an XPathNamespace
if (isNamespaceNode(node)) {
return new XPathNamespaceImpl(node);
} else {
return node;
}
}