本文整理了Java中org.apache.axiom.om.OMElement.getDefaultNamespace()
方法的一些代码示例,展示了OMElement.getDefaultNamespace()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OMElement.getDefaultNamespace()
方法的具体详情如下:
包路径:org.apache.axiom.om.OMElement
类名称:OMElement
方法名:getDefaultNamespace
[英]Get the default namespace in scope on this element.
[中]获取此元素作用域中的默认命名空间。
代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.common.ui
public static String getNamespaceURI(String name, OMElement currentElement) {
String prefix = getPrefix(name);
OMNamespace namespace = null;
if (prefix != null) {
namespace = currentElement.findNamespace(null, prefix);
} else {
// if the prefix is null we can't assume the namespace is null
namespace = currentElement.getDefaultNamespace();
}
if (namespace == null) {
return null;
}
return namespace.getNamespaceURI();
}
代码示例来源:origin: org.apache.ws.commons.axiom/axiom-c14n
public NamedNodeMap getAttributes() {
if (nnm == null) { // ok now nnm == null implies this is the first time call to this method
list = new ArrayList();
nnm = new NamedNodeMapImpl(list, e, fac);
Iterator itr = e.getAllAttributes();
while (itr.hasNext()) {
list.add(itr.next());
}
itr = e.getAllDeclaredNamespaces();
while (itr.hasNext()) {
list.add(itr.next());
}
Object parent = e.getParent();
if (parent instanceof OMElement) {
OMNamespace defaultNS = e.getDefaultNamespace();
OMNamespace defaultParentNS = ((OMElement) parent).getDefaultNamespace();
if (defaultNS != null && defaultParentNS != null &&
defaultNS.getNamespaceURI().equals(defaultParentNS.getNamespaceURI())) {
list.remove(defaultNS);
}
}
}
return nnm;
}
代码示例来源:origin: org.wso2.bpel/ode-bpel-epr
@SuppressWarnings("unchecked")
private static void buildNScontext(NSContext nscontext, OMElement element) {
if (element == null)
return;
if (element.getParent() instanceof OMElement)
buildNScontext(nscontext, (OMElement) element.getParent());
if (element.getAllDeclaredNamespaces() != null)
for (Iterator<OMNamespace> i=element.getAllDeclaredNamespaces(); i.hasNext(); ){
OMNamespace omn = i.next();
nscontext.register(omn.getPrefix(), omn.getNamespaceURI());
}
if (element.getDefaultNamespace() != null)
nscontext.register("", element.getDefaultNamespace().getNamespaceURI());
}
代码示例来源:origin: org.wso2.carbon.governance/org.wso2.carbon.governance.lcm
public static List evaluateXpath(OMElement contentElement, String xpathString,String nsPrefix) {
List ret = new ArrayList();
try {
AXIOMXPath xpath = new AXIOMXPath(xpathString);
Iterator nsIterator = contentElement.getAllDeclaredNamespaces();
if (nsIterator.hasNext()) {
while (nsIterator.hasNext()) {
OMNamespace next = (OMNamespace) nsIterator.next();
xpath.addNamespace(nsPrefix, next.getNamespaceURI());
ret.addAll(xpath.selectNodes(contentElement));
}
}else if(contentElement.getDefaultNamespace() != null){
xpath.addNamespace(nsPrefix, contentElement.getDefaultNamespace().getNamespaceURI());
ret.addAll(xpath.selectNodes(contentElement));
}else if(nsPrefix != null){
xpathString = xpathString.replace(nsPrefix + ":","");
xpath = new AXIOMXPath(xpathString);
ret.addAll(xpath.selectNodes(contentElement));
}else{
xpath = new AXIOMXPath(xpathString);
ret.addAll(xpath.selectNodes(contentElement));
}
return ret;
} catch (Exception e) {
log.error(e);
}
return null;
}
代码示例来源:origin: org.wso2.carbon.governance/org.wso2.carbon.governance.registry.extensions
resultsList.addAll(xpath.selectNodes(contentElement));
} else if (contentElement.getDefaultNamespace() != null) {
xpath.addNamespace(nsPrefix, contentElement.getDefaultNamespace().getNamespaceURI());
resultsList.addAll(xpath.selectNodes(contentElement));
} else if (nsPrefix != null) {
代码示例来源:origin: org.ballerinalang/ballerina-core
/**
* {@inheritDoc}
*/
@Override
public BMap<?, ?> getAttributesMap() {
BMap<String, BString> attrMap = new BMap<>(new BMapType(BTypes.typeString));
if (nodeType != XMLNodeType.ELEMENT) {
return attrMap;
}
OMNamespace defaultNs = ((OMElement) omNode).getDefaultNamespace();
String namespaceOfPrefix = '{' + (defaultNs == null ? XMLConstants.XMLNS_ATTRIBUTE_NS_URI :
defaultNs.getNamespaceURI()) + '}';
Iterator<OMNamespace> namespaceIterator = ((OMElement) omNode).getAllDeclaredNamespaces();
while (namespaceIterator.hasNext()) {
OMNamespace namespace = namespaceIterator.next();
String prefix = namespace.getPrefix();
if (prefix.isEmpty()) {
continue;
}
attrMap.put(namespaceOfPrefix + prefix, new BString(namespace.getNamespaceURI()));
}
Iterator<OMAttribute> attrIterator = ((OMElement) omNode).getAllAttributes();
while (attrIterator.hasNext()) {
OMAttribute attr = attrIterator.next();
attrMap.put(attr.getQName().toString(), new BString(attr.getAttributeValue()));
}
return attrMap;
}
代码示例来源:origin: usnistgov/iheos-toolkit2
void element(OMElement ele, boolean isTop) {
OMNamespace myNamespace = ele.getNamespace();
String myNamespaceUri = (myNamespace != null) ? myNamespace.getNamespaceURI() : null;
OMNamespace defaultNamespace = ele.getDefaultNamespace();
String defaultNamespaceUri = (defaultNamespace != null) ? defaultNamespace.getNamespaceURI() : null;
String prefix;
OMNamespace parentsDefaultNamespace = parent.getDefaultNamespace();
parentsDefaultNamespaceUri = parentsDefaultNamespace.getNamespaceURI();
} catch (Exception e) {}
代码示例来源:origin: org.ballerinalang/ballerina-core
if ((node.getDefaultNamespace() != null && namespaceUri.equals(node.getDefaultNamespace().getNamespaceURI()))
|| namespaceUri.equals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI)) {
内容来源于网络,如有侵权,请联系作者删除!