Example usage for org.w3c.dom Element getOwnerDocument

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

Introduction

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

Prototype

public Document getOwnerDocument();

Source Link

Document

The Document object associated with this node.

Usage

From source file:org.apache.axis2.wsdl.codegen.emitter.AxisServiceBasedMultiLanguageEmitter.java

/**
 * set the short type as it is in the data binding
 *
 * @param paramElement//w ww  .j a v  a  2s  . c  o  m
 * @param xmlName
 */

protected void addShortType(Element paramElement, String xmlName) {

    if (xmlName != null) {
        String javaName;
        if (JavaUtils.isJavaKeyword(xmlName)) {
            javaName = JavaUtils.makeNonJavaKeyword(xmlName);
        } else {
            javaName = JavaUtils.capitalizeFirstChar(JavaUtils.xmlNameToJava(xmlName));
        }
        addAttribute(paramElement.getOwnerDocument(), "shorttype", javaName, paramElement);
    } else {
        addAttribute(paramElement.getOwnerDocument(), "shorttype", "", paramElement);
    }
}

From source file:org.apache.camel.component.cxf.CxfConsumer.java

public CxfConsumer(final CxfEndpoint endpoint, Processor processor) throws Exception {
    super(endpoint, processor);

    // create server
    ServerFactoryBean svrBean = endpoint.createServerFactoryBean();
    svrBean.setInvoker(new Invoker() {

        // we receive a CXF request when this method is called
        public Object invoke(Exchange cxfExchange, Object o) {
            if (LOG.isTraceEnabled()) {
                LOG.trace("Received CXF Request: " + cxfExchange);
            }/*  w  w w.j a v  a  2s.  c  o  m*/
            Continuation continuation = getContinuation(cxfExchange);
            // Only calling the continuation API for CXF 2.3.x 
            if (continuation != null && !endpoint.isSynchronous()
                    && Version.getCurrentVersion().startsWith("2.3")) {
                if (LOG.isTraceEnabled()) {
                    LOG.trace("Calling the Camel async processors.");
                }
                return asyncInvoke(cxfExchange, continuation);
            } else {
                if (LOG.isTraceEnabled()) {
                    LOG.trace("Calling the Camel sync processors.");
                }
                return syncInvoke(cxfExchange);
            }
        }

        // NOTE this code cannot work with CXF 2.2.x
        private Object asyncInvoke(Exchange cxfExchange, final Continuation continuation) {
            synchronized (continuation) {
                if (continuation.isNew()) {
                    final org.apache.camel.Exchange camelExchange = perpareCamelExchange(cxfExchange);

                    // Now we don't set up the timeout value
                    if (LOG.isTraceEnabled()) {
                        LOG.trace("Suspending continuation of exchangeId: " + camelExchange.getExchangeId());
                    }
                    // TODO Support to set the timeout in case the Camel can't send the response back on time.
                    // The continuation could be called before the suspend is called
                    continuation.suspend(0);

                    // use the asynchronous API to process the exchange
                    getAsyncProcessor().process(camelExchange, new AsyncCallback() {
                        public void done(boolean doneSync) {
                            // make sure the continuation resume will not be called before the suspend method in other thread
                            synchronized (continuation) {
                                if (LOG.isTraceEnabled()) {
                                    LOG.trace("Resuming continuation of exchangeId: "
                                            + camelExchange.getExchangeId());
                                }
                                // resume processing after both, sync and async callbacks
                                continuation.setObject(camelExchange);
                                continuation.resume();
                            }
                        }
                    });

                }
                if (continuation.isResumed()) {
                    org.apache.camel.Exchange camelExchange = (org.apache.camel.Exchange) continuation
                            .getObject();
                    setResponseBack(cxfExchange, camelExchange);

                }
            }
            return null;
        }

        private Continuation getContinuation(Exchange cxfExchange) {
            ContinuationProvider provider = (ContinuationProvider) cxfExchange.getInMessage()
                    .get(ContinuationProvider.class.getName());
            return provider == null ? null : provider.getContinuation();
        }

        private Object syncInvoke(Exchange cxfExchange) {
            org.apache.camel.Exchange camelExchange = perpareCamelExchange(cxfExchange);
            // send Camel exchange to the target processor
            if (LOG.isTraceEnabled()) {
                LOG.trace("Processing +++ START +++");
            }
            try {
                getProcessor().process(camelExchange);
            } catch (Exception e) {
                throw new Fault(e);
            }
            if (LOG.isTraceEnabled()) {
                LOG.trace("Processing +++ END +++");
            }
            setResponseBack(cxfExchange, camelExchange);
            // response should have been set in outMessage's content
            return null;
        }

        private org.apache.camel.Exchange perpareCamelExchange(Exchange cxfExchange) {
            // get CXF binding
            CxfEndpoint endpoint = (CxfEndpoint) getEndpoint();
            CxfBinding binding = endpoint.getCxfBinding();

            // create a Camel exchange
            org.apache.camel.Exchange camelExchange = endpoint.createExchange();
            DataFormat dataFormat = endpoint.getDataFormat();

            BindingOperationInfo boi = cxfExchange.getBindingOperationInfo();
            // make sure the "boi" is remained as wrapped in PAYLOAD mode
            if (dataFormat == DataFormat.PAYLOAD && boi.isUnwrapped()) {
                boi = boi.getWrappedOperation();
                cxfExchange.put(BindingOperationInfo.class, boi);
            }

            if (boi != null) {
                camelExchange.setProperty(BindingOperationInfo.class.getName(), boi);
                if (LOG.isTraceEnabled()) {
                    LOG.trace("Set exchange property: BindingOperationInfo: " + boi);
                }
            }

            // set data format mode in Camel exchange
            camelExchange.setProperty(CxfConstants.DATA_FORMAT_PROPERTY, dataFormat);
            if (LOG.isTraceEnabled()) {
                LOG.trace("Set Exchange property: " + DataFormat.class.getName() + "=" + dataFormat);
            }

            camelExchange.setProperty(Message.MTOM_ENABLED, String.valueOf(endpoint.isMtomEnabled()));

            // bind the CXF request into a Camel exchange
            binding.populateExchangeFromCxfRequest(cxfExchange, camelExchange);
            // extract the javax.xml.ws header
            Map<String, Object> context = new HashMap<String, Object>();
            binding.extractJaxWsContext(cxfExchange, context);
            // put the context into camelExchange
            camelExchange.setProperty(CxfConstants.JAXWS_CONTEXT, context);
            return camelExchange;

        }

        @SuppressWarnings("unchecked")
        private void setResponseBack(Exchange cxfExchange, org.apache.camel.Exchange camelExchange) {
            CxfEndpoint endpoint = (CxfEndpoint) getEndpoint();
            CxfBinding binding = endpoint.getCxfBinding();

            checkFailure(camelExchange);

            // bind the Camel response into a CXF response
            if (camelExchange.getPattern().isOutCapable()) {
                binding.populateCxfResponseFromExchange(camelExchange, cxfExchange);
            }

            // check failure again as fault could be discovered by converter
            checkFailure(camelExchange);

            // copy the headers javax.xml.ws header back
            binding.copyJaxWsContext(cxfExchange,
                    (Map<String, Object>) camelExchange.getProperty(CxfConstants.JAXWS_CONTEXT));
        }

        private void checkFailure(org.apache.camel.Exchange camelExchange) throws Fault {
            final Throwable t;
            if (camelExchange.isFailed()) {
                t = (camelExchange.hasOut() && camelExchange.getOut().isFault())
                        ? camelExchange.getOut().getBody(Throwable.class)
                        : camelExchange.getException();
                if (t instanceof Fault) {
                    throw (Fault) t;
                } else if (t != null) {
                    // This is not a CXF Fault. Build the CXF Fault manuallly.
                    Fault fault = new Fault(t);
                    if (fault.getMessage() == null) {
                        // The Fault has no Message. This is the case if t had
                        // no message, for
                        // example was a NullPointerException.
                        fault.setMessage(t.getClass().getSimpleName());
                    }
                    WebFault faultAnnotation = t.getClass().getAnnotation(WebFault.class);
                    Object faultInfo = null;
                    try {
                        Method method = t.getClass().getMethod("getFaultInfo", new Class[0]);
                        faultInfo = method.invoke(t, new Object[0]);
                    } catch (Exception e) {
                        // do nothing here                            
                    }
                    if (faultAnnotation != null && faultInfo == null) {
                        // t has a JAX-WS WebFault annotation, which describes
                        // in detail the Web Service Fault that should be thrown. Add the
                        // detail.
                        Element detail = fault.getOrCreateDetail();
                        Element faultDetails = detail.getOwnerDocument()
                                .createElementNS(faultAnnotation.targetNamespace(), faultAnnotation.name());
                        detail.appendChild(faultDetails);
                    }

                    throw fault;
                }

            }
        }

    });
    server = svrBean.create();
    if (ObjectHelper.isNotEmpty(endpoint.getPublishedEndpointUrl())) {
        server.getEndpoint().getEndpointInfo().setProperty("publishedEndpointUrl",
                endpoint.getPublishedEndpointUrl());
    }
}

