本文整理匯總了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;
}
}
}
示例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;
}
示例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
}
}
示例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;
}
}
示例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;
}
示例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;
}