Node getPrefix - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Node getPrefix method.

This code example shows how to use the following methods:getLocalName, getPrefix
        String lname;
        doc = (Document) load("staffNS", builder);
        newList = doc.getElementsByTagNameNS("*", "employee");
        assertEquals("employeeCount", 5, newList.getLength());
        newElement = (Element) newList.item(3);
        prefix = newElement.getPrefix();
        assertEquals("prefix", "emp", prefix);
        lname = newElement.getLocalName();
        assertEquals("lname", "employee", lname);
    } 
    public void testGetElementsByTagNameNS3() throws Throwable { 
        Document doc;
        NodeList elementList;
        Node child;
        String childName;
        List<String> result = new ArrayList<String>();
 
        List<String> expectedResult = new ArrayList<String>();
        expectedResult.add("employee");
        expectedResult.add("employeeId");
7
CodeRank
This code example shows how to use the following methods:getName, getNamespaceURI, getNodeName, getNodeValue, getPrefix
        assertEquals("documentcreateattributeNS02_att1_prefix", "xml", prefix);
        assertEquals("documentcreateattributeNS02_att1_namespaceURI", 
                "http://www.w3.org/XML/1998/namespace", namespaceURI);
        attribute2 = doc.createAttributeNS("http://www.w3.org/2000/xmlns/",
                "xmlns"); 
        name = attribute2.getName();
        nodeName = attribute2.getNodeName();
        nodeValue = attribute2.getNodeValue();
        prefix = attribute2.getPrefix();
        namespaceURI = attribute2.getNamespaceURI();
        assertEquals("documentcreateattributeNS02_att2_name", "xmlns", name);
        assertEquals("documentcreateattributeNS02_att2_nodeName", "xmlns", 
                nodeName);
        assertEquals("documentcreateattributeNS02_att2_nodeValue", "", 
                nodeValue);
        assertEquals("documentcreateattributeNS02_att2_namespaceURI", 
                "http://www.w3.org/2000/xmlns/", namespaceURI);
    } 
    public void testCreateAttributeNS3() throws Throwable { 
        Document doc;
8
CodeRank
This code example shows how to use the following methods:getPrefix
 
    /** 
     * @see org.w3c.dom.Node#getPrefix() 
     */ 
    public String getPrefix() {
        return m_attributeNode.getPrefix();
    } 
 
    /** 
     * @see org.w3c.dom.Node#setPrefix(String) 
     */ 
    public void setPrefix(String arg0) throws DOMException {
    } 
 
    /** 
     * @see org.w3c.dom.Node#getLocalName() 
     */ 
    public String getLocalName() {
         
        // For namespace node, the local name is the same as the prefix 
6
CodeRank
This code example shows how to use the following methods:getName, getValue, getLocalName, getNamespaceURI, getPrefix
        Element element = (Element)doc.getDocumentElement().getFirstChild();
        assertTrue(element.hasAttributes());
        NamedNodeMap attributes = element.getAttributes();
        assertEquals(1, attributes.getLength());
        Attr attr = (Attr)attributes.item(0);
        assertEquals("xmlns", attr.getName());
        assertNull(attr.getPrefix());
        assertEquals("xmlns", attr.getLocalName());
        assertEquals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, attr.getNamespaceURI());
        assertEquals("", attr.getValue());
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getOwnerElement, getValue, getLocalName, getNamespaceURI, getPrefix
    /** {@inheritDoc} */ 
    protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
        AttributedString attributedString = (AttributedString) xmlObject;
         
        QName attribQName = 
            XMLHelper.constructQName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute.getPrefix());
        if (AttributedString.WSU_ID_ATTR_NAME.equals(attribQName)) {
            attributedString.setWSUId(attribute.getValue());
            attribute.getOwnerElement().setIdAttributeNode(attribute, true);
        } else { 
            XMLHelper.unmarshallToAttributeMap(attributedString.getUnknownAttributes(), attribute);
        } 
    } 
 
    /** {@inheritDoc} */ 
    protected void processElementContent(XMLObject xmlObject, String elementContent) {
        AttributedString attributedString = (AttributedString) xmlObject;
        attributedString.setValue(elementContent);
    } 
     
