javax.xml.transform.TransformerException#getMessage ( )源码实例Demo

下面列出了javax.xml.transform.TransformerException#getMessage ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openjdk-8   文件: TransformerFactoryImpl.java
/**
 * 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;
}
 
/**
 * 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;
}
 
源代码3 项目: JDKSourceCode1.8   文件: TransformerFactoryImpl.java
/**
 * 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;
}
 
源代码4 项目: j2objc   文件: TransformerIdentityImpl.java
/**
 * Receive notification of the beginning of the document.
 *
 * <p>By default, do nothing.  Application writers may override this
 * method in a subclass to take specific actions at the beginning
 * of a document (such as allocating the root node of a tree or
 * creating an output file).</p>
 *
 * @throws org.xml.sax.SAXException Any SAX exception, possibly
 *            wrapping another exception.
 * @see org.xml.sax.ContentHandler#startDocument
 *
 * @throws SAXException
 */
public void startDocument() throws SAXException
{

  try
  {
    if (null == m_resultContentHandler)
      createResultContentHandler(m_result);
  }
  catch (TransformerException te)
  {
    throw new SAXException(te.getMessage(), te);
  }

  // Reset for multiple transforms with this transformer.
  m_flushedStartDoc = false;
  m_foundFirstElement = false;
}
 
源代码5 项目: jsons2xsd   文件: XmlUtil.java
public static String asXmlString(Node node)
{
    final Source source = new DOMSource(node);
    final StringWriter stringWriter = new StringWriter();
    final Result result = new StreamResult(stringWriter);
    final TransformerFactory factory = TransformerFactory.newInstance();

    try
    {
        final Transformer transformer = factory.newTransformer();
        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
        transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
        transformer.transform(source, result);
        return stringWriter.getBuffer().toString();
    }
    catch (TransformerException exc)
    {
        throw new UncheckedIOException(exc.getMessage(), new IOException(exc));
    }
}
 
源代码6 项目: scipio-erp   文件: UtilXml.java
public static void writeXmlDocument(OutputStream os, Node node) throws java.io.IOException {
    if (node == null) {
        Debug.logWarning("[UtilXml.writeXmlDocument] Node was null, doing nothing" + getLogSuffixDetailed(), module); // SCIPIO: getLogSuffixDetailed
        return;
    }
    // OutputFormat defaults are: indent on, indent = 4, include XML declaration,
    // charset = UTF-8, line width = 72
    try {
        writeXmlDocument(node, os, "UTF-8", false, true, 4);
    } catch (TransformerException e) {
        // Wrapping this exception for backwards compatibility
        throw new IOException(e.getMessage());
    }
}
 
源代码7 项目: JVoiceXML   文件: XmlDocument.java
/**
 * Returns the contents of this object as an XML formatted string.
 *
 * @return XML representation of this object.
 *
 * @exception IOException
 *            Error writing to the writer.
 */
public final String toXml()
        throws IOException {
    final ByteArrayOutputStream out = new ByteArrayOutputStream();
    final Result result = new StreamResult(out);
    final TransformerFactory transformerFactory =
        TransformerFactory.newInstance();
    try {
        final Transformer transformer = transformerFactory.newTransformer();
        final String encoding = System.getProperty("jvoicexml.xml.encoding",
            "UTF-8");
        transformer.setOutputProperty(OutputKeys.ENCODING, encoding);
        transformer.setOutputProperty(OutputKeys.STANDALONE, "yes");
        final DocumentType type = getDoctype();
        if (type != null) {
            transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC,
                    type.getPublicId());
            transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM,
                    type.getSystemId());
        }
        final Source source = new DOMSource(document);
        transformer.transform(source, result);
        return out.toString(encoding);
    } catch (TransformerException e) {
        throw new IOException(e.getMessage(), e);
    }
}
 
源代码8 项目: proarc   文件: OaiCatalogTest.java
@Test
public void testOaiErrorResponseTransformation() throws Exception {
    OaiCatalog c = new OaiCatalog("", "");
    String srcUrl = OaiCatalogTest.class.getResource("oaiErrorResponse.xml").toExternalForm();
    try {
        c.transformOaiResponse(new StreamSource(srcUrl), new StreamResult(new StringWriter()));
        fail();
    } catch (TransformerException result) {
        String msg = result.getMessage();
        assertTrue(msg, msg.contains("cannotDisseminateFormat"));
    }
}
 