From source file:org.apache.camel.spring.handler.CamelNamespaceHandler.java

/**
 * Used for auto registering producer and consumer templates if not already defined in XML.
 *//*from  w ww.  j  av  a  2s  . c  o m*/
protected void registerTemplates(Element element, ParserContext parserContext, String contextId) {
    boolean template = false;
    boolean consumerTemplate = false;

    NodeList list = element.getChildNodes();
    int size = list.getLength();
    for (int i = 0; i < size; i++) {
        Node child = list.item(i);
        if (child instanceof Element) {
            Element childElement = (Element) child;
            String localName = childElement.getLocalName();
            if ("template".equals(localName)) {
                template = true;
            } else if ("consumerTemplate".equals(localName)) {
                consumerTemplate = true;
            }
        }
    }

    if (!template) {
        // either we have not used template before or we have auto registered it already and therefore we
        // need it to allow to do it so it can remove the existing auto registered as there is now a clash id
        // since we have multiple camel contexts
        boolean existing = autoRegisterMap.get("template") != null;
        boolean inUse = false;
        try {
            inUse = parserContext.getRegistry().isBeanNameInUse("template");
        } catch (BeanCreationException e) {
            // Spring Eclipse Tooling may throw an exception when you edit the Spring XML online in Eclipse
            // when the isBeanNameInUse method is invoked, so ignore this and continue (CAMEL-2739)
            LOG.debug("Error checking isBeanNameInUse(template). This exception will be ignored", e);
        }
        if (!inUse || existing) {
            String id = "template";
            // auto create a template
            Element templateElement = element.getOwnerDocument().createElement("template");
            templateElement.setAttribute("id", id);
            BeanDefinitionParser parser = parserMap.get("template");
            BeanDefinition definition = parser.parse(templateElement, parserContext);

            // auto register it
            autoRegisterBeanDefinition(id, definition, parserContext, contextId);
        }
    }

    if (!consumerTemplate) {
        // either we have not used template before or we have auto registered it already and therefore we
        // need it to allow to do it so it can remove the existing auto registered as there is now a clash id
        // since we have multiple camel contexts
        boolean existing = autoRegisterMap.get("consumerTemplate") != null;
        boolean inUse = false;
        try {
            inUse = parserContext.getRegistry().isBeanNameInUse("consumerTemplate");
        } catch (BeanCreationException e) {
            // Spring Eclipse Tooling may throw an exception when you edit the Spring XML online in Eclipse
            // when the isBeanNameInUse method is invoked, so ignore this and continue (CAMEL-2739)
            LOG.debug("Error checking isBeanNameInUse(consumerTemplate). This exception will be ignored", e);
        }
        if (!inUse || existing) {
            String id = "consumerTemplate";
            // auto create a template
            Element templateElement = element.getOwnerDocument().createElement("consumerTemplate");
            templateElement.setAttribute("id", id);
            BeanDefinitionParser parser = parserMap.get("consumerTemplate");
            BeanDefinition definition = parser.parse(templateElement, parserContext);

            // auto register it
            autoRegisterBeanDefinition(id, definition, parserContext, contextId);
        }
    }

}

