Example usage for org.w3c.dom Node getNamespaceURI

List of usage examples for org.w3c.dom Node getNamespaceURI

Introduction

In this page you can find the example usage for org.w3c.dom Node getNamespaceURI.

Prototype

public String getNamespaceURI();

Source Link

Document

The namespace URI of this node, or null if it is unspecified (see ).

Usage

From source file:org.eclipse.lyo.testsuite.oslcv2.QueryTests.java

public void checkLessThanProperty(NodeList resultList, String queryProperty, String qVal, Document doc) {
    String queryPropertyNS = "*";
    String queryPropertyName = queryProperty;
    if (queryProperty.contains(":")) {
        queryPropertyNS = queryProperty.substring(0, queryProperty.indexOf(':'));
        queryPropertyName = queryProperty.substring(queryProperty.indexOf(':') + 1);
    }//w w w  . j  a  va  2s  .  c  o m
    for (int i = 0; i < resultList.getLength(); i++) {
        NodeList elements = resultList.item(i).getChildNodes();
        for (int j = 0; j < elements.getLength(); j++) {
            Node element = elements.item(j);
            if (element.getLocalName() != null && element.getLocalName().equals(queryPropertyName)
                    && (element.getNamespaceURI().equals(doc.lookupNamespaceURI(queryPropertyNS))
                            || queryPropertyNS.equals("*"))) {
                assertTrue(element.getTextContent().compareTo(qVal) < 0);
            }
        }
    }
}

From source file:org.eclipse.lyo.testsuite.oslcv2.QueryTests.java

public void checkGreaterThanProperty(NodeList resultList, String queryProperty, String qVal, Document doc) {
    String queryPropertyNS = "*";
    String queryPropertyName = queryProperty;
    if (queryProperty.contains(":")) {
        queryPropertyNS = queryProperty.substring(0, queryProperty.indexOf(':'));
        queryPropertyName = queryProperty.substring(queryProperty.indexOf(':') + 1);
    }/*w w w .j av a 2s. c  o m*/
    for (int i = 0; i < resultList.getLength(); i++) {
        NodeList elements = resultList.item(i).getChildNodes();
        for (int j = 0; j < elements.getLength(); j++) {
            Node element = elements.item(j);
            if (element.getLocalName() != null && element.getLocalName().equals(queryPropertyName)
                    && (element.getNamespaceURI().equals(doc.lookupNamespaceURI(queryPropertyNS))
                            || queryPropertyNS.equals("*"))) {
                assertTrue(element.getTextContent().compareTo(qVal) >= 0);
            }
        }
    }
}

From source file:org.eclipse.lyo.testsuite.oslcv2.QueryTests.java

public void checkEqualityProperty(NodeList resultList, String queryProperty, String qVal, Document doc) {
    String queryPropertyNS = "*";
    String queryPropertyName = queryProperty;
    if (queryProperty.contains(":")) {
        queryPropertyNS = queryProperty.substring(0, queryProperty.indexOf(':'));
        queryPropertyName = queryProperty.substring(queryProperty.indexOf(':') + 1);
    }//from w  w w  .  j  a v  a  2 s .c  om
    for (int i = 0; i < resultList.getLength(); i++) {
        NodeList elements = resultList.item(i).getChildNodes();
        for (int j = 0; j < elements.getLength(); j++) {
            Node element = elements.item(j);
            if (element.getLocalName() != null && element.getLocalName().equals(queryPropertyName)
                    && (element.getNamespaceURI().equals(doc.lookupNamespaceURI(queryPropertyNS))
                            || queryPropertyNS.equals("*"))) {
                // TODO: Determine if OSLC queries are case-sensitive.
                assertTrue(qVal.equalsIgnoreCase(element.getTextContent()));
            }
        }
    }
}

From source file:de.betterform.xml.xforms.ui.Item.java

private Element findElement(NodeList nodes, String namespace, String localName) {
    for (int i = 0; i < nodes.getLength(); i++) {
        Node child = nodes.item(i);
        if (child instanceof Element) {
            if (child.getNamespaceURI().equals(namespace) && child.getLocalName().equals(localName)) {
                return (Element) child;
            }//from www .  j  av  a2 s .c o m
        }
    }
    return null;
}

From source file:com.apatar.buzzsaw.BuzzsawNode.java

