本文整理了Java中org.dom4j.Element.getNamespacePrefix()
方法的一些代码示例,展示了Element.getNamespacePrefix()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getNamespacePrefix()
方法的具体详情如下:
包路径:org.dom4j.Element
类名称:Element
方法名:getNamespacePrefix
[英]Returns the namespace prefix of this element if one exists otherwise an empty String
is returned.
[中]返回此元素的命名空间前缀(如果存在),否则返回空String
。
代码示例来源:origin: org.freemarker/freemarker
@Override
String getNamespacePrefix(Object node) {
if (node instanceof Element) {
return ((Element) node).getNamespacePrefix();
}
if (node instanceof Attribute) {
return ((Attribute) node).getNamespacePrefix();
}
return null;
}
代码示例来源:origin: igniterealtime/Openfire
@Override
boolean processUnknowPacket(Element doc) throws UnauthorizedException {
// Handle subsequent db:result packets
if ("db".equals(doc.getNamespacePrefix()) && "result".equals(doc.getName())) {
if (!((LocalIncomingServerSession) session).validateSubsequentDomain(doc)) {
throw new UnauthorizedException("Failed to validate domain when using piggyback.");
}
return true;
}
else if ("db".equals(doc.getNamespacePrefix()) && "verify".equals(doc.getName())) {
// The Receiving Server is reusing an existing connection for sending the
// Authoritative Server a request for verification of a key
((LocalIncomingServerSession) session).verifyReceivedKey(doc);
return true;
}
return false;
}
代码示例来源:origin: igniterealtime/Openfire
/**
* Remote servers may send subsequent db:result packets so we need to process them in order
* to validate new domains.
*
* @param doc the unknown DOM element that was received
* @return true if the packet is a db:result packet otherwise false.
*/
@Override
protected boolean processUnknowPacket(Element doc) {
// Handle subsequent db:result packets
if ("db".equals(doc.getNamespacePrefix()) && "result".equals(doc.getName())) {
if (!((LocalIncomingServerSession) session).validateSubsequentDomain(doc)) {
open = false;
}
return true;
}
else if ("db".equals(doc.getNamespacePrefix()) && "verify".equals(doc.getName())) {
// The Receiving Server is reusing an existing connection for sending the
// Authoritative Server a request for verification of a key
((LocalIncomingServerSession) session).verifyReceivedKey(doc);
return true;
}
return false;
}
代码示例来源:origin: pentaho/pentaho-kettle
public void prepareNSMap( Element l ) {
@SuppressWarnings( "unchecked" )
List<Namespace> namespacesList = l.declaredNamespaces();
for ( Namespace ns : namespacesList ) {
if ( ns.getPrefix().trim().length() == 0 ) {
data.NAMESPACE.put( "pre" + data.NSPath.size(), ns.getURI() );
String path = "";
Element element = l;
while ( element != null ) {
if ( element.getNamespacePrefix() != null && element.getNamespacePrefix().length() > 0 ) {
path = GetXMLDataMeta.N0DE_SEPARATOR + element.getNamespacePrefix() + ":" + element.getName() + path;
} else {
path = GetXMLDataMeta.N0DE_SEPARATOR + element.getName() + path;
}
element = element.getParent();
}
data.NSPath.add( path );
} else {
data.NAMESPACE.put( ns.getPrefix(), ns.getURI() );
}
}
@SuppressWarnings( "unchecked" )
List<Element> elementsList = l.elements();
for ( Element e : elementsList ) {
prepareNSMap( e );
}
}
代码示例来源:origin: igniterealtime/Openfire
return false;
else if ("db".equals(doc.getNamespacePrefix()) && "result".equals(doc.getName())) {
if ( "valid".equals(doc.attributeValue("type")) ) {
log.debug( "Authenticated succeeded!" );
代码示例来源:origin: igniterealtime/Openfire
@Override
boolean processUnknowPacket(Element doc) {
String tag = doc.getName();
if ("route".equals(tag)) {
// Process stanza wrapped by the route packet
processRoute(new Route(doc));
return true;
} else if ("handshake".equals(tag)) {
if (!((LocalConnectionMultiplexerSession) session).authenticate(doc.getStringValue())) {
Log.debug( "Closing session that failed to authenticate: {}", session );
session.close();
}
return true;
} else if ("error".equals(tag) && "stream".equals(doc.getNamespacePrefix())) {
Log.debug( "Closing session because of received stream error {}. Affected session: {}", doc.asXML(), session );
session.close();
return true;
}
return false;
}
代码示例来源:origin: igniterealtime/Openfire
if (child != null && "session".equals(child.getName()) &&
"http://jabber.org/protocol/connectionmanager"
.equals(child.getNamespacePrefix())) {
Element send = child.element("send");
if (send != null) {
代码示例来源:origin: igniterealtime/Openfire
if ("db".equals(doc.getNamespacePrefix()) && "verify".equals(doc.getName())) {
if (doc.attributeValue("id") == null || !streamID.equals(BasicStreamIDFactory.createStreamID( doc.attributeValue("id") ))) {
代码示例来源:origin: igniterealtime/Openfire
if ("db".equals(doc.getNamespacePrefix()) && "result".equals(doc.getName())) {
String hostname = doc.attributeValue("from");
String recipient = doc.attributeValue("to");
else if ("db".equals(doc.getNamespacePrefix()) && "verify".equals(doc.getName())) {
代码示例来源:origin: igniterealtime/Openfire
} else if ("error".equals(tag) && "stream".equals(doc.getNamespacePrefix())) {
Log.debug( "Closing session because of received stream error {}. Affected session: {}", doc.asXML(), session );
session.close();
代码示例来源:origin: org.dom4j/dom4j
public String getPrefix() {
return element.getNamespacePrefix();
}
代码示例来源:origin: webx/citrus
/** 将element的prefix改成统一的值,但不改变其namespace。 */
private void setNamespacePrefix(Element element, String prefix) {
assertNotNull(prefix, "prefix is null");
if (!prefix.equals(element.getNamespacePrefix())) {
element.setQName(QName.get(element.getName(), prefix, element.getNamespaceURI()));
modified = true;
}
}
代码示例来源:origin: webx/citrus
/** 将element的prefix改成统一的值,但不改变其namespace。 */
private void setNamespacePrefix(Element element, String prefix) {
assertNotNull(prefix, "prefix is null");
if (!prefix.equals(element.getNamespacePrefix())) {
element.setQName(QName.get(element.getName(), prefix, element.getNamespaceURI()));
modified = true;
}
}
代码示例来源:origin: webx/citrus
/** 将element的prefix改成统一的值,但不改变其namespace。 */
private void setNamespacePrefix(Element element, String prefix) {
assertNotNull(prefix, "prefix is null");
if (!prefix.equals(element.getNamespacePrefix())) {
element.setQName(QName.get(element.getName(), prefix, element.getNamespaceURI()));
modified = true;
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.freemarker
@Override
String getNamespacePrefix(Object node) {
if (node instanceof Element) {
return ((Element) node).getNamespacePrefix();
}
if (node instanceof Attribute) {
return ((Attribute) node).getNamespacePrefix();
}
return null;
}
代码示例来源:origin: org.freemarker/freemarker-gae
@Override
String getNamespacePrefix(Object node) {
if (node instanceof Element) {
return ((Element) node).getNamespacePrefix();
}
if (node instanceof Attribute) {
return ((Attribute) node).getNamespacePrefix();
}
return null;
}
代码示例来源:origin: org.freemarker/com.springsource.freemarker
String getNamespacePrefix(Object node) {
if(node instanceof Element) {
return ((Element)node).getNamespacePrefix();
}
if(node instanceof Attribute) {
return ((Attribute)node).getNamespacePrefix();
}
return null;
}
代码示例来源:origin: MarkusLewis/Podcast-Feed-Library
public URL getLink() throws MalformedURLException, MalformedFeedException {
if (this.link != null) {
return this.link;
}
Element linkElement = this.channelElement.element("link");
if (linkElement == null)
throw new MalformedFeedException("Missing required link element.");
if ("atom".equalsIgnoreCase(linkElement.getNamespacePrefix())) {
return new URL(linkElement.attributeValue("href"));
}
//TODO Handle URL Exceptions?
return this.link = new URL(linkElement.getText());
}
代码示例来源:origin: com.alibaba.citrus/citrus-webx-all
/** 将element的prefix改成统一的值,但不改变其namespace。 */
private void setNamespacePrefix(Element element, String prefix) {
assertNotNull(prefix, "prefix is null");
if (!prefix.equals(element.getNamespacePrefix())) {
element.setQName(QName.get(element.getName(), prefix, element.getNamespaceURI()));
modified = true;
}
}
代码示例来源:origin: dom4j/dom4j
public void debugShowNamespaces() throws Exception {
Element root = getRootElement();
for (Iterator iter = root.elementIterator(); iter.hasNext();) {
Element element = (Element) iter.next();
log("Found element: " + element);
log("Namespace: " + element.getNamespace());
log("Namespace prefix: " + element.getNamespacePrefix());
log("Namespace URI: " + element.getNamespaceURI());
}
}
内容来源于网络,如有侵权,请联系作者删除!