From source file:org.apache.cocoon.webapps.session.context.RequestSessionContext.java

/**
 * Build attributes XML/*from   w w  w  . j  a  v a 2  s. c o m*/
 */
private void buildMiscXML(Element root) {
    Document doc = root.getOwnerDocument();

    Element node;

    node = doc.createElementNS(null, "characterEncoding");
    node.appendChild(this.createTextNode(doc, this.request.getCharacterEncoding()));
    root.appendChild(node);
    node = doc.createElementNS(null, "contentLength");
    node.appendChild(this.createTextNode(doc, "" + this.request.getContentLength()));
    root.appendChild(node);
    node = doc.createElementNS(null, "contentType");
    node.appendChild(this.createTextNode(doc, this.request.getContentType()));
    root.appendChild(node);
    node = doc.createElementNS(null, "protocol");
    node.appendChild(this.createTextNode(doc, this.request.getProtocol()));
    root.appendChild(node);
    node = doc.createElementNS(null, "remoteAddress");
    node.appendChild(this.createTextNode(doc, this.request.getRemoteAddr()));
    root.appendChild(node);
    node = doc.createElementNS(null, "remoteHost");
    node.appendChild(this.createTextNode(doc, this.request.getRemoteHost()));
    root.appendChild(node);
    node = doc.createElementNS(null, "scheme");
    node.appendChild(this.createTextNode(doc, this.request.getScheme()));
    root.appendChild(node);
    node = doc.createElementNS(null, "serverName");
    node.appendChild(this.createTextNode(doc, this.request.getServerName()));
    root.appendChild(node);
    node = doc.createElementNS(null, "serverPort");
    node.appendChild(this.createTextNode(doc, "" + this.request.getServerPort()));
    root.appendChild(node);
    node = doc.createElementNS(null, "method");
    node.appendChild(this.createTextNode(doc, this.request.getMethod()));
    root.appendChild(node);
    node = doc.createElementNS(null, "contextPath");
    node.appendChild(this.createTextNode(doc, this.request.getContextPath()));
    root.appendChild(node);
    node = doc.createElementNS(null, "pathInfo");
    node.appendChild(this.createTextNode(doc, this.request.getPathInfo()));
    root.appendChild(node);
    node = doc.createElementNS(null, "pathTranslated");
    node.appendChild(this.createTextNode(doc, this.request.getPathTranslated()));
    root.appendChild(node);
    node = doc.createElementNS(null, "remoteUser");
    node.appendChild(this.createTextNode(doc, this.request.getRemoteUser()));
    root.appendChild(node);
    node = doc.createElementNS(null, "requestedSessionId");
    node.appendChild(this.createTextNode(doc, this.request.getRequestedSessionId()));
    root.appendChild(node);
    node = doc.createElementNS(null, "requestURI");
    node.appendChild(this.createTextNode(doc, this.request.getRequestURI()));
    root.appendChild(node);
    node = doc.createElementNS(null, "servletPath");
    node.appendChild(this.createTextNode(doc, this.request.getServletPath()));
    root.appendChild(node);
    node = doc.createElementNS(null, "isRequestedSessionIdFromCookie");
    node.appendChild(
            doc.createTextNode(BooleanUtils.toStringTrueFalse(this.request.isRequestedSessionIdFromCookie())));
    root.appendChild(node);
    node = doc.createElementNS(null, "isRequestedSessionIdFromURL");
    node.appendChild(
            doc.createTextNode(BooleanUtils.toStringTrueFalse(this.request.isRequestedSessionIdFromURL())));
    root.appendChild(node);
    node = doc.createElementNS(null, "isRequestedSessionIdValid");
    node.appendChild(
            doc.createTextNode(BooleanUtils.toStringTrueFalse(this.request.isRequestedSessionIdValid())));
    root.appendChild(node);
}

