Example usage for org.w3c.dom Element getLocalName

List of usage examples for org.w3c.dom Element getLocalName

Introduction

In this page you can find the example usage for org.w3c.dom Element getLocalName.

Prototype

public String getLocalName();

Source Link

Document

Returns the local part of the qualified name of this node.

Usage

From source file:org.exist.xquery.modules.sql.ExecuteFunction.java

/**
 * evaluate the call to the XQuery execute() function, it is really the main entry point of this class.
 *
 * @param   args             arguments from the execute() function call
 * @param   contextSequence  the Context Sequence to operate on (not used here internally!)
 *
 * @return  A node representing the SQL result set
 *
 * @throws  XPathException  DOCUMENT ME!
 *
 * @see     org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence)
 */// www  .  j a  v  a  2 s  . co  m
@Override
public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
    // was a connection and SQL statement specified?
    if (args[0].isEmpty() || args[1].isEmpty()) {
        return (Sequence.EMPTY_SEQUENCE);
    }

    // get the Connection
    long connectionUID = ((IntegerValue) args[0].itemAt(0)).getLong();
    Connection con = SQLModule.retrieveConnection(context, connectionUID);

    if (con == null) {
        return (Sequence.EMPTY_SEQUENCE);
    }

    boolean preparedStmt = false;

    //setup the SQL statement
    String sql = null;
    Statement stmt = null;
    boolean executeResult = false;
    ResultSet rs = null;

    try {
        boolean makeNodeFromColumnName = false;
        MemTreeBuilder builder = context.getDocumentBuilder();
        int iRow = 0;

        //SQL or PreparedStatement?
        if (args.length == 3) {

            // get the SQL statement
            sql = args[1].getStringValue();
            stmt = con.createStatement();
            makeNodeFromColumnName = ((BooleanValue) args[2].itemAt(0)).effectiveBooleanValue();

            //execute the statement
            executeResult = stmt.execute(sql);

        } else if (args.length == 4) {

            preparedStmt = true;

            //get the prepared statement
            long statementUID = ((IntegerValue) args[1].itemAt(0)).getLong();
            PreparedStatementWithSQL stmtWithSQL = SQLModule.retrievePreparedStatement(context, statementUID);
            sql = stmtWithSQL.getSql();
            stmt = stmtWithSQL.getStmt();
            makeNodeFromColumnName = ((BooleanValue) args[3].itemAt(0)).effectiveBooleanValue();

            if (!args[2].isEmpty()) {
                setParametersOnPreparedStatement(stmt, (Element) args[2].itemAt(0));
            }

            //execute the prepared statement
            executeResult = ((PreparedStatement) stmt).execute();
        } else {
            //TODO throw exception
        }

        // DW: stmt can be null ?

        // execute the query statement
        if (executeResult) {
            /* SQL Query returned results */

            // iterate through the result set building an XML document
            rs = stmt.getResultSet();
            ResultSetMetaData rsmd = rs.getMetaData();
            int iColumns = rsmd.getColumnCount();

            builder.startDocument();

            builder.startElement(new QName("result", SQLModule.NAMESPACE_URI, SQLModule.PREFIX), null);
            builder.addAttribute(new QName("count", null, null), String.valueOf(-1));

            while (rs.next()) {
                builder.startElement(new QName("row", SQLModule.NAMESPACE_URI, SQLModule.PREFIX), null);
                builder.addAttribute(new QName("index", null, null), String.valueOf(rs.getRow()));

                // get each tuple in the row
                for (int i = 0; i < iColumns; i++) {
                    String columnName = rsmd.getColumnLabel(i + 1);

                    if (columnName != null) {

                        String colElement = "field";

                        if (makeNodeFromColumnName && columnName.length() > 0) {
                            // use column names as the XML node

                            /**
                             * Spaces in column names are replaced with
                             * underscore's
                             */
                            colElement = SQLUtils.escapeXmlAttr(columnName.replace(' ', '_'));
                        }

                        builder.startElement(new QName(colElement, SQLModule.NAMESPACE_URI, SQLModule.PREFIX),
                                null);

                        if (!makeNodeFromColumnName || columnName.length() <= 0) {
                            String name;

                            if (columnName.length() > 0) {
                                name = SQLUtils.escapeXmlAttr(columnName);
                            } else {
                                name = "Column: " + String.valueOf(i + 1);
                            }

                            builder.addAttribute(new QName("name", null, null), name);
                        }

                        builder.addAttribute(
                                new QName(TYPE_ATTRIBUTE_NAME, SQLModule.NAMESPACE_URI, SQLModule.PREFIX),
                                rsmd.getColumnTypeName(i + 1));
                        builder.addAttribute(new QName(TYPE_ATTRIBUTE_NAME, Namespaces.SCHEMA_NS, "xs"),
                                Type.getTypeName(SQLUtils.sqlTypeToXMLType(rsmd.getColumnType(i + 1))));

                        //get the content
                        if (rsmd.getColumnType(i + 1) == Types.SQLXML) {
                            //parse sqlxml value
                            try {
                                final SQLXML sqlXml = rs.getSQLXML(i + 1);

                                if (rs.wasNull()) {
                                    // Add a null indicator attribute if the value was SQL Null
                                    builder.addAttribute(
                                            new QName("null", SQLModule.NAMESPACE_URI, SQLModule.PREFIX),
                                            "true");
                                } else {

                                    SAXParserFactory factory = SAXParserFactory.newInstance();
                                    factory.setNamespaceAware(true);
                                    InputSource src = new InputSource(sqlXml.getCharacterStream());
                                    SAXParser parser = factory.newSAXParser();
                                    XMLReader xr = parser.getXMLReader();

                                    SAXAdapter adapter = new AppendingSAXAdapter(builder);
                                    xr.setContentHandler(adapter);
                                    xr.setProperty(Namespaces.SAX_LEXICAL_HANDLER, adapter);
                                    xr.parse(src);
                                }
                            } catch (Exception e) {
                                throw new XPathException(
                                        "Could not parse column of type SQLXML: " + e.getMessage(), e);
                            }
                        } else {
                            //otherwise assume string value
                            final String colValue = rs.getString(i + 1);

                            if (rs.wasNull()) {
                                // Add a null indicator attribute if the value was SQL Null
                                builder.addAttribute(
                                        new QName("null", SQLModule.NAMESPACE_URI, SQLModule.PREFIX), "true");
                            } else {
                                if (colValue != null) {
                                    builder.characters(SQLUtils.escapeXmlText(colValue));
                                }
                            }
                        }

                        builder.endElement();
                    }
                }

                builder.endElement();
                iRow++;
            }

            builder.endElement();
        } else {
            /* SQL Query performed updates */

            builder.startDocument();

            builder.startElement(new QName("result", SQLModule.NAMESPACE_URI, SQLModule.PREFIX), null);
            builder.addAttribute(new QName("updateCount", null, null), String.valueOf(stmt.getUpdateCount()));
            builder.endElement();
        }

        // Change the root element count attribute to have the correct value
        NodeValue node = (NodeValue) builder.getDocument().getDocumentElement();
        Node count = node.getNode().getAttributes().getNamedItem("count");

        if (count != null) {
            count.setNodeValue(String.valueOf(iRow));
        }

        builder.endDocument();

        // return the XML result set
        return (node);

    } catch (SQLException sqle) {
        LOG.error("sql:execute() Caught SQLException \"" + sqle.getMessage() + "\" for SQL: \"" + sql + "\"",
                sqle);

        //return details about the SQLException
        MemTreeBuilder builder = context.getDocumentBuilder();

        builder.startDocument();
        builder.startElement(new QName("exception", SQLModule.NAMESPACE_URI, SQLModule.PREFIX), null);

        boolean recoverable = false;

        if (sqle instanceof SQLRecoverableException) {
            recoverable = true;
        }
        builder.addAttribute(new QName("recoverable", null, null), String.valueOf(recoverable));

        builder.startElement(new QName("state", SQLModule.NAMESPACE_URI, SQLModule.PREFIX), null);
        builder.characters(sqle.getSQLState());
        builder.endElement();

        builder.startElement(new QName("message", SQLModule.NAMESPACE_URI, SQLModule.PREFIX), null);

        String state = sqle.getMessage();

        if (state != null) {
            builder.characters(state);
        }

        builder.endElement();

        builder.startElement(new QName("stack-trace", SQLModule.NAMESPACE_URI, SQLModule.PREFIX), null);
        ByteArrayOutputStream bufStackTrace = new ByteArrayOutputStream();
        sqle.printStackTrace(new PrintStream(bufStackTrace));
        builder.characters(new String(bufStackTrace.toByteArray()));
        builder.endElement();

        builder.startElement(new QName("sql", SQLModule.NAMESPACE_URI, SQLModule.PREFIX), null);
        builder.characters(SQLUtils.escapeXmlText(sql));
        builder.endElement();

        if (stmt instanceof PreparedStatement) {
            Element parametersElement = (Element) args[2].itemAt(0);

            if (parametersElement.getNamespaceURI().equals(SQLModule.NAMESPACE_URI)
                    && parametersElement.getLocalName().equals(PARAMETERS_ELEMENT_NAME)) {
                NodeList paramElements = parametersElement.getElementsByTagNameNS(SQLModule.NAMESPACE_URI,
                        PARAM_ELEMENT_NAME);

                builder.startElement(
                        new QName(PARAMETERS_ELEMENT_NAME, SQLModule.NAMESPACE_URI, SQLModule.PREFIX), null);

                for (int i = 0; i < paramElements.getLength(); i++) {
                    Element param = ((Element) paramElements.item(i));
                    String value = param.getFirstChild().getNodeValue();
                    String type = param.getAttributeNS(SQLModule.NAMESPACE_URI, TYPE_ATTRIBUTE_NAME);

                    builder.startElement(
                            new QName(PARAM_ELEMENT_NAME, SQLModule.NAMESPACE_URI, SQLModule.PREFIX), null);

                    builder.addAttribute(
                            new QName(TYPE_ATTRIBUTE_NAME, SQLModule.NAMESPACE_URI, SQLModule.PREFIX), type);
                    builder.characters(SQLUtils.escapeXmlText(value));

                    builder.endElement();
                }

                builder.endElement();
            }
        }

        builder.startElement(new QName("xquery", SQLModule.NAMESPACE_URI, SQLModule.PREFIX), null);
        builder.addAttribute(new QName("line", null, null), String.valueOf(getLine()));
        builder.addAttribute(new QName("column", null, null), String.valueOf(getColumn()));
        builder.endElement();

        builder.endElement();
        builder.endDocument();

        return ((NodeValue) builder.getDocument().getDocumentElement());
    } finally {

        // close any record set or statement
        if (rs != null) {

            try {
                rs.close();
            } catch (SQLException se) {
                LOG.warn("Unable to cleanup JDBC results", se);
            }
            rs = null;
        }

        if (!preparedStmt && stmt != null) {

            try {
                stmt.close();
            } catch (SQLException se) {
                LOG.warn("Unable to cleanup JDBC results", se);
            }
            stmt = null;
        }

    }
}