private void addDinamicFieldToList(Node node) {
    String fieldNameSpace = node.getNamespaceURI();
    String fieldName = node.getLocalName();

    // does node have children or not
    if (node.hasChildNodes()) {
        for (int i = 0; i < node.getChildNodes().getLength(); i++) {
            if (1 == node.getChildNodes().item(i).getNodeType()) {
                addDinamicFieldToList(node.getChildNodes().item(i));
            }//  ww w .  ja v  a  2 s  . c  o m
        }
    }

    // is this bazzsaw property or not
    if ("http://www.buzzsaw.com/projectpoint".equalsIgnoreCase(fieldNameSpace)) {
        fieldName = "Buzzsaw_" + fieldName;
    }

    // does dinamicFields have fieldName or not
    if (!dinamicFields.contains(fieldName)) {
        dinamicFields.add(fieldName);
    }
}

From source file:org.apache.taverna.activities.wsdl.T2WSDLSOAPInvoker.java

@Override
protected void addSoapHeader(SOAPEnvelope envelope) throws SOAPException {
    if (wsrfEndpointReference != null) {

        // Extract elements
        // Add WSA-stuff
        // Add elements

        Document wsrfDoc;/* ww w. ja  v a  2 s  .c o  m*/
        try {
            wsrfDoc = parseWsrfEndpointReference(wsrfEndpointReference);
        } catch (Exception e) {
            logger.warn("Could not parse endpoint reference, ignoring:\n" + wsrfEndpointReference, e);
            return;
        }

        Element wsrfRoot = wsrfDoc.getDocumentElement();

        Element endpointRefElem = null;
        if (!wsrfRoot.getNamespaceURI().equals(WSA200403NS)
                || !wsrfRoot.getLocalName().equals(ENDPOINT_REFERENCE)) {
            // Only look for child if the parent is not an EPR
            NodeList nodes = wsrfRoot.getChildNodes();
            for (int i = 0, n = nodes.getLength(); i < n; i++) {
                Node node = nodes.item(i);
                if (Node.ELEMENT_NODE == node.getNodeType() && node.getLocalName().equals(ENDPOINT_REFERENCE)
                        && node.getNamespaceURI().equals(WSA200403NS)) {
                    // Support wrapped endpoint reference for backward compatibility
                    // and convenience (T2-677)
                    endpointRefElem = (Element) node;
                    break;
                }
            }
        }

        if (endpointRefElem == null) {
            logger.warn("Unexpected element name for endpoint reference, but inserting anyway: "
                    + wsrfRoot.getTagName());
            endpointRefElem = wsrfRoot;
        }

        Element refPropsElem = null;
        NodeList nodes = endpointRefElem.getChildNodes();
        for (int i = 0, n = nodes.getLength(); i < n; i++) {
            Node node = nodes.item(i);
            if (Node.ELEMENT_NODE == node.getNodeType() && node.getLocalName().equals(REFERENCE_PROPERTIES)
                    && node.getNamespaceURI().equals(WSA200403NS)) {
                refPropsElem = (Element) node;
                break;
            }
        }
        if (refPropsElem == null) {
            logger.warn("Could not find " + REFERENCE_PROPERTIES);
            return;
        }

        SOAPHeader header = envelope.getHeader();
        if (header == null) {
            header = envelope.addHeader();
        }

        NodeList refProps = refPropsElem.getChildNodes();

        for (int i = 0, n = refProps.getLength(); i < n; i++) {
            Node node = refProps.item(i);

            if (Node.ELEMENT_NODE == node.getNodeType()) {
                SOAPElement soapElement = SOAPFactory.newInstance().createElement((Element) node);
                header.addChildElement(soapElement);

                Iterator<SOAPHeaderElement> headers = header.examineAllHeaderElements();
                while (headers.hasNext()) {
                    SOAPHeaderElement headerElement = headers.next();
                    if (headerElement.getElementQName().equals(soapElement.getElementQName())) {
                        headerElement.setMustUnderstand(false);
                        headerElement.setActor(null);
                    }
                }
            }
        }
    }
}

From source file:com.apatar.buzzsaw.BuzzsawNode.java