From source file:org.apache.cocoon.webapps.session.context.RequestSessionContext.java

/**
 * Build attributes XML//  w  w w .  j  a va 2  s .  co  m
 */
private void buildAttributesXML(Element root) throws ProcessingException {
    Document doc = root.getOwnerDocument();
    Element attrElement = doc.createElementNS(null, "attributes");
    String attrName;
    Element attr;

    root.appendChild(attrElement);
    Enumeration all = this.request.getAttributeNames();
    while (all.hasMoreElements() == true) {
        attrName = (String) all.nextElement();
        try {
            attr = doc.createElementNS(null, attrName);
            attrElement.appendChild(attr);
            DOMUtil.valueOf(attr, this.request.getAttribute(attrName));
        } catch (DOMException de) {
            // Some request attributes have names that are invalid as element names.
            // Example : "FOM JavaScript GLOBAL SCOPE/file://my/path/to/flow/script.js"
            this.logger.info("RequestSessionContext: Cannot create XML element from request attribute '"
                    + attrName + "' : " + de.getMessage());
        }
    }
}

From source file:org.apache.cocoon.webapps.session.context.RequestSessionContext.java

/**
 * Build cookies XML/*  w w  w  .  j  av  a2s  . c o  m*/
 */
private void buildCookiesXML(Element root) {
    Document doc = root.getOwnerDocument();

    Element cookiesElement = doc.createElementNS(null, "cookies");
    root.appendChild(cookiesElement);

    Cookie[] cookies = this.request.getCookies();
    if (cookies != null) {
        Cookie current;
        Element node;
        Element parent;
        for (int i = 0; i < cookies.length; i++) {
            current = cookies[i];
            parent = doc.createElementNS(null, "cookie");
            parent.setAttributeNS(null, "name", current.getName());
            cookiesElement.appendChild(parent);
            node = doc.createElementNS(null, "comment");
            node.appendChild(this.createTextNode(doc, current.getComment()));
            parent.appendChild(node);
            node = doc.createElementNS(null, "domain");
            node.appendChild(this.createTextNode(doc, current.getDomain()));
            parent.appendChild(node);
            node = doc.createElementNS(null, "maxAge");
            node.appendChild(this.createTextNode(doc, "" + current.getMaxAge()));
            parent.appendChild(node);
            node = doc.createElementNS(null, "name");
            node.appendChild(this.createTextNode(doc, current.getName()));
            parent.appendChild(node);
            node = doc.createElementNS(null, "path");
            node.appendChild(this.createTextNode(doc, current.getPath()));
            parent.appendChild(node);
            node = doc.createElementNS(null, "secure");
            node.appendChild(doc.createTextNode(BooleanUtils.toStringTrueFalse(current.getSecure())));
            parent.appendChild(node);
            node = doc.createElementNS(null, "value");
            node.appendChild(this.createTextNode(doc, current.getValue()));
            parent.appendChild(node);
            node = doc.createElementNS(null, "version");
            node.appendChild(this.createTextNode(doc, "" + current.getVersion()));
            parent.appendChild(node);
        }
    }
}