源代码9 项目: TencentKona-8   文件: XPathResultImpl.java
/**
         * @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());
                        }
                }
        }
 
源代码10 项目: openjdk-jdk8u-backup   文件: XPathResultImpl.java
/**
         * 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;
        }
        }
 
private String toXMLString(Element assertion) throws TechnicalConnectorException {
   try {
      StreamResult sr = new StreamResult(new StringWriter());
      Transformer tf = TransformerFactory.newInstance().newTransformer();
      tf.setOutputProperty("encoding", "utf8");
      tf.setOutputProperty("indent", "no");
      tf.setOutputProperty("media-type", "text/xml");
      tf.setOutputProperty("omit-xml-declaration", "yes");
      tf.transform(new DOMSource(assertion), sr);
      return sr.getWriter().toString();
   } catch (TransformerException var4) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.CORE_TECHNICAL, var4, new Object[]{var4.getMessage()});
   }
}
 
private String toXMLString(Element assertion) throws TechnicalConnectorException {
   try {
      StreamResult sr = new StreamResult(new StringWriter());
      Transformer tf = TransformerFactory.newInstance().newTransformer();
      tf.setOutputProperty("encoding", "utf8");
      tf.setOutputProperty("indent", "no");
      tf.setOutputProperty("media-type", "text/xml");
      tf.setOutputProperty("omit-xml-declaration", "yes");
      tf.transform(new DOMSource(assertion), sr);
      return sr.getWriter().toString();
   } catch (TransformerException var4) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.CORE_TECHNICAL, var4, new Object[]{var4.getMessage()});
   }
}
 
private String toXMLString(Element assertion) throws TechnicalConnectorException {
   try {
      StreamResult sr = new StreamResult(new StringWriter());
      Transformer tf = TransformerFactory.newInstance().newTransformer();
      tf.setOutputProperty("encoding", "utf8");
      tf.setOutputProperty("indent", "no");
      tf.setOutputProperty("media-type", "text/xml");
      tf.setOutputProperty("omit-xml-declaration", "yes");
      tf.transform(new DOMSource(assertion), sr);
      return sr.getWriter().toString();
   } catch (TransformerException var4) {
      throw new TechnicalConnectorException(TechnicalConnectorExceptionValues.CORE_TECHNICAL, var4, new Object[]{var4.getMessage()});
   }
}
 
源代码14 项目: everrest   文件: XSLTStreamingOutput.java
@Override
public void write(OutputStream output) throws IOException {
    try {
        Transformer transformer = templates.newTransformer();
        transformer.transform(source, new StreamResult(output));
    } catch (TransformerException tre) {
        throw new IOException(tre.getMessage(), tre);
    }
}
 
源代码15 项目: mdw   文件: SoapWebServiceAdapter.java
/**
 * Builds the request XML.
 */
protected String getRequestData() throws ActivityException {
    Object request = null;
    String requestVarName = getAttributeValue(REQUEST_VARIABLE);
    if (requestVarName == null)
        throw new ActivityException("Missing attribute: " + REQUEST_VARIABLE);
    String requestVarType = getParameterType(requestVarName);

    request = getParameterValue(requestVarName);
    if (!hasPreScript()) {
        if (request == null)
            throw new ActivityException("Request data is null: " + requestVarName);
        if (!(request instanceof DocumentReference))
            throw new ActivityException("Request data must be a DocumentReference: " + requestVarName);
    }

    try {
        Object requestObj = request == null ? null : getDocument((DocumentReference)request, requestVarType);
        if (hasPreScript()) {
            Object ret = executePreScript(requestObj);
            if (ret == null) {
                // nothing returned; requestVar may have been assigned by script
                Object req = getParameterValue(requestVarName);
                if (req == null)
                  throw new ActivityException("Request data is null: " + requestVarName);
                requestObj = getDocument((DocumentReference)req, requestVarType);
            }
            else {
                requestObj = ret;
                setParameterValueAsDocument(requestVarName, this.getProcessDefinition().getVariable(requestVarName).getType(), requestObj);
            }
        }
        soapRequest = createSoapRequest(requestObj);
        return DomHelper.toXml(soapRequest.getSOAPPart().getDocumentElement());
    }
    catch (TransformerException ex) {
        throw new ActivityException(ex.getMessage(), ex);
    }
}
 
源代码16 项目: jdk8u60   文件: XPathResultImpl.java
/**
         * @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());
                        }
                }
        }
 
源代码17 项目: jdk8u60   文件: XPathResultImpl.java
/**
         * 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;
        }
        }
 
源代码18 项目: hottub   文件: XPathResultImpl.java
/**
         * @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());
                        }
                }
        }
 
源代码19 项目: hottub   文件: XPathResultImpl.java
/**
         * 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;
        }
        }
 
源代码20 项目: openjdk-8   文件: XPathResultImpl.java
/**
         * 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;
        }
        }