From source file:org.exist.xquery.modules.sql.ExecuteFunction.java

private void setParametersOnPreparedStatement(Statement stmt, Element parametersElement)
        throws SQLException, XPathException {
    if (parametersElement.getNamespaceURI().equals(SQLModule.NAMESPACE_URI)
            && parametersElement.getLocalName().equals(PARAMETERS_ELEMENT_NAME)) {
        NodeList paramElements = parametersElement.getElementsByTagNameNS(SQLModule.NAMESPACE_URI,
                PARAM_ELEMENT_NAME);/*w  w w  .  j av  a2s. c o  m*/

        for (int i = 0; i < paramElements.getLength(); i++) {
            Element param = ((Element) paramElements.item(i));
            Node child = param.getFirstChild();

            // Prevent NPE
            if (child != null) {
                if (child instanceof ReferenceNode) {
                    child = ((ReferenceNode) child).getReference().getNode();
                }

                final String value = child.getNodeValue();
                final String type = param.getAttributeNS(SQLModule.NAMESPACE_URI, TYPE_ATTRIBUTE_NAME);
                final int sqlType = SQLUtils.sqlTypeFromString(type);

                if (sqlType == Types.TIMESTAMP) {
                    final DateTimeValue dv = new DateTimeValue(value);
                    final Timestamp timestampValue = new Timestamp(dv.getDate().getTime());
                    ((PreparedStatement) stmt).setTimestamp(i + 1, timestampValue);

                } else {
                    ((PreparedStatement) stmt).setObject(i + 1, value, sqlType);
                }
            }

        }
    }
}