From source file:org.apache.cocoon.webapps.session.context.RequestSessionContext.java

/**
 * Build headers XML//from   w  w  w  .  ja v  a 2 s. co  m
 */
private void buildHeadersXML(Element root) {
    Document doc = root.getOwnerDocument();
    Element headersElement = doc.createElementNS(null, "headers");
    String headerName;
    Element header;

    root.appendChild(headersElement);
    Enumeration all = this.request.getHeaderNames();
    while (all.hasMoreElements() == true) {
        headerName = (String) all.nextElement();
        try {
            header = doc.createElementNS(null, headerName);
            headersElement.appendChild(header);
            header.appendChild(this.createTextNode(doc, this.request.getHeader(headerName)));
        } catch (Exception ignore) {
            // if the header name is not a valid element name, we simply ignore it
        }
    }
}

From source file:org.apache.cocoon.webapps.session.context.RequestSessionContext.java

/**
 * Build parameter XML//ww w  .j a  va2 s. c o  m
 */
private void buildParameterXML(Element root, SAXParser parser) {
    Document doc = root.getOwnerDocument();
    // include all parameters
    // process "/parameter" and "/parametervalues" at the same time
    Element parameterElement = doc.createElementNS(null, "parameter");
    Element parameterValuesElement = doc.createElementNS(null, "parametervalues");
    root.appendChild(parameterElement);
    root.appendChild(parameterValuesElement);
    String parameterName = null;
    Enumeration pars = this.request.getParameterNames();
    Element parameter;
    Element element;
    Node valueNode;
    String[] values;
    String parValue;

    element = doc.createElementNS(CIncludeTransformer.CINCLUDE_NAMESPACE_URI, PARAMETERS_ELEMENT);
    element.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:cinclude",
            CIncludeTransformer.CINCLUDE_NAMESPACE_URI);
    parameterValuesElement.appendChild(element);
    parameterValuesElement = element;

    while (pars.hasMoreElements() == true) {
        parameterName = (String) pars.nextElement();
        values = this.request.getParameterValues(parameterName);

        for (int i = 0; i < values.length; i++) {

            // this is a fast test, if the parameter value contains xml!
            parValue = values[i].trim();
            if (parValue.length() > 0 && parValue.charAt(0) == '<') {
                try {
                    valueNode = DOMUtil.getDocumentFragment(parser, new StringReader(parValue));
                    valueNode = doc.importNode(valueNode, true);
                } catch (Exception noXMLException) {
                    valueNode = doc.createTextNode(parValue);
                }
            } else {
                valueNode = doc.createTextNode(parValue);
            }
            // create "/parameter" entry for first value
            if (i == 0) {
                try {
                    parameter = doc.createElementNS(null, parameterName);
                    parameter.appendChild(valueNode);
                    parameterElement.appendChild(parameter);
                } catch (Exception local) {
                    // the exception is ignored and only this parameters is ignored
                }
            }

            try {
                // create "/parametervalues" entry
                element = doc.createElementNS(CIncludeTransformer.CINCLUDE_NAMESPACE_URI, PARAMETER_ELEMENT);
                parameterValuesElement.appendChild(element);
                parameter = element;
                element = doc.createElementNS(CIncludeTransformer.CINCLUDE_NAMESPACE_URI, NAME_ELEMENT);
                parameter.appendChild(element);
                element.appendChild(doc.createTextNode(parameterName));
                element = doc.createElementNS(CIncludeTransformer.CINCLUDE_NAMESPACE_URI, VALUE_ELEMENT);
                parameter.appendChild(element);
                element.appendChild(valueNode.cloneNode(true));
            } catch (Exception local) {
                // the exception is ignored and only this parameters is ignored
            }
        }
    }
    // and now the query string
    element = doc.createElementNS(null, "querystring");
    root.appendChild(element);
    String value = request.getQueryString();
    if (value != null) {
        element.appendChild(doc.createTextNode('?' + value));
    }
}

