本文整理了Java中org.apache.axiom.om.OMAttribute.getNamespace()
方法的一些代码示例,展示了OMAttribute.getNamespace()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OMAttribute.getNamespace()
方法的具体详情如下:
包路径:org.apache.axiom.om.OMAttribute
类名称:OMAttribute
方法名:getNamespace
暂无
代码示例来源:origin: org.bluestemsoftware.open.eoa.ext/open-eoa-aspect-axiom
/** @see org.apache.axiom.om.OMElement#getAllAttributes() */
public Iterator getAllAttributes() {
if (attributes == null) {
return EMPTY_ITERATOR;
}
ArrayList list = new ArrayList();
for (int i = 0; i < attributes.getLength(); i++) {
OMAttribute item = (OMAttribute) attributes.getItem(i);
if (item.getNamespace() == null
|| !(item.getNamespace() != null && OMConstants.XMLNS_NS_URI
.equals(item.getNamespace().getNamespaceURI()))) {
list.add(item);
}
}
return list.iterator();
}
代码示例来源:origin: org.apache.abdera/abdera-parser
public List<QName> getExtensionAttributes() {
List<QName> list = new ArrayList<QName>();
for (Iterator i = getAllAttributes(); i.hasNext();) {
OMAttribute attr = (OMAttribute)i.next();
String namespace = (attr.getNamespace() != null) ? attr.getNamespace().getNamespaceURI() : "";
if (!namespace.equals(getNamespace().getNamespaceURI()) && !namespace.equals(""))
list.add(attr.getQName());
}
return Collections.unmodifiableList(list);
}
代码示例来源:origin: deegree/deegree3
private static void writeAttribute( XMLStreamWriter writer, OMAttribute attrib )
throws XMLStreamException {
writer.writeAttribute( attrib.getNamespace().getNamespaceURI(), attrib.getAttributeValue() );
}
代码示例来源:origin: org.apache.neethi/neethi
public Map<QName, String> getAttributes(OMElement s) {
Map<QName, String> mp = new HashMap<QName, String>();
Iterator<?> it = s.getAllAttributes();
while (it.hasNext()) {
OMAttribute attr = (OMAttribute)it.next();
if (attr.getNamespace() == null) {
mp.put(new QName("", attr.getLocalName()),
attr.getAttributeValue());
} else {
mp.put(new QName(attr.getNamespace().getNamespaceURI(), attr.getLocalName()),
attr.getAttributeValue());
}
}
return mp;
}
代码示例来源:origin: usnistgov/iheos-toolkit2
String getAttributeName(OMAttribute a) {
attNamespace = a.getNamespace();
String prefix = "";
if (attNamespace != null) {
prefix = attNamespace.getPrefix();
if (prefix != null && !prefix.equals(""))
prefix = prefix + ":";
// if (nsPrefix != null && nsPrefix.equals("xml")) {
// prefix = "xml:";
// attNamespace = null; // so namespace does not get added to element
// }
}
String attName = a.getLocalName();
return prefix + attName;
}
代码示例来源:origin: org.bluestemsoftware.open.eoa.ext/open-eoa-aspect-axiom
/** @see org.apache.axiom.om.OMElement#addAttribute (org.apache.axiom.om.OMAttribute) */
public OMAttribute addAttribute(OMAttribute attr) {
OMNamespace namespace = attr.getNamespace();
if (namespace != null && namespace.getNamespaceURI() != null
&& !"".equals(namespace.getNamespaceURI())
&& this.findNamespace(namespace.getNamespaceURI(), namespace
.getPrefix()) == null) {
this.declareNamespace(namespace.getNamespaceURI(), namespace.getPrefix());
}
if (attr.getNamespace() != null) { // If the attr has a namespace
return (AttrImpl) this.setAttributeNode((Attr) attr);
} else {
return (AttrImpl) this.setAttributeNodeNS((Attr) attr);
}
}
代码示例来源:origin: org.bluestemsoftware.open.eoa.ext/open-eoa-aspect-axiom
/**
* @param i
* @return Returns String.
* @see javax.xml.stream.XMLStreamReader#getAttributeNamespace
*/
public String getAttributeNamespace(int i) {
String returnString = null;
if (parser != null) {
returnString = parser.getAttributeNamespace(i);
} else {
if (isStartElement() || (currentEvent == ATTRIBUTE)) {
OMAttribute attrib = getAttribute((OMElement) lastNode, i);
if (attrib != null) {
OMNamespace nameSpace = attrib.getNamespace();
if (nameSpace != null) {
returnString = nameSpace.getNamespaceURI();
}
}
} else {
throw new IllegalStateException(
"attribute nameSpace accessed in illegal event!");
}
}
return returnString;
}
代码示例来源:origin: org.apache.ws.commons.axiom/axiom-api
/**
* Retrieves the QName of the given attribute node.
*
* @param object the context attribute node
* @return Returns the qualified name of the attribute node.
*/
public String getAttributeQName(Object object) {
OMAttribute attr = (OMAttribute) object;
String prefix = attr.getNamespace().getPrefix();
if (prefix == null || "".equals(prefix)) {
return attr.getLocalName();
}
return prefix + ":" + attr.getLocalName();
}
代码示例来源:origin: org.apache.ws.commons.axiom/axiom-common-impl
/**
* @param i
* @return Returns String.
* @see javax.xml.stream.XMLStreamReader#getAttributeNamespace
*/
public String getAttributeNamespace(int i) {
String returnString = null;
if (parser != null) {
returnString = parser.getAttributeNamespace(i);
} else {
if (isStartElement()) {
loadAttributes();
OMAttribute attrib = attributes[i];
if (attrib != null) {
OMNamespace nameSpace = attrib.getNamespace();
if (nameSpace != null) {
returnString = nameSpace.getNamespaceURI();
}
}
} else {
throw new IllegalStateException(
"attribute nameSpace accessed in illegal event!");
}
}
return returnString;
}
代码示例来源:origin: org.apache.ws.commons.axiom/axiom-impl
private Map<String,String> getAllNamespaces(OMSerializable contextNode) {
if (contextNode == null) {
return Collections.emptyMap();
}
OMContainer context;
if (contextNode instanceof OMContainer) {
context = (OMContainer)contextNode;
} else {
context = ((OMNode)contextNode).getParent();
}
Map<String,String> nsMap = new LinkedHashMap<String,String>();
while (context != null && !(context instanceof OMDocument)) {
OMElement element = (OMElement) context;
for (Iterator it = element.getAllDeclaredNamespaces(); it.hasNext(); ) {
addNamespaceToMap((OMNamespace) it.next(), nsMap);
}
if (element.getNamespace() != null) {
addNamespaceToMap(element.getNamespace(), nsMap);
}
for (Iterator it = element.getAllAttributes(); it.hasNext(); ) {
OMAttribute attr = (OMAttribute) it.next();
if (attr.getNamespace() != null) {
addNamespaceToMap(attr.getNamespace(), nsMap);
}
}
context = element.getParent();
}
return nsMap;
}
代码示例来源:origin: org.bluestemsoftware.open.eoa.ext/open-eoa-aspect-axiom
/**
* @param i
* @return Returns String.
* @see javax.xml.stream.XMLStreamReader#getAttributeLocalName
*/
public String getAttributeLocalName(int i) {
String returnString = null;
if (parser != null) {
returnString = parser.getAttributeLocalName(i);
} else {
if (isStartElement() || (currentEvent == ATTRIBUTE)) {
OMAttribute attrib = getAttribute((OMElement) lastNode, i);
if (attrib != null) {
if (attrib.getNamespace() != null) {
returnString = attrib.getLocalName();
} else {
returnString = ((Attr) attrib).getNodeName();
}
}
} else {
throw new IllegalStateException(
"attribute localName accessed in illegal event!");
}
}
return returnString;
}
代码示例来源:origin: org.apache.ws.commons.axiom/om-aspects
private Map<String,String> getAllNamespaces(OMSerializable contextNode) {
if (contextNode == null) {
return Collections.emptyMap();
}
OMContainer context;
if (contextNode instanceof OMContainer) {
context = (OMContainer)contextNode;
} else {
context = ((OMNode)contextNode).getParent();
}
Map<String,String> nsMap = new LinkedHashMap<String,String>();
while (context != null && !(context instanceof OMDocument)) {
OMElement element = (OMElement) context;
for (Iterator it = element.getAllDeclaredNamespaces(); it.hasNext(); ) {
addNamespaceToMap((OMNamespace) it.next(), nsMap);
}
if (element.getNamespace() != null) {
addNamespaceToMap(element.getNamespace(), nsMap);
}
for (Iterator it = element.getAllAttributes(); it.hasNext(); ) {
OMAttribute attr = (OMAttribute) it.next();
if (attr.getNamespace() != null) {
addNamespaceToMap(attr.getNamespace(), nsMap);
}
}
context = element.getParent();
}
return nsMap;
}
代码示例来源:origin: org.apache.ws.commons.axiom/axiom-common-impl
iter != null && iter.hasNext();) {
OMAttribute attr = (OMAttribute) iter.next();
if (attr.getNamespace() != null) {
addNamespaceToMap(attr.getNamespace(), nsMap);
代码示例来源:origin: org.bluestemsoftware.open.eoa.ext/open-eoa-aspect-axiom
/**
* @param i
* @return Returns String.
* @see javax.xml.stream.XMLStreamReader#getAttributePrefix
*/
public String getAttributePrefix(int i) {
String returnString = null;
if (parser != null) {
returnString = parser.getAttributePrefix(i);
} else {
if (isStartElement() || (currentEvent == ATTRIBUTE)) {
OMAttribute attrib = getAttribute((OMElement) lastNode, i);
if (attrib != null) {
OMNamespace nameSpace = attrib.getNamespace();
if (nameSpace != null) {
returnString = nameSpace.getPrefix();
}
}
} else {
throw new IllegalStateException(
"attribute prefix accessed in illegal event!");
}
}
return returnString;
}
代码示例来源:origin: org.apache.ws.commons.axiom/axiom-common-impl
/**
* @param i
* @return Returns String.
* @see javax.xml.stream.XMLStreamReader#getAttributePrefix
*/
public String getAttributePrefix(int i) {
String returnString = null;
if (parser != null) {
returnString = parser.getAttributePrefix(i);
} else {
if (isStartElement()) {
loadAttributes();
OMAttribute attrib = attributes[i];
if (attrib != null) {
OMNamespace nameSpace = attrib.getNamespace();
if (nameSpace != null) {
returnString = nameSpace.getPrefix();
}
}
} else {
throw new IllegalStateException(
"attribute prefix accessed in illegal event!");
}
}
return returnString;
}
代码示例来源:origin: org.apache.axis2/axis2-adb
newOMAttribute = omFactory.createOMAttribute(
omAttribute.getLocalName(),
omAttribute.getNamespace(),
omAttribute.getAttributeValue());
newOMElement.addAttribute(newOMAttribute);
代码示例来源:origin: org.bluestemsoftware.open.eoa.ext/open-eoa-aspect-axiom
/**
* Method serializeAttribute.
*
* @param attr
* @param writer
* @throws XMLStreamException
*/
static void serializeAttribute(OMAttribute attr, XMLStreamWriter writer)
throws XMLStreamException {
// first check whether the attribute is associated with a namespace
OMNamespace ns = attr.getNamespace();
String prefix;
String namespaceName;
if (ns != null) {
// add the prefix if it's availble
prefix = ns.getPrefix();
namespaceName = ns.getNamespaceURI();
if (prefix != null) {
writer.writeAttribute(prefix, namespaceName, attr
.getLocalName(), attr.getAttributeValue());
} else {
writer.writeAttribute(namespaceName, attr.getLocalName(), attr
.getAttributeValue());
}
} else {
writer
.writeAttribute(attr.getLocalName(), attr
.getAttributeValue());
}
}
代码示例来源:origin: org.apache.ws.commons.axiom/axiom-api
OMNamespace ns = attr.getNamespace();
String prefix = null;
String namespaceName = null;
代码示例来源:origin: apache/axis2-java
newOMAttribute = omFactory.createOMAttribute(
omAttribute.getLocalName(),
omAttribute.getNamespace(),
omAttribute.getAttributeValue());
newOMElement.addAttribute(newOMAttribute);
代码示例来源:origin: org.apache.ws.commons.axiom/axiom-api
/**
* In Axiom, a single tree should always contain objects created from the same type of factory
* (eg: LinkedListImplFactory, DOMFactory, etc.,). This method will convert omAttribute to the
* given omFactory.
*
* @see ElementHelper#importOMElement(OMElement, OMFactory) to convert instances of OMElement
*/
public static void importOMAttribute(OMAttribute omAttribute, OMElement omElement) {
// first check whether the given OMAttribute has the same OMFactory
if (omAttribute.getOMFactory().getMetaFactory() == omElement.getOMFactory().getMetaFactory()) {
omElement.addAttribute(omAttribute);
} else {
OMNamespace ns = omAttribute.getNamespace();
omElement.addAttribute(omAttribute.getLocalName(), omAttribute.getAttributeValue(),
omElement.getOMFactory().createOMNamespace(ns.getNamespaceURI(), ns.getPrefix()));
}
}
}
内容来源于网络,如有侵权,请联系作者删除!