- final InputStream errIS = SendErrorExceptionUtil.class.getResourceAsStream("server_error.xml");
- Document originalErrorDocument;
- try {
- originalErrorDocument = XmlUtil.readXmlToDocument(errIS);
- } catch (final Exception e) {
- throw new IllegalStateException(e);
- }
-
- final Document errorDocument = XmlUtil.createDocumentCopy(originalErrorDocument);
- final Node rootNode = errorDocument.getFirstChild();
-
- final Node rpcErrorNode = (Node) XmlUtil.evaluateXPath(rpcErrorExpression, rootNode, XPathConstants.NODE);
-
- final Node errorTypeNode = (Node) XmlUtil.evaluateXPath(errorTypeExpression, rpcErrorNode, XPathConstants.NODE);
- errorTypeNode.setTextContent(sendErrorException.getErrorType().getTagValue());
-
- final Node errorTagNode = (Node) XmlUtil.evaluateXPath(errorTagExpression, rpcErrorNode, XPathConstants.NODE);
- errorTagNode.setTextContent(sendErrorException.getErrorTag().getTagValue());
-
- final Node errorSeverityNode = (Node) XmlUtil.evaluateXPath(errorSeverityExpression, rpcErrorNode,
- XPathConstants.NODE);
- errorSeverityNode.setTextContent(sendErrorException.getErrorSeverity().getTagValue());
-
- if (sendErrorException.getErrorInfo() != null && !sendErrorException.getErrorInfo().isEmpty()) {
- /*
- * <error-info> <bad-attribute>message-id</bad-attribute>
- * <bad-element>rpc</bad-element> </error-info>
- */
- final Node errorInfoNode = errorDocument.createElementNS(
- XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0, "error-info");