From source file:org.exist.xquery.xproc.ProcessFunction.java

protected void parseOptions(UserArgs userArgs, Sequence optSeq) throws XPathException {

    if (optSeq.isEmpty())
        return;//from   w w w.  j a  v a2  s. c  om

    SequenceIterator iter = optSeq.iterate();
    while (iter.hasNext()) {
        Element element = (Element) iter.nextItem();

        String localName = element.getLocalName();
        if ("input".equalsIgnoreCase(localName)) {

            String port = element.getAttribute("port");
            if (port == null || port.isEmpty()) {
                throw new XPathException(this, "Input pipe port undefined at '" + element.toString() + "'");
            }

            com.xmlcalabash.util.Input.Type type;
            String _type = element.getAttribute("type");
            if (_type == null || _type.isEmpty()) {
                throw new XPathException(this, "Input pine type undefined at '" + element.toString() + "'");
            } else if ("XML".equalsIgnoreCase(_type)) {
                type = com.xmlcalabash.util.Input.Type.XML;
            } else if ("DATA".equalsIgnoreCase(_type)) {
                type = com.xmlcalabash.util.Input.Type.DATA;
            } else {
                throw new XPathException(this, "Unknown input pine type '" + _type + "'");
            }

            String url = element.getAttribute("url");
            if (url == null || url.isEmpty()) {
                throw new XPathException(this, "Input pine url undefined at '" + element.toString() + "'");
            }

            userArgs.addInput(port, url, type);

        } else if ("output".equalsIgnoreCase(localName)) {

            String port = element.getAttribute("port");
            if (port == null || port.isEmpty()) {
                throw new XPathException(this, "Output pipe port undefined at '" + element.toString() + "'");
            }

            String url = element.getAttribute("url");
            if (url == null || url.isEmpty()) {
                throw new XPathException(this, "Output pine url undefined at '" + element.toString() + "'");
            }

            userArgs.addOutput(port, url);

        } else if ("option".equalsIgnoreCase(localName)) {

            String name = element.getAttribute("name");
            if (name == null || name.isEmpty()) {
                throw new XPathException(this, "Option name undefined at '" + element.toString() + "'");
            }

            String value = element.getAttribute("value");
            if (value == null || value.isEmpty()) {
                throw new XPathException(this, "Option value undefined at '" + element.toString() + "'");
            }

            userArgs.addOption(name, value);
        } else
            throw new XPathException(this, "Unknown option '" + localName + "'.");
    }
}

