本文整理了Java中org.apache.axiom.om.OMElement.getNamespacesInScope()
方法的一些代码示例,展示了OMElement.getNamespacesInScope()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OMElement.getNamespacesInScope()
方法的具体详情如下:
包路径:org.apache.axiom.om.OMElement
类名称:OMElement
方法名:getNamespacesInScope
[英]Get an iterator that returns all namespaces in scope for this element. This method may be used to determine the namespace context for this element. For any given prefix, the iterator returns at most one OMNamespace object with that prefix, and this object specifies the namespace URI bound to the prefix. The iterator returns an OMNamespace object with an empty prefix if and only if there is a default namespace. It will never return an OMNamespace object with both the prefix and the namespace URI set to the empty string, even if the element or one of its ancestors has a namespace declaration of the form xmlns="".
The order in which the iterator returns the namespaces is undefined, and invoking the Iterator#remove() method on the returned iterator is not supported. The iterator may be a "live" object, which means that results are undefined if the document is modified (in a way that would modify the namespace context for the element) while the iterator is in use.
[中]
代码示例来源:origin: org.apache.synapse/synapse-core
public void setNamespaces(OMElement elem){
Iterator namespaces = elem.getNamespacesInScope();
while (namespaces.hasNext()){
OMNamespace ns = (OMNamespace) namespaces.next();
namespaceList.add(ns);
}
}
代码示例来源:origin: org.apache.ws.commons.axiom/om-aspects
protected Iterator doGetPrefixes(String namespaceURI) {
List prefixes = new ArrayList();
for (Iterator it = element.getNamespacesInScope(); it.hasNext(); ) {
OMNamespace ns = (OMNamespace)it.next();
if (ns.getNamespaceURI().equals(namespaceURI)) {
prefixes.add(ns.getPrefix());
}
}
return prefixes.iterator();
}
}
代码示例来源:origin: org.apache.ws.commons.axiom/axiom-impl
protected Iterator doGetPrefixes(String namespaceURI) {
List prefixes = new ArrayList();
for (Iterator it = element.getNamespacesInScope(); it.hasNext(); ) {
OMNamespace ns = (OMNamespace)it.next();
if (ns.getNamespaceURI().equals(namespaceURI)) {
prefixes.add(ns.getPrefix());
}
}
return prefixes.iterator();
}
}
代码示例来源:origin: org.apache.ws.commons.axiom/axiom-common-impl
protected Iterator doGetPrefixes(String namespaceURI) {
List prefixes = new ArrayList();
for (Iterator it = element.getNamespacesInScope(); it.hasNext(); ) {
OMNamespace ns = (OMNamespace)it.next();
if (ns.getNamespaceURI().equals(namespaceURI)) {
prefixes.add(ns.getPrefix());
}
}
return prefixes.iterator();
}
}
代码示例来源:origin: org.apache.rampart/rampart-policy
private void processElement(OMElement element, SignedEncryptedElements parent) {
if (SP11Constants.XPATH.equals(element.getQName())) {
parent.addXPathExpression(element.getText());
Iterator namespaces = element.getNamespacesInScope();
while (namespaces.hasNext()) {
OMNamespace nm = (OMNamespace) namespaces.next();
parent.addDeclaredNamespaces(nm.getNamespaceURI(), nm.getPrefix());
}
}
}
代码示例来源:origin: org.apache.rampart/rampart-policy
private void processElement(OMElement element, RequiredElements parent) {
QName name = element.getQName();
if (SP12Constants.XPATH.equals(name)) {
parent.addXPathExpression(element.getText());
Iterator namespaces = element.getNamespacesInScope();
while (namespaces.hasNext()) {
OMNamespace nm = (OMNamespace) namespaces.next();
parent.addDeclaredNamespaces(nm.getNamespaceURI(), nm.getPrefix());
}
}
}
代码示例来源:origin: org.apache.rampart/rampart-policy
private void processElement(OMElement element, RequiredElements parent) {
QName name = element.getQName();
if (SP11Constants.XPATH.equals(name)) {
parent.addXPathExpression(element.getText());
Iterator namespaces = element.getNamespacesInScope();
while (namespaces.hasNext()) {
OMNamespace nm = (OMNamespace) namespaces.next();
parent.addDeclaredNamespaces(nm.getNamespaceURI(), nm.getPrefix());
}
}
}
代码示例来源:origin: org.apache.rampart/rampart-policy
private void processElement(OMElement element, SignedEncryptedElements parent) {
QName name = element.getQName();
if (SP11Constants.XPATH.equals(name)) {
parent.addXPathExpression(element.getText());
Iterator namespaces = element.getNamespacesInScope();
while (namespaces.hasNext()) {
OMNamespace nm = (OMNamespace) namespaces.next();
parent.addDeclaredNamespaces(nm.getNamespaceURI(), nm.getPrefix());
}
}
}
代码示例来源:origin: org.apache.rampart/rampart-policy
private void processElement(OMElement element, ContentEncryptedElements parent) {
QName name = element.getQName();
if (SP12Constants.XPATH.equals(name)) {
parent.addXPathExpression(element.getText());
Iterator namespaces = element.getNamespacesInScope();
while (namespaces.hasNext()) {
OMNamespace nm = (OMNamespace) namespaces.next();
parent.addDeclaredNamespaces(nm.getNamespaceURI(), nm.getPrefix());
}
}
}
代码示例来源:origin: org.apache.rampart/rampart-policy
private void processElement(OMElement element, SignedEncryptedElements parent) {
QName name = element.getQName();
if (SP12Constants.XPATH.equals(name)) {
parent.addXPathExpression(element.getText());
Iterator namespaces = element.getNamespacesInScope();
while (namespaces.hasNext()) {
OMNamespace nm = (OMNamespace) namespaces.next();
parent.addDeclaredNamespaces(nm.getNamespaceURI(), nm.getPrefix());
}
}
}
代码示例来源:origin: org.apache.rampart/rampart-policy
private void processElement(OMElement element, SignedEncryptedElements parent) {
if (SP12Constants.XPATH.equals(element.getQName())) {
parent.addXPathExpression(element.getText());
Iterator namespaces = element.getNamespacesInScope();
while (namespaces.hasNext()) {
OMNamespace nm = (OMNamespace) namespaces.next();
parent.addDeclaredNamespaces(nm.getNamespaceURI(), nm.getPrefix());
}
}
}
代码示例来源:origin: org.apache.ws.commons.axiom/axiom-common-impl
public static NamespaceContext getNamespaceContext(OMElement element, boolean detached) {
if (detached) {
Map namespaces = new HashMap();
for (Iterator it = element.getNamespacesInScope(); it.hasNext(); ) {
OMNamespace ns = (OMNamespace)it.next();
namespaces.put(ns.getPrefix(), ns.getNamespaceURI());
}
return new MapBasedNamespaceContext(namespaces);
} else {
return new LiveNamespaceContext(element);
}
}
代码示例来源:origin: org.apache.ws.commons.axiom/om-aspects
public PushOMBuilder(AxiomSourcedElement root) throws XMLStreamException {
this.root = root;
factory = (OMFactoryEx)root.getOMFactory();
// Seed the namespace context with the namespace context from the parent
OMContainer parent = root.getParent();
if (parent instanceof OMElement) {
for (Iterator it = ((OMElement)parent).getNamespacesInScope(); it.hasNext(); ) {
OMNamespace ns = (OMNamespace)it.next();
setPrefix(ns.getPrefix(), ns.getNamespaceURI());
}
}
}
代码示例来源:origin: org.apache.ws.commons.axiom/axiom-impl
public PushOMBuilder(AxiomSourcedElement root) throws XMLStreamException {
this.root = root;
factory = (OMFactoryEx)root.getOMFactory();
// Seed the namespace context with the namespace context from the parent
OMContainer parent = root.getParent();
if (parent instanceof OMElement) {
for (Iterator it = ((OMElement)parent).getNamespacesInScope(); it.hasNext(); ) {
OMNamespace ns = (OMNamespace)it.next();
setPrefix(ns.getPrefix(), ns.getNamespaceURI());
}
}
}
代码示例来源:origin: org.apache.ws.commons.axiom/axiom-api
/**
* Add the namespace declarations of a given {@link OMElement} to the namespace
* context of an XPath expression. Typically this method is used with an XPath
* expression appearing in an attribute of the given element.
* <p>
* Note that the default namespace is explicitly excluded and not added to the
* namespace context. This makes the behaviour of this method consistent with
* the rules followed in XSL stylesheets. Indeed, the XSLT specification defines
* the namespace context of an XPath expression as follows:
* <blockquote>
* the set of namespace declarations are those in scope on the element which has the
* attribute in which the expression occurs; [...] the default namespace
* (as declared by xmlns) is not part of this set
* </blockquote>
*
* @param element the element to retrieve the namespace context from
* @throws JaxenException if an error occurred when adding the namespace declarations
*/
public void addNamespaces(OMElement element) throws JaxenException {
for (Iterator it = element.getNamespacesInScope(); it.hasNext(); ) {
OMNamespace ns = (OMNamespace) it.next();
String prefix = ns.getPrefix();
// Exclude the default namespace as explained in the Javadoc above
if (prefix.length() != 0) {
addNamespace(prefix, ns.getNamespaceURI());
}
}
}
代码示例来源:origin: org.apache.synapse/synapse-core
Iterator it = elem.getNamespacesInScope();
while (it.hasNext()) {
内容来源于网络,如有侵权,请联系作者删除!