6
CodeRank
This code example shows how to use the following methods:getOwnerElement, getValue, getLocalName, getNamespaceURI, getPrefix
    /** {@inheritDoc} */ 
    protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
        AttributedURI attributedURI = (AttributedURI) xmlObject;
         
        QName attribQName = 
            XMLHelper.constructQName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute.getPrefix());
        if (AttributedURI.WSU_ID_ATTR_NAME.equals(attribQName)) {
            attributedURI.setWSUId(attribute.getValue());
            attribute.getOwnerElement().setIdAttributeNode(attribute, true);
        } else { 
            XMLHelper.unmarshallToAttributeMap(attributedURI.getUnknownAttributes(), attribute);
        } 
    } 
 
    /** {@inheritDoc} */ 
    protected void processElementContent(XMLObject xmlObject, String elementContent) {
        AttributedURI attributedURI = (AttributedURI) xmlObject;
        attributedURI.setValue(elementContent);
    } 
     
6
CodeRank
This code example shows how to use the following methods:getLocalName, getNamespaceURI, getPrefix, getTextContent
        } 
        return new XmlPrimitiveAssertion(element);
    } 
     
    protected QName getQName(Element element) {
        if (element.getPrefix() == null) {
            return new QName(element.getNamespaceURI(), element.getLocalName());
        } 
        return new QName(element.getNamespaceURI(), element.getLocalName(), element.getPrefix());
    } 
    public Assertion newPrimitiveAssertion(Element element, Map<QName, String> atts) {
        return new PrimitiveAssertion(getQName(element),
                                      isOptional(element), isIgnorable(element),
                                      atts,
                                      element.getTextContent());
    } 
    public Assertion newPolicyContainingAssertion(Element element, Map<QName, String> atts, Policy policy) {
        return new PolicyContainingPrimitiveAssertion(getQName(element),
                                      isOptional(element), isIgnorable(element),
                                      policy);
6
CodeRank
This code example shows how to use the following methods:getValue, isId, getLocalName, getNamespaceURI, getPrefix
    } 
 
    /** {@inheritDoc} */ 
    protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
        Body body = (Body) xmlObject;
        QName attribQName = XMLHelper.constructQName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute
                .getPrefix());
        if (attribute.isId()) {
            body.getUnknownAttributes().registerID(attribQName);
        } 
        body.getUnknownAttributes().put(attribQName, attribute.getValue());
    } 
 
    /** {@inheritDoc} */ 
    protected void processElementContent(XMLObject xmlObject, String elementContent) {
        // do nothing, no child content 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getLocalName, getNamespaceURI, getPrefix
		this.startLine = startLine;
		this.endLine = endLine;
 
		// If a DOM node given then retrieve the relevant information 
		if (node != null) {
			localName = node.getLocalName();
			prefix = node.getPrefix();
			namespaceURI = node.getNamespaceURI();
		} 
	} 
	 
	public XmlSourceLocation(XmlSourceLocation location) {
		resource = location.getResource();
		localName = location.getLocalName();
		prefix = location.getPrefix();
		namespaceURI = location.getNamespaceURI();
		startLine = location.getStartLine();
		endLine = location.getEndLine();
	} 
 
7
CodeRank
This code example shows how to use the following methods:getOwnerElement, getValue, getLocalName, getNamespaceURI, getPrefix
    /** {@inheritDoc} */ 
    protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
        SignatureConfirmation sc = (SignatureConfirmation) xmlObject;
         
        QName attrName =
            XMLHelper.constructQName(attribute.getNamespaceURI(), attribute.getLocalName(), attribute.getPrefix());
        if (SignatureConfirmation.WSU_ID_ATTR_NAME.equals(attrName)) {
            sc.setWSUId(attribute.getValue());
            attribute.getOwnerElement().setIdAttributeNode(attribute, true);
        } else if (SignatureConfirmation.VALUE_ATTRIB_NAME.equals(attribute.getLocalName())) {
            sc.setValue(attribute.getValue());
        } else { 
            super.processAttribute(xmlObject, attribute);
        } 
    } 
 
} 
6
CodeRank
getPrefix Method Overview
The namespace prefix of this node, or null if it is unspecified.
See Code Examples for other Java 8 Node Methods: