當前位置: 首頁>>代碼示例>>Java>>正文


Java XMLConstants.XML_NS_URI屬性代碼示例

本文整理匯總了Java中javax.xml.XMLConstants.XML_NS_URI屬性的典型用法代碼示例。如果您正苦於以下問題:Java XMLConstants.XML_NS_URI屬性的具體用法?Java XMLConstants.XML_NS_URI怎麽用?Java XMLConstants.XML_NS_URI使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在javax.xml.XMLConstants的用法示例。


在下文中一共展示了XMLConstants.XML_NS_URI屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getNamespaceURI

@Override
public String getNamespaceURI(String prefix) {
	if (XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)) {
		if (defaultNamespaceURI == null) {
			return XMLConstants.NULL_NS_URI;
		} else {
			return defaultNamespaceURI;
		}
	} else if (XMLConstants.XML_NS_PREFIX.equals(prefix)) {
		return XMLConstants.XML_NS_URI;
	} else if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) {
		return XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
	} else if (prefix == null) {
		throw new IllegalArgumentException("Null prefix not allowed");
	} else {
		String uri = idNamespacesMap.get(prefix);
		if (uri == null) {
			return XMLConstants.NULL_NS_URI;
		} else {
			return uri;
		}
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:23,代碼來源:MapBasedNamespaceContext.java

示例2: resolveNamespacePrefix

private String resolveNamespacePrefix( String prefix ) {
    if(prefix.equals("xml"))
        return XMLConstants.XML_NS_URI;

    for( int i=nsLen-2; i>=0; i-=2 ) {
        if(prefix.equals(nsBind[i]))
            return nsBind[i+1];
    }

    if(environmentNamespaceContext!=null)
        // temporary workaround until Zephyr fixes 6337180
        return environmentNamespaceContext.getNamespaceURI(prefix.intern());

    // by default, the default ns is bound to "".
    // but allow environmentNamespaceContext to take precedence
    if(prefix.equals(""))
        return "";

    // unresolved. error.
    return null;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:21,代碼來源:UnmarshallingContext.java

示例3: testXPath13

@Test
public void testXPath13() throws Exception {
    QName qname = new QName(XMLConstants.XML_NS_URI, "");

    XPathFactory xpathFactory = XPathFactory.newInstance();
    Assert.assertNotNull(xpathFactory);

    XPath xpath = xpathFactory.newXPath();
    Assert.assertNotNull(xpath);

    try {
        xpath.evaluate("1+1", (Object) null, qname);
        Assert.fail("failed , expected IAE not thrown");
    } catch (IllegalArgumentException e) {
        ; // as expected
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:Bug4991939.java

示例4: getNamespaceURI

@Override
public String getNamespaceURI(String prefix) {
    if (null == prefix) {
        throw new IllegalArgumentException("prefix");
    } else if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) {
        return XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
    } else if (XMLConstants.XML_NS_PREFIX.equals(prefix)) {
        return XMLConstants.XML_NS_URI;
    } else if ("my".equals(prefix)) {
        return "http://www.example.com/my";
    } else {
        return XMLConstants.NULL_NS_URI;
    }
}
 
開發者ID:SimY4,項目名稱:xpath-to-xml,代碼行數:14,代碼來源:SimpleNamespaceContext.java

示例5: getNamespaceURI

@SuppressWarnings({"StringEquality"})
public String getNamespaceURI(String prefix) {
    if (prefix == null) {
        throw new IllegalArgumentException("Prefix cannot be null");
    }

    /*
     * If the buffer was created using string interning
     * intern the prefix and check for reference equality
     * rather than using String.equals();
     */
    if (_stringInterningFeature) {
        prefix = prefix.intern();

        // Find the most recently declared prefix
        for (int i = _namespaceAIIsEnd - 1; i >=0; i--) {
            if (prefix == _namespaceAIIsPrefix[i]) {
                return _namespaceAIIsNamespaceName[i];
            }
        }
    } else {
        // Find the most recently declared prefix
        for (int i = _namespaceAIIsEnd - 1; i >=0; i--) {
            if (prefix.equals(_namespaceAIIsPrefix[i])) {
                return _namespaceAIIsNamespaceName[i];
            }
        }
    }

    // Check for XML-based prefixes
    if (prefix.equals(XMLConstants.XML_NS_PREFIX)) {
        return XMLConstants.XML_NS_URI;
    } else if (prefix.equals(XMLConstants.XMLNS_ATTRIBUTE)) {
        return XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
    }

    return null;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:38,代碼來源:StreamReaderBufferProcessor.java

示例6: getNamespaceURI

public String getNamespaceURI(String prefix) {
    Node parent = e;
    String namespace = null;
    final String prefixColon = prefix + ':';

    if (prefix.equals("xml")) {
        namespace = XMLConstants.XML_NS_URI;
    } else {
        int type;

        while ((null != parent) && (null == namespace)
                && (((type = parent.getNodeType()) == Node.ELEMENT_NODE)
                || (type == Node.ENTITY_REFERENCE_NODE))) {
            if (type == Node.ELEMENT_NODE) {
                if (parent.getNodeName().startsWith(prefixColon))
                    return parent.getNamespaceURI();
                NamedNodeMap nnm = parent.getAttributes();

                for (int i = 0; i < nnm.getLength(); i++) {
                    Node attr = nnm.item(i);
                    String aname = attr.getNodeName();
                    boolean isPrefix = aname.startsWith("xmlns:");

                    if (isPrefix || aname.equals("xmlns")) {
                        int index = aname.indexOf(':');
                        String p = isPrefix ? aname.substring(index + 1) : "";

                        if (p.equals(prefix)) {
                            namespace = attr.getNodeValue();

                            break;
                        }
                    }
                }
            }

            parent = parent.getParentNode();
        }
    }

    if(prefix.equals(""))
        return "";  // default namespace
    return namespace;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:44,代碼來源:NamespaceContextImpl.java


注:本文中的javax.xml.XMLConstants.XML_NS_URI屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。