当前位置: 首页>>代码示例>>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;未经允许,请勿转载。