List of usage examples for org.w3c.dom Element getLocalName
public String getLocalName();
From source file:org.eclipse.smila.datamodel.record.dom.RecordParser.java
/** * parse literals from L element to attribute. * //from w w w. j a va 2 s .com * @param attribute * target attribute * @param literalsElement * L element */ private void parseLiterals(final Attribute attribute, final Element literalsElement) { String defaultSemanticType = literalsElement.getAttribute(ATTRIBUTE_SEMANTICTYPE); if (StringUtils.isBlank(defaultSemanticType)) { defaultSemanticType = null; } final NodeList children = literalsElement.getChildNodes(); if (children != null && children.getLength() > 0) { Literal annotationLiteral = null; for (int i = 0; i < children.getLength(); i++) { final Node childNode = children.item(i); if (childNode instanceof Element) { final Element childElement = (Element) childNode; if (TAG_VALUE.equals(childElement.getLocalName())) { final Literal newLiteral = parseAttributeLiteral(attribute, childElement, defaultSemanticType); if (annotationLiteral == null) { annotationLiteral = newLiteral; } } else if (annotationLiteral != null && TAG_ANNOTATION.equals(childElement.getLocalName())) { parseAnnotation(annotationLiteral, childElement); } } } } }
From source file:org.eclipse.smila.processing.bpel.ExtensionManager.java
/** * parse annotations from given element and attach them to annotatble object. * /*from ww w . ja va2 s.c o m*/ * @param content * DOM objects to search for annotations * @param annotatable * object to attach annotations to. */ public void parseAnnotations(final Element content, final AnnotatableImpl annotatable) { final NodeList annotations = content.getElementsByTagNameNS(ODEWorkflowProcessor.NAMESPACE_PROCESSOR, TAG_SETANNOTATIONS); if (annotations != null && annotations.getLength() > 0) { for (int j = 0; j < annotations.getLength(); j++) { final Element setAnnotations = (Element) annotations.item(j); final NodeList childs = setAnnotations.getChildNodes(); for (int i = 0; i < childs.getLength(); i++) { final Node child = childs.item(i); if (child instanceof Element) { final Element element = (Element) child; if (RecordParser.TAG_ANNOTATION.equals(element.getLocalName())) { RECORD_PARSER.parseAnnotation(annotatable, element); } } } } } }
From source file:org.eclipse.smila.search.datadictionary.messages.ddconfig.DFieldConfigCodec.java
/** * Decode standard values of a field config. * /*from w w w .jav a 2 s. co m*/ * @param dField * Field config. * @param element * Element. * @throws ConfigurationException * Unable to decode field config. */ public static void decodeStandardValues(DFieldConfig dField, Element element) throws ConfigurationException { final Log log = LogFactory.getLog(DFieldConfigCodec.class); if (element.hasAttribute("Weight")) { dField.setWeight(new Integer(element.getAttribute("Weight"))); } if (element.hasAttribute("FieldTemplate")) { dField.setFieldTemplate(element.getAttribute("FieldTemplate")); } if (element.hasAttribute("Constraint")) { dField.setConstraint(element.getAttribute("Constraint")); } final NodeList nl = element.getChildNodes(); for (int i = 0; i < nl.getLength(); i++) { if (!(nl.item(i) instanceof Element)) { continue; } final Element el = (Element) nl.item(i); if ("Transformer".equals(el.getLocalName())) { try { dField.setTransformer(DTransformerCodec.decode(el)); } catch (final DSearchException e) { log.error("Unable to decode Transformer: " + e.getMessage(), e); throw new ConfigurationException("Unable to decode Transformer: " + e.getMessage()); } } else if ("NodeTransformer".equals(el.getLocalName())) { try { dField.setNodeTransformer(DNodeTransformerCodec.decode(el)); } catch (final DSearchException e) { log.error("Unable to decode NodeTransformer: " + e.getMessage(), e); throw new ConfigurationException("Unable to decode NodeTransformer: " + e.getMessage()); } } } }
From source file:org.eclipse.swordfish.plugins.planner.policy.PolicyAssertionHintExtractor.java
@SuppressWarnings("unchecked") private Policy getPolicy(MessageExchange messageExchange) { Policy policy = null;/*from w ww.j a va 2 s .c o m*/ try { NormalizedMessage message = getNormalizedMessage(messageExchange); Map<QName, Node> headers = (Map<QName, Node>) message.getProperty(JbiConstants.SOAP_HEADERS); if (headers == null) { return null; } DocumentFragment policyFragment = (DocumentFragment) headers.get(POLICY_HEADER); if (policyFragment == null) { return null; } Element policyElement = (Element) policyFragment.getFirstChild(); if (!Constants.ELEM_POLICY.equals(policyElement.getLocalName()) || !Constants.URI_POLICY_NS.equals(policyElement.getNamespaceURI())) { return null; } return policyExtractor.extractPolicy(policyElement); } catch (Exception ex) { LOG.warn(ex.getMessage(), ex); } return policy; }
From source file:org.eclipse.uomo.xml.test.XMLTestCase.java
private String compareElements(Element e1, Element e2, String p) { if (!e1.getNamespaceURI().equals(e2.getNamespaceURI())) return "element namespaces differ at " + p; if (!e1.getLocalName().equals(e2.getLocalName())) return "element names differ at " + p; String msg = compareAttributes(e1, e2, p); if (msg != null) return msg; p = p + "/" + e1.getNodeName(); int i = 0;/* w w w . j ava 2 s . co m*/ Node c1 = getNextRelevantNode(e1.getFirstChild()); Node c2 = getNextRelevantNode(e2.getFirstChild()); while (c1 != null && c2 != null) { if (c1.getNodeType() != c2.getNodeType()) return "Different node types (" + Integer.toString(c1.getNodeType()) + "/" + c2.getNodeType() + ") @ " + p; msg = null; if (c1.getNodeType() == Node.TEXT_NODE) { msg = compareTexts((Text) c1, (Text) c2, p + "[" + Integer.toString(i) + "]"); } else if (c1.getNodeType() == Node.ELEMENT_NODE) { msg = compareElements((Element) c1, (Element) c2, p + "[" + Integer.toString(i) + "]"); } else msg = "unknown node type " + Integer.toString(c1.getNodeType()); if (msg != null) return msg; c1 = getNextRelevantNode(c1.getNextSibling()); c2 = getNextRelevantNode(c2.getNextSibling()); i++; } if (c1 != null && c2 == null) return "node present in one and not in two @ " + p; if (c2 != null && c1 == null) return "node present in two and not in one @ " + p; return null; }
From source file:org.exist.http.urlrewrite.XQueryURLRewrite.java
@Override protected void service(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws IOException, ServletException { if (rewriteConfig == null) { configure();/* w ww . j a v a2 s . c o m*/ rewriteConfig = new RewriteConfig(this); } final long start = System.currentTimeMillis(); final HttpServletRequest request = servletRequest; final HttpServletResponse response = servletResponse; if (LOG.isTraceEnabled()) { LOG.trace(request.getRequestURI()); } final Descriptor descriptor = Descriptor.getDescriptorSingleton(); if (descriptor != null && descriptor.requestsFiltered()) { final String attr = (String) request.getAttribute("XQueryURLRewrite.forwarded"); if (attr == null) { // request = new HttpServletRequestWrapper(request, /*formEncoding*/ "utf-8" ); //logs the request if specified in the descriptor descriptor.doLogRequestInReplayLog(request); request.setAttribute("XQueryURLRewrite.forwarded", "true"); } } Subject user = defaultUser; Subject requestUser = HttpAccount.getUserFromServletRequest(request); if (requestUser != null) { user = requestUser; } else { // Secondly try basic authentication final String auth = request.getHeader("Authorization"); if (auth != null) { requestUser = authenticator.authenticate(request, response); if (requestUser != null) { user = requestUser; } } } try { configure(); //checkCache(user); final RequestWrapper modifiedRequest = new RequestWrapper(request); final URLRewrite staticRewrite = rewriteConfig.lookup(modifiedRequest); if (staticRewrite != null && !staticRewrite.isControllerForward()) { modifiedRequest.setPaths(staticRewrite.resolve(modifiedRequest), staticRewrite.getPrefix()); if (LOG.isTraceEnabled()) { LOG.trace("Forwarding to target: " + staticRewrite.getTarget()); } staticRewrite.doRewrite(modifiedRequest, response); } else { if (LOG.isTraceEnabled()) { LOG.trace("Processing request URI: " + request.getRequestURI()); } if (staticRewrite != null) { // fix the request URI staticRewrite.updateRequest(modifiedRequest); } // check if the request URI is already in the url cache ModelAndView modelView = getFromCache(request.getHeader("Host") + request.getRequestURI(), user); if (LOG.isDebugEnabled()) { LOG.debug("Checked cache for URI: " + modifiedRequest.getRequestURI() + " original: " + request.getRequestURI()); } // no: create a new model and view configuration if (modelView == null) { modelView = new ModelAndView(); // Execute the query Sequence result = Sequence.EMPTY_SEQUENCE; DBBroker broker = null; try { broker = pool.get(user); modifiedRequest.setAttribute(RQ_ATTR_REQUEST_URI, request.getRequestURI()); final Properties outputProperties = new Properties(); outputProperties.setProperty(OutputKeys.INDENT, "yes"); outputProperties.setProperty(OutputKeys.ENCODING, "UTF-8"); outputProperties.setProperty(OutputKeys.MEDIA_TYPE, MimeType.XML_TYPE.getName()); result = runQuery(broker, modifiedRequest, response, modelView, staticRewrite, outputProperties); logResult(broker, result); if (response.isCommitted()) { return; } // process the query result if (result.getItemCount() == 1) { final Item resource = result.itemAt(0); if (!Type.subTypeOf(resource.getType(), Type.NODE)) { throw new ServletException( "XQueryURLRewrite: urlrewrite query should return an element!"); } Node node = ((NodeValue) resource).getNode(); if (node.getNodeType() == Node.DOCUMENT_NODE) { node = ((Document) node).getDocumentElement(); } if (node.getNodeType() != Node.ELEMENT_NODE) { //throw new ServletException("Redirect XQuery should return an XML element!"); response(broker, response, outputProperties, result); return; } Element elem = (Element) node; if (!(Namespaces.EXIST_NS.equals(elem.getNamespaceURI()))) { response(broker, response, outputProperties, result); return; // throw new ServletException("Redirect XQuery should return an element in namespace " + Namespaces.EXIST_NS); } if (Namespaces.EXIST_NS.equals(elem.getNamespaceURI()) && "dispatch".equals(elem.getLocalName())) { node = elem.getFirstChild(); while (node != null) { if (node.getNodeType() == Node.ELEMENT_NODE && Namespaces.EXIST_NS.equals(node.getNamespaceURI())) { final Element action = (Element) node; if ("view".equals(action.getLocalName())) { parseViews(modifiedRequest, action, modelView); } else if ("error-handler".equals(action.getLocalName())) { parseErrorHandlers(modifiedRequest, action, modelView); } else if ("cache-control".equals(action.getLocalName())) { final String option = action.getAttribute("cache"); modelView.setUseCache("yes".equals(option)); } else { final URLRewrite urw = parseAction(modifiedRequest, action); if (urw != null) { modelView.setModel(urw); } } } node = node.getNextSibling(); } if (modelView.getModel() == null) { modelView.setModel(new PassThrough(config, elem, modifiedRequest)); } } else if (Namespaces.EXIST_NS.equals(elem.getNamespaceURI()) && "ignore".equals(elem.getLocalName())) { modelView.setModel(new PassThrough(config, elem, modifiedRequest)); final NodeList nl = elem.getElementsByTagNameNS(Namespaces.EXIST_NS, "cache-control"); if (nl.getLength() > 0) { elem = (Element) nl.item(0); final String option = elem.getAttribute("cache"); modelView.setUseCache("yes".equals(option)); } } else { response(broker, response, outputProperties, result); return; } } else if (result.getItemCount() > 1) { response(broker, response, outputProperties, result); return; } if (modelView.useCache()) { LOG.debug("Caching request to " + request.getRequestURI()); urlCache.put(modifiedRequest.getHeader("Host") + request.getRequestURI(), modelView); } } finally { pool.release(broker); } // store the original request URI to org.exist.forward.request-uri modifiedRequest.setAttribute(RQ_ATTR_REQUEST_URI, request.getRequestURI()); modifiedRequest.setAttribute(RQ_ATTR_SERVLET_PATH, request.getServletPath()); } if (LOG.isTraceEnabled()) { LOG.trace("URLRewrite took " + (System.currentTimeMillis() - start) + "ms."); } final HttpServletResponse wrappedResponse = new CachingResponseWrapper(response, modelView.hasViews() || modelView.hasErrorHandlers()); if (modelView.getModel() == null) { modelView.setModel(new PassThrough(config, modifiedRequest)); } if (staticRewrite != null) { if (modelView.getModel().doResolve()) { staticRewrite.rewriteRequest(modifiedRequest); } else { modelView.getModel().setAbsolutePath(modifiedRequest); } } modifiedRequest.allowCaching(!modelView.hasViews()); doRewrite(modelView.getModel(), modifiedRequest, wrappedResponse); int status = ((CachingResponseWrapper) wrappedResponse).getStatus(); if (status == HttpServletResponse.SC_NOT_MODIFIED) { response.flushBuffer(); } else if (status < 400) { if (modelView.hasViews()) { applyViews(modelView, modelView.views, response, modifiedRequest, wrappedResponse); } else { ((CachingResponseWrapper) wrappedResponse).flush(); } } else { // HTTP response code indicates an error if (modelView.hasErrorHandlers()) { final byte[] data = ((CachingResponseWrapper) wrappedResponse).getData(); if (data != null) { modifiedRequest.setAttribute(RQ_ATTR_ERROR, new String(data, UTF_8)); } applyViews(modelView, modelView.errorHandlers, response, modifiedRequest, wrappedResponse); } else { flushError(response, wrappedResponse); } } } // Sequence result; // if ((result = (Sequence) request.getAttribute(RQ_ATTR_RESULT)) != null) { // writeResults(response, broker, result); // } } catch (final Throwable e) { LOG.error("Error while processing " + servletRequest.getRequestURI() + ": " + e.getMessage(), e); throw new ServletException("An error occurred while processing request to " + servletRequest.getRequestURI() + ": " + e.getMessage(), e); } }
From source file:org.exist.http.urlrewrite.XQueryURLRewrite.java
private URLRewrite parseAction(HttpServletRequest request, Element action) throws ServletException { URLRewrite rewrite = null;/*w ww .jav a2 s. co m*/ if ("forward".equals(action.getLocalName())) { rewrite = new PathForward(config, action, request.getRequestURI()); } else if ("redirect".equals(action.getLocalName())) { rewrite = new Redirect(action, request.getRequestURI()); // } else if ("call".equals(action.getLocalName())) { // rewrite = new ModuleCall(action, queryContext, request.getRequestURI()); } return rewrite; }
From source file:org.exist.xquery.modules.mail.SendEmailFunction.java
/** * Constructs a mail Object from an XML representation of an email * * The XML email Representation is expected to look something like this * * <mail>//from w w w . j ava 2 s.co m * <from></from> * <reply-to></reply-to> * <to></to> * <cc></cc> * <bcc></bcc> * <subject></subject> * <message> * <text></text> * <xhtml></xhtml> * </message> * </mail> * * @param mailElements The XML mail Node * @return A mail Object representing the XML mail Node */ private List<Mail> parseMailElement(List<Element> mailElements) throws TransformerException { List<Mail> mails = new ArrayList<>(); for (Element mailElement : mailElements) { //Make sure that message has a Mail node if (mailElement.getLocalName().equals("mail")) { //New mail Object Mail mail = new Mail(); //Get the First Child Node child = mailElement.getFirstChild(); while (child != null) { //Parse each of the child nodes if (child.getNodeType() == Node.ELEMENT_NODE && child.hasChildNodes()) { switch (child.getLocalName()) { case "from": mail.setFrom(child.getFirstChild().getNodeValue()); break; case "reply-to": mail.setReplyTo(child.getFirstChild().getNodeValue()); break; case "to": mail.addTo(child.getFirstChild().getNodeValue()); break; case "cc": mail.addCC(child.getFirstChild().getNodeValue()); break; case "bcc": mail.addBCC(child.getFirstChild().getNodeValue()); break; case "subject": mail.setSubject(child.getFirstChild().getNodeValue()); break; case "message": //If the message node, then parse the child text and xhtml nodes Node bodyPart = child.getFirstChild(); while (bodyPart != null) { if (bodyPart.getLocalName().equals("text")) { mail.setText(bodyPart.getFirstChild().getNodeValue()); } else if (bodyPart.getLocalName().equals("xhtml")) { //Convert everything inside <xhtml></xhtml> to text TransformerFactory transFactory = TransformerFactory.newInstance(); Transformer transformer = transFactory.newTransformer(); DOMSource source = new DOMSource(bodyPart.getFirstChild()); StringWriter strWriter = new StringWriter(); StreamResult result = new StreamResult(strWriter); transformer.transform(source, result); mail.setXHTML(strWriter.toString()); } //next body part bodyPart = bodyPart.getNextSibling(); } break; case "attachment": Element attachment = (Element) child; MailAttachment ma = new MailAttachment(attachment.getAttribute("filename"), attachment.getAttribute("mimetype"), attachment.getFirstChild().getNodeValue()); mail.addAttachment(ma); break; } } //next node child = child.getNextSibling(); } mails.add(mail); } } return mails; }
From source file:org.exist.xquery.modules.mail.SendEmailFunction.java
/** * Constructs a mail Object from an XML representation of an email * * The XML email Representation is expected to look something like this * * <mail>// w w w.jav a 2s. co m * <from></from> * <reply-to></reply-to> * <to></to> * <cc></cc> * <bcc></bcc> * <subject></subject> * <message> * <text charset="" encoding=""></text> * <xhtml charset="" encoding=""></xhtml> * <generic charset="" type="" encoding=""></generic> * </message> * <attachment mimetype="" filename=""></attachment> * </mail> * * @param mailElements The XML mail Node * @return A mail Object representing the XML mail Node */ private List<Message> parseMessageElement(Session session, List<Element> mailElements) throws IOException, MessagingException, TransformerException { List<Message> mails = new ArrayList<>(); for (Element mailElement : mailElements) { //Make sure that message has a Mail node if (mailElement.getLocalName().equals("mail")) { //New message Object // create a message MimeMessage msg = new MimeMessage(session); ArrayList<InternetAddress> replyTo = new ArrayList<>(); boolean fromWasSet = false; MimeBodyPart body = null; Multipart multibody = null; ArrayList<MimeBodyPart> attachments = new ArrayList<>(); String firstContent = null; String firstContentType = null; String firstCharset = null; String firstEncoding = null; //Get the First Child Node child = mailElement.getFirstChild(); while (child != null) { //Parse each of the child nodes if (child.getNodeType() == Node.ELEMENT_NODE && child.hasChildNodes()) { switch (child.getLocalName()) { case "from": // set the from and to address InternetAddress[] addressFrom = { new InternetAddress(child.getFirstChild().getNodeValue()) }; msg.addFrom(addressFrom); fromWasSet = true; break; case "reply-to": // As we can only set the reply-to, not add them, let's keep // all of them in a list replyTo.add(new InternetAddress(child.getFirstChild().getNodeValue())); msg.setReplyTo(replyTo.toArray(new InternetAddress[0])); break; case "to": msg.addRecipient(Message.RecipientType.TO, new InternetAddress(child.getFirstChild().getNodeValue())); break; case "cc": msg.addRecipient(Message.RecipientType.CC, new InternetAddress(child.getFirstChild().getNodeValue())); break; case "bcc": msg.addRecipient(Message.RecipientType.BCC, new InternetAddress(child.getFirstChild().getNodeValue())); break; case "subject": msg.setSubject(child.getFirstChild().getNodeValue()); break; case "header": // Optional : You can also set your custom headers in the Email if you Want msg.addHeader(((Element) child).getAttribute("name"), child.getFirstChild().getNodeValue()); break; case "message": //If the message node, then parse the child text and xhtml nodes Node bodyPart = child.getFirstChild(); while (bodyPart != null) { if (bodyPart.getNodeType() != Node.ELEMENT_NODE) continue; Element elementBodyPart = (Element) bodyPart; String content = null; String contentType = null; if (bodyPart.getLocalName().equals("text")) { // Setting the Subject and Content Type content = bodyPart.getFirstChild().getNodeValue(); contentType = "plain"; } else if (bodyPart.getLocalName().equals("xhtml")) { //Convert everything inside <xhtml></xhtml> to text TransformerFactory transFactory = TransformerFactory.newInstance(); Transformer transformer = transFactory.newTransformer(); DOMSource source = new DOMSource(bodyPart.getFirstChild()); StringWriter strWriter = new StringWriter(); StreamResult result = new StreamResult(strWriter); transformer.transform(source, result); content = strWriter.toString(); contentType = "html"; } else if (bodyPart.getLocalName().equals("generic")) { // Setting the Subject and Content Type content = elementBodyPart.getFirstChild().getNodeValue(); contentType = elementBodyPart.getAttribute("type"); } // Now, time to store it if (content != null && contentType != null && contentType.length() > 0) { String charset = elementBodyPart.getAttribute("charset"); String encoding = elementBodyPart.getAttribute("encoding"); if (body != null && multibody == null) { multibody = new MimeMultipart("alternative"); multibody.addBodyPart(body); } if (StringUtils.isEmpty(charset)) { charset = "UTF-8"; } if (StringUtils.isEmpty(encoding)) { encoding = "quoted-printable"; } if (body == null) { firstContent = content; firstCharset = charset; firstContentType = contentType; firstEncoding = encoding; } body = new MimeBodyPart(); body.setText(content, charset, contentType); if (encoding != null) { body.setHeader("Content-Transfer-Encoding", encoding); } if (multibody != null) multibody.addBodyPart(body); } //next body part bodyPart = bodyPart.getNextSibling(); } break; case "attachment": Element attachment = (Element) child; MimeBodyPart part; // if mimetype indicates a binary resource, assume the content is base64 encoded if (MimeTable.getInstance().isTextContent(attachment.getAttribute("mimetype"))) { part = new MimeBodyPart(); } else { part = new PreencodedMimeBodyPart("base64"); } StringBuilder content = new StringBuilder(); Node attachChild = attachment.getFirstChild(); while (attachChild != null) { if (attachChild.getNodeType() == Node.ELEMENT_NODE) { TransformerFactory transFactory = TransformerFactory.newInstance(); Transformer transformer = transFactory.newTransformer(); DOMSource source = new DOMSource(attachChild); StringWriter strWriter = new StringWriter(); StreamResult result = new StreamResult(strWriter); transformer.transform(source, result); content.append(strWriter.toString()); } else { content.append(attachChild.getNodeValue()); } attachChild = attachChild.getNextSibling(); } part.setDataHandler(new DataHandler(new ByteArrayDataSource(content.toString(), attachment.getAttribute("mimetype")))); part.setFileName(attachment.getAttribute("filename")); // part.setHeader("Content-Transfer-Encoding", "base64"); attachments.add(part); break; } } //next node child = child.getNextSibling(); } // Lost from if (!fromWasSet) msg.setFrom(); // Preparing content and attachments if (attachments.size() > 0) { if (multibody == null) { multibody = new MimeMultipart("mixed"); if (body != null) { multibody.addBodyPart(body); } } else { MimeMultipart container = new MimeMultipart("mixed"); MimeBodyPart containerBody = new MimeBodyPart(); containerBody.setContent(multibody); container.addBodyPart(containerBody); multibody = container; } for (MimeBodyPart part : attachments) { multibody.addBodyPart(part); } } // And now setting-up content if (multibody != null) { msg.setContent(multibody); } else if (body != null) { msg.setText(firstContent, firstCharset, firstContentType); if (firstEncoding != null) { msg.setHeader("Content-Transfer-Encoding", firstEncoding); } } msg.saveChanges(); mails.add(msg); } } return mails; }
From source file:org.exist.xquery.modules.oracle.ExecuteFunction.java
private void setParametersOnPreparedStatement(Statement stmt, Element parametersElement) throws SQLException, XPathException { if (parametersElement.getNamespaceURI().equals(OracleModule.NAMESPACE_URI) && parametersElement.getLocalName().equals(PARAMETERS_ELEMENT_NAME)) { NodeList paramElements = parametersElement.getElementsByTagNameNS(OracleModule.NAMESPACE_URI, PARAM_ELEMENT_NAME);/*from www. jav a 2s. co m*/ for (int i = 0; i < paramElements.getLength(); i++) { Element param = ((Element) paramElements.item(i)); String value = param.getFirstChild().getNodeValue(); String type = param.getAttributeNS(OracleModule.NAMESPACE_URI, TYPE_ATTRIBUTE_NAME); int position = Integer .parseInt(param.getAttributeNS(OracleModule.NAMESPACE_URI, POSITION_ATTRIBUTE_NAME)); try { int sqlType = SQLUtils.sqlTypeFromString(type); // What if SQL type is date??? if (sqlType == Types.DATE) { Date date = xmlDf.parse(value); ((PreparedStatement) stmt).setTimestamp(position, new Timestamp(date.getTime())); } else { ((PreparedStatement) stmt).setObject(position, value, sqlType); } } catch (ParseException pex) { throw new XPathException(this, "Unable to parse date from value " + value + ". Expected format is YYYY-MM-DDThh:mm:ss.sss"); } catch (Exception ex) { throw new XPathException(this, "Failed to set stored procedure parameter at position " + position + " as " + type + " with value " + value); } } } }