From source file:org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBindingParser.java

void parseElement(JAXWSBinding jaxwsBinding, Element element) {
    Node child = element.getFirstChild();
    if (child == null) {
        // global binding
        if (isAsyncElement(element)) {
            jaxwsBinding.setEnableAsyncMapping(getNodeValue(element));
        }//ww  w .  j a v a  2  s. c o  m
        if (isMIMEElement(element)) {
            jaxwsBinding.setEnableMime(getNodeValue(element));
        }
        if (isPackageElement(element)) {
            jaxwsBinding.setPackage(getPackageName(element));
        }

        if (isWrapperStyle(element)) {
            jaxwsBinding.setEnableWrapperStyle(getNodeValue(element));
        }
    } else {
        // other binding
        while (child != null) {
            if (isAsyncElement(child)) {
                jaxwsBinding.setEnableAsyncMapping(getNodeValue(child));
            } else if (isMIMEElement(child)) {
                jaxwsBinding.setEnableMime(getNodeValue(child));
            } else if (isWrapperStyle(child)) {
                jaxwsBinding.setEnableWrapperStyle(getNodeValue(child));
            } else if (isPackageElement(child)) {
                jaxwsBinding.setPackage(getPackageName(child));
                Node docChild = DOMUtils.getChild(child, Element.ELEMENT_NODE);
                if (docChild != null && this.isJAXWSClassDoc(docChild)) {
                    jaxwsBinding.setPackageJavaDoc(StringEscapeUtils.escapeHtml(DOMUtils.getContent(docChild)));
                }
            } else if (isJAXWSMethodElement(child)) {
                jaxwsBinding.setMethodName(getMethodName(child));
                Node docChild = DOMUtils.getChild(child, Element.ELEMENT_NODE);

                if (docChild != null && this.isJAXWSClassDoc(docChild)) {
                    jaxwsBinding.setMethodJavaDoc(StringEscapeUtils.escapeHtml(DOMUtils.getContent(docChild)));
                }
            } else if (isJAXWSParameterElement(child)) {
                Element childElement = (Element) child;
                String partPath = "//" + childElement.getAttribute("part");
                Node node = queryXPathNode(element.getOwnerDocument().getDocumentElement(), partPath);
                String messageName = "";
                String partName = "";
                if (node != null) {
                    partName = ((Element) node).getAttribute("name");
                    Node messageNode = node.getParentNode();
                    if (messageNode != null) {
                        Element messageEle = (Element) messageNode;
                        messageName = messageEle.getAttribute("name");
                    }
                }

                String name = childElement.getAttribute("name");
                String elementNameString = childElement.getAttribute("childElementName");
                QName elementName = null;
                if (!StringUtils.isEmpty(elementNameString)) {
                    String ns = "";
                    if (elementNameString.indexOf(':') != -1) {
                        ns = elementNameString.substring(0, elementNameString.indexOf(':'));
                        ns = childElement.lookupNamespaceURI(ns);
                        elementNameString = elementNameString.substring(elementNameString.indexOf(':') + 1);
                    }
                    elementName = new QName(ns, elementNameString);
                }
                JAXWSParameter jpara = new JAXWSParameter(messageName, partName, elementName, name);
                jaxwsBinding.addJaxwsPara(jpara);
            } else if (isJAXWSClass(child)) {
                Element childElement = (Element) child;
                String clzName = childElement.getAttribute("name");
                String javadoc = "";
                Node docChild = DOMUtils.getChild(child, Element.ELEMENT_NODE);

                if (docChild != null && this.isJAXWSClassDoc(docChild)) {
                    javadoc = StringEscapeUtils.escapeHtml(DOMUtils.getContent(docChild));
                }

                JAXWSClass jaxwsClass = new JAXWSClass(clzName, javadoc);
                jaxwsBinding.setJaxwsClass(jaxwsClass);
            }
            child = child.getNextSibling();
        }
    }

}

From source file:org.apache.empire.db.DBReader.java

/**
 * Returns a XML document with the field description an values of this record.
 * /*from   w w w . j  a v  a 2 s . c  o  m*/
 * @return the new XML Document object
 */
@Override
public Document getXmlDocument() {
    if (rset == null)
        return null;
    // Create Document
    String rowsetElementName = getXmlDictionary().getRowSetElementName();
    Element root = XMLUtil.createDocument(rowsetElementName);
    // Add Field Description
    addColumnDesc(root);
    // Add row rset
    addRows(root);
    // return Document
    return root.getOwnerDocument();
}