From source file:org.fireflow.service.email.send.MailSendServiceParser.java

@Override
public ServiceDef deserializeService(Element svcElem) throws DeserializerException {
    String localName_1 = svcElem.getLocalName();
    String namespaceUri_1 = svcElem.getNamespaceURI();

    if (!equalStrings(localName_1, SERVICE_NAME) || !equalStrings(namespaceUri_1, SERVICE_NS_URI)) {
        throw new DeserializerException(
                "The element is not a java service, the element name is '" + localName_1 + "'");
    }//from   w  ww  .  jav  a2  s.  c o  m

    MailSendServiceDef mailSendServiceDef = new MailSendServiceDef();

    this.loadCommonServiceAttribute(mailSendServiceDef, svcElem);

    //?
    Element mailTemplateElem = Util4Deserializer.child(svcElem, this.MAIL_TEMPLATE);
    if (mailTemplateElem != null) {
        String from = Util4Deserializer.elementAsString(mailTemplateElem, FROM);
        mailSendServiceDef.setFrom(from);
        MailTemplate mailTemplate = new MailTemplate();
        mailSendServiceDef.setMailTemplate(mailTemplate);

        Element _childElm = Util4Deserializer.child(mailTemplateElem, MAILTO_LIST);
        if (_childElm != null) {
            Element expElem = Util4Deserializer.child(_childElm, EXPRESSION);
            mailTemplate.setMailToList(this.createExpression(expElem));
        }
        _childElm = Util4Deserializer.child(mailTemplateElem, CARBONCOPY_LIST);
        if (_childElm != null) {
            Element expElem = Util4Deserializer.child(_childElm, EXPRESSION);
            mailTemplate.setCarbonCopyList(this.createExpression(expElem));
        }
        _childElm = Util4Deserializer.child(mailTemplateElem, SUBJECT);
        if (_childElm != null) {
            Element expElem = Util4Deserializer.child(_childElm, EXPRESSION);
            mailTemplate.setSubject(this.createExpression(expElem));
        }

        _childElm = Util4Deserializer.child(mailTemplateElem, EMAIL_BODY);
        if (_childElm != null) {
            Element expElem = Util4Deserializer.child(_childElm, EXPRESSION);
            mailTemplate.setBody(this.createExpression(expElem));
        }

        _childElm = Util4Deserializer.child(mailTemplateElem, BODY_IS_HTML);
        if (_childElm != null) {
            Element expElem = Util4Deserializer.child(_childElm, EXPRESSION);
            mailTemplate.setBodyIsHtml(this.createExpression(expElem));
        }

    }

    //?
    Element connectInfoElem = Util4Deserializer.child(svcElem, CONNECT_INFO);
    String protocol = Util4Deserializer.elementAsString(connectInfoElem, PROTOCOL);
    if (!StringUtils.isEmpty(protocol)) {
        mailSendServiceDef.setProtocol(protocol);
    }

    String serverUrl = Util4Deserializer.elementAsString(connectInfoElem, SERVER_URL);
    mailSendServiceDef.setSmtpServer(serverUrl);

    String port = Util4Deserializer.elementAsString(connectInfoElem, PORT);
    mailSendServiceDef.setSmtpPort(Integer.parseInt(port));

    String needAuth = Util4Deserializer.elementAsString(connectInfoElem, NEED_AUTH);
    mailSendServiceDef.setNeedAuth(Boolean.parseBoolean(needAuth));

    String userName = Util4Deserializer.elementAsString(connectInfoElem, USER_NAME);
    mailSendServiceDef.setUserName(userName);

    String password = Util4Deserializer.elementAsString(connectInfoElem, PASSWORD);
    mailSendServiceDef.setPassword(password);

    String useSSL = Util4Deserializer.elementAsString(connectInfoElem, USE_SSL);
    mailSendServiceDef.setUseSSL(Boolean.parseBoolean(useSSL));

    String charset = Util4Deserializer.elementAsString(connectInfoElem, CHARSET);
    mailSendServiceDef.setCharset(charset);

    this.loadExtendedAttributes(mailSendServiceDef.getExtendedAttributes(),
            Util4Deserializer.child(svcElem, EXTENDED_ATTRIBUTES));

    return mailSendServiceDef;
}