private void putPropertyValueToTable(Node node, KeyInsensitiveMap datas) {
    String fieldNameSpace = node.getNamespaceURI();
    String fieldName = node.getLocalName();
    String fieldValue = node.getTextContent();

    // does node have children or not
    if (node.hasChildNodes()) {
        for (int i = 0; i < node.getChildNodes().getLength(); i++) {
            if (1 == node.getChildNodes().item(i).getNodeType()) {
                putPropertyValueToTable(node.getChildNodes().item(i), datas);
            }//from   w  ww. j  a  v a  2 s.  c  o  m
        }
    }

    // is this bazzsaw property or not
    if ("http://www.buzzsaw.com/projectpoint".equalsIgnoreCase(fieldNameSpace)) {
        fieldName = "Buzzsaw_" + fieldName;
    }

    List<Record> recs = getTiForConnection(OUT_CONN_POINT_NAME).getRecords();
    Record rec = Record.getRecordByFieldName(recs, fieldName);
    if (rec != null) {
        datas.put(fieldName, new JdbcObject(fieldValue, rec.getSqlType()));
    }
}

From source file:com.centeractive.ws.builder.soap.XmlUtils.java

public static boolean hasContentAttributes(Element elm) {
    NamedNodeMap attributes = elm.getAttributes();
    for (int c = 0; c < attributes.getLength(); c++) {
        Node item = attributes.item(c);
        String ns = item.getNamespaceURI();
        if (!ns.equals(Constants.XML_NS)
        // && !ns.equals( Constants.XSI_NS ) && !ns.equals(
        // Constants.XSI_NS_2000 )
        // && !ns.equals( Constants.XSD_NS )
        )//w  w  w.ja va 2s .  c o  m
            return true;
    }

    return false;
}

From source file:org.eclipse.lyo.testsuite.oslcv2.ServiceProviderXmlTests.java

@Test
public void serviceProviderHasAtMostOnePublisher() throws XPathExpressionException {
    //Get the listed ServiceProvider elements
    NodeList providerChildren = (NodeList) OSLCUtils.getXPath().evaluate("//oslc_v2:ServiceProvider/*", doc,
            XPathConstants.NODESET);
    int numPublishers = 0;
    for (int i = 0; i < providerChildren.getLength(); i++) {
        Node child = providerChildren.item(i);
        if (child.getLocalName() != null && child.getNamespaceURI().equals(OSLCConstants.DC)
                && child.getLocalName().equals("publisher")) {
            numPublishers++;// w ww. j a  v  a2  s .  c  om
        }
    }
    assert (numPublishers <= 1);
}

From source file:com.eviware.soapui.impl.wsdl.submit.transports.http.support.attachments.WsdlMimeMessageResponse.java

private void expandMtomAttachments(WsdlRequest wsdlRequest) {
    try {/*w w w.  j a va 2 s . com*/
        // XmlObject xmlObject = XmlObject.Factory.parse( getContentAsString()
        // );
        XmlObject xmlObject = XmlUtils.createXmlObject(getContentAsString());
        XmlObject[] includes = xmlObject
                .selectPath("declare namespace xop='http://www.w3.org/2004/08/xop/include'; //xop:Include");

        for (XmlObject include : includes) {
            Element elm = (Element) include.getDomNode();
            String href = elm.getAttribute("href");
            Attachment attachment = getMmSupport().getAttachmentWithContentId("<" + href.substring(4) + ">");
            if (attachment != null) {
                ByteArrayOutputStream data = Tools.readAll(attachment.getInputStream(), 0);
                byte[] byteArray = data.toByteArray();

                XmlCursor cursor = include.newCursor();
                cursor.toParent();
                XmlObject parentXmlObject = cursor.getObject();
                cursor.dispose();

                SchemaType schemaType = parentXmlObject.schemaType();
                Node parentNode = elm.getParentNode();

                if (schemaType.isNoType()) {
                    SchemaTypeSystem typeSystem = wsdlRequest.getOperation().getInterface().getWsdlContext()
                            .getSchemaTypeSystem();
                    SchemaGlobalElement schemaElement = typeSystem
                            .findElement(new QName(parentNode.getNamespaceURI(), parentNode.getLocalName()));
                    if (schemaElement != null) {
                        schemaType = schemaElement.getType();
                    }
                }

                String txt = null;

                if (SchemaUtils.isInstanceOf(schemaType, XmlHexBinary.type)) {
                    txt = new String(Hex.encodeHex(byteArray));
                } else {
                    txt = new String(Base64.encodeBase64(byteArray));
                }

                parentNode.replaceChild(elm.getOwnerDocument().createTextNode(txt), elm);
            }
        }

        getMmSupport().setResponseContent(xmlObject.toString());
    } catch (Exception e) {
        SoapUI.logError(e);
    }
}