From source file:org.fireflow.service.java.JavaServiceParser.java

public ServiceDef deserializeService(Element element) throws DeserializerException {
    String localName_1 = element.getLocalName();
    String namespaceUri_1 = element.getNamespaceURI();

    if (!equalStrings(localName_1, SERVICE_NAME) || !equalStrings(namespaceUri_1, SERVICE_NS_URI)) {
        throw new DeserializerException(
                "The element is not a java service, the element name is '" + localName_1 + "'");
    }/*from w  w w .j  av a2 s . c o  m*/
    JavaService javaService = new JavaService();
    this.loadCommonServiceAttribute(javaService, element);

    InterfaceDef _interface = loadInterface(Util4Deserializer.child(element, INTERFACE));
    javaService.setInterface(_interface);

    String javaBeanName = Util4Deserializer.elementAsString(element, JAVA_BEAN_NAME);
    if (!StringUtils.isEmpty(javaBeanName)) {
        javaService.setJavaBeanName(javaBeanName);
    }

    String javaClassName = Util4Deserializer.elementAsString(element, JAVA_CLASS_NAME);
    if (!StringUtils.isEmpty(javaClassName)) {
        javaService.setJavaClassName(javaClassName);
    }

    return javaService;
}

From source file:org.infoscoop.util.Xml2Json.java

private String getTagName(Element elem) {
    String name = elem.getLocalName();
    if (name == null)
        name = elem.getNodeName();/*ww w. j a  v  a  2  s .  c  o  m*/
    return name;
}

From source file:org.jboss.bpm.console.server.util.DOMUtils.java

private static void search(List<Element> list, Element baseElement, QName nodeName, boolean recursive) {
    if (nodeName == null) {
        list.add(baseElement);/*from   www .j a v  a 2  s  .  c o  m*/
    } else {
        QName qname;
        if (nodeName.getNamespaceURI().length() > 0) {
            qname = new QName(baseElement.getNamespaceURI(), baseElement.getLocalName());
        } else {
            qname = new QName(baseElement.getLocalName());
        }
        if (qname.equals(nodeName)) {
            list.add(baseElement);
        }
    }
    if (recursive) {
        NodeList nlist = baseElement.getChildNodes();
        for (int i = 0; i < nlist.getLength(); i++) {
            Node child = nlist.item(i);
            if (child.getNodeType() == Node.ELEMENT_NODE) {
                search(list, (Element) child, nodeName, recursive);
            }
        }
    }
}

From source file:org.jbpm.bpel.endpointref.EndpointReference.java

public static EndpointReference readServiceRef(Element referenceElem) {
    String scheme;/*from   www .  jav  a2s. com*/
    Element endpointRefElem;
    // is the given element a service reference container?
    if (BpelConstants.NS_SERVICE_REF.equals(referenceElem.getNamespaceURI())
            && BpelConstants.ELEM_SERVICE_REF.equals(referenceElem.getLocalName())) {
        // read element following the schema of bpel:service-ref
        scheme = referenceElem.getAttribute(BpelConstants.ATTR_REFERENCE_SCHEME);
        endpointRefElem = XmlUtil.getElement(referenceElem);
    } else {
        // assume the given element is the actual endpoint reference value
        scheme = null;
        endpointRefElem = referenceElem;
    }
    // locate a factory that understands this reference
    QName endpointRefName = QNameUtils.newQName(endpointRefElem);
    EndpointReferenceFactory factory = EndpointReferenceFactory.getInstance(endpointRefName, scheme);
    if (factory == null)
        throw new BpelFaultException(BpelConstants.FAULT_UNSUPPORTED_REFERENCE);
    // produce the endpoint reference
    EndpointReference endpointRef = factory.createEndpointReference();
    endpointRef.setScheme(scheme);
    endpointRef.readEndpointRef(endpointRefElem);
    return endpointRef;
}

From source file:org.jbpm.bpel.endpointref.EndpointReference.java

public void writeServiceRef(Element referenceElem) {
    // write the endpoint reference value
    Element endpointRefElem = writeEndpointRef(referenceElem.getOwnerDocument());
    // is the given element a service reference container?
    if (BpelConstants.NS_SERVICE_REF.equals(referenceElem.getNamespaceURI())
            && BpelConstants.ELEM_SERVICE_REF.equals(referenceElem.getLocalName())) {
        // clean the container element
        XmlUtil.removeAttributes(referenceElem);
        XmlUtil.removeChildNodes(referenceElem);
        // set reference scheme attribute
        if (scheme == null || scheme.length() == 0)
            referenceElem.setAttribute(BpelConstants.ATTR_REFERENCE_SCHEME, scheme);
        // add endpoint reference child element
        referenceElem.appendChild(endpointRefElem);
    } else {/*from w  w  w.j  a v a2 s. c o  m*/
        // copy the reference value directly to the given element
        XmlUtil.copy(referenceElem, endpointRefElem);
    }
}

From source file:org.jbpm.bpel.graph.exe.ScopeInstance.java

/**
 * Selects a handler for the internal fault. The handler is selected as follows.
 * <ul>//from   w  ww  . j  a va 2s .c o m
 * <li>if the fault has no data, select a handler with a matching faultName and no faultVariable</li>
 * <li>if the fault has data, select a handler with a matching faultName and a matching
 * faultVariable; if there is no such handler then select a handler with a matching faultVariable
 * and no faultName</li>
 * <li>otherwise, select the catchAll handler if it exists</li>
 * </ul>
 * @return the selected fault handler, or <code>null</code> if no handler is able to catch the
 * fault
 */
public Handler getFaultHandler() {
    if (faultInstance == null)
        throw new IllegalStateException("scope has not faulted");

    // determine the type of fault data
    VariableType dataType;
    // is it a message?
    MessageValue messageValue = faultInstance.getMessageValue();
    if (messageValue != null)
        dataType = messageValue.getType();
    else {
        // is it an element?
        Element elementValue = faultInstance.getElementValue();
        if (elementValue != null) {
            QName elementName = new QName(elementValue.getNamespaceURI(), elementValue.getLocalName());
            dataType = definition.getBpelProcessDefinition().getImportDefinition().getElementType(elementName);
        }
        // it is none of the above
        else
            dataType = null;
    }
    return definition.selectFaultHandler(faultInstance.getName(), dataType);
}