本文整理了Java中org.dom4j.Namespace.getURI()
方法的一些代码示例,展示了Namespace.getURI()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Namespace.getURI()
方法的具体详情如下:
包路径:org.dom4j.Namespace
类名称:Namespace
方法名:getURI
[英]DOCUMENT ME!
[中]记录我!
代码示例来源:origin: jaxen/jaxen
public String getNamespaceStringValue(Object obj)
{
Namespace ns = (Namespace) obj;
return ns.getURI();
}
代码示例来源:origin: igniterealtime/Openfire
protected boolean isNamespaceDeclaration( Namespace ns ) {
if (ns != null && ns != Namespace.XML_NAMESPACE) {
String uri = ns.getURI();
if ( uri != null ) {
if ( ! namespaceStack.contains( ns ) ) {
return true;
}
}
}
return false;
}
代码示例来源:origin: igniterealtime/Openfire
protected void writeNamespace(Namespace namespace) throws IOException {
if ( namespace != null ) {
writeNamespace(namespace.getPrefix(), namespace.getURI());
}
}
代码示例来源: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: jaxen/jaxen
public String translateNamespacePrefixToUri(String prefix, Object context)
{
Element element = null;
if ( context instanceof Element )
{
element = (Element) context;
}
else if ( context instanceof Node )
{
Node node = (Node) context;
element = node.getParent();
}
if ( element != null )
{
Namespace namespace = element.getNamespaceForPrefix( prefix );
if ( namespace != null )
{
return namespace.getURI();
}
}
return null;
}
代码示例来源:origin: igniterealtime/Openfire
private void initiateSession(Element stanza) {
String host = stanza.attributeValue("to");
StreamError streamError = null;
Locale language = Locale.forLanguageTag(stanza.attributeValue(QName.get("lang", XMLConstants.XML_NS_URI), "en"));
if (STREAM_FOOTER.equals(stanza.getName())) {
// an error occurred while setting up the session
Log.warn("Client closed stream before session was established");
} else if (!STREAM_HEADER.equals(stanza.getName())) {
streamError = new StreamError(StreamError.Condition.unsupported_stanza_type);
Log.warn("Closing session due to incorrect stream header. Tag: " + stanza.getName());
} else if (!FRAMING_NAMESPACE.equals(stanza.getNamespace().getURI())) {
// Validate the stream namespace (https://tools.ietf.org/html/rfc7395#section-3.3.2)
streamError = new StreamError(StreamError.Condition.invalid_namespace);
Log.warn("Closing session due to invalid namespace in stream header. Namespace: " + stanza.getNamespace().getURI());
} else if (!validateHost(host)) {
streamError = new StreamError(StreamError.Condition.host_unknown);
Log.warn("Closing session due to incorrect hostname in stream header. Host: " + host);
} else {
// valid stream; initiate session
xmppSession = SessionManager.getInstance().createClientSession(wsConnection, language);
xmppSession.setSessionData("ws", Boolean.TRUE);
}
if (xmppSession == null) {
closeStream(streamError);
} else {
openStream(language.toLanguageTag(), stanza.attributeValue("from"));
configureStream();
}
}
代码示例来源:origin: igniterealtime/Openfire
String prefix = ns.getPrefix();
String uri = namespaceStack.getURI(prefix);
if (!ns.getURI().equals(uri)) { // output a new namespace declaration
writeNamespace(ns);
namespaceStack.push(ns);
代码示例来源:origin: igniterealtime/Openfire
for (Element child : (List<Element>)element.elements()) {
Namespace ns = child.getNamespace();
if (ns == null || ns.getURI().equals("jabber:client") || ns.getURI().equals("jabber:server")) {
continue;
代码示例来源:origin: org.dom4j/dom4j
/**
* DOCUMENT ME!
*
* @return the namespace URI of this QName
*/
public String getNamespaceURI() {
if (namespace == null) {
return "";
}
return namespace.getURI();
}
代码示例来源:origin: igniterealtime/Openfire
final String defaultNS = el.getNamespaceForPrefix("").getURI();
if (defaultNS.equals("")) {
代码示例来源:origin: org.dom4j/dom4j
protected boolean isNamespaceDeclaration(Namespace ns) {
if ((ns != null) && (ns != Namespace.NO_NAMESPACE)
&& (ns != Namespace.XML_NAMESPACE)) {
String uri = ns.getURI();
if ((uri != null) && (uri.length() > 0)) {
if (!namespaceStack.contains(ns)) {
return true;
}
}
}
return false;
}
代码示例来源:origin: org.dom4j/dom4j
public String translateNamespacePrefixToUri(String prefix) {
if ((prefix != null) && (prefix.length() > 0)) {
Namespace ns = element.getNamespaceForPrefix(prefix);
if (ns != null) {
return ns.getURI();
}
}
return null;
}
}
代码示例来源:origin: org.dom4j/dom4j
protected boolean isNamespaceDeclaration(Namespace ns) {
if ((ns != null) && (ns != Namespace.XML_NAMESPACE)) {
String uri = ns.getURI();
if (uri != null) {
if (!namespaceStack.contains(ns)) {
return true;
}
}
}
return false;
}
代码示例来源:origin: org.dom4j/dom4j
protected void writeNamespace(org.w3c.dom.Element domElement,
Namespace namespace) {
String attributeName = attributeNameForNamespace(namespace);
// domElement.setAttributeNS("", attributeName, namespace.getURI());
domElement.setAttribute(attributeName, namespace.getURI());
}
代码示例来源:origin: org.dom4j/dom4j
private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
// We use writeObject() and not writeUTF() to minimize space
// This allows for writing pointers to already written strings
out.writeObject(namespace.getPrefix());
out.writeObject(namespace.getURI());
}
代码示例来源:origin: org.dom4j/dom4j
public String resolveNamespacePrefix(String prefix) {
Namespace namespace = getNamespaceForPrefix(prefix);
if (namespace != null) {
return namespace.getURI();
}
return null;
}
代码示例来源:origin: org.dom4j/dom4j
protected void writeNamespace(Namespace namespace) throws IOException {
if (namespace != null) {
writeNamespace(namespace.getPrefix(), namespace.getURI());
}
}
代码示例来源:origin: org.dom4j/dom4j
public int compare(Namespace n1, Namespace n2) {
int answer = compare(n1.getURI(), n2.getURI());
if (answer == 0) {
answer = compare(n1.getPrefix(), n2.getPrefix());
}
return answer;
}
代码示例来源:origin: org.dom4j/dom4j
public List<Namespace> getNamespacesForURI(String uri) {
BackedList<Namespace> answer = createResultList();
for (Node node : contentList()) {
if ((node instanceof Namespace)
&& ((Namespace) node).getURI().equals(uri)) {
answer.addLocal((Namespace) node);
}
}
return answer;
}
代码示例来源:origin: org.dom4j/dom4j
protected void addDeclaredNamespaces(Element element) {
for (int size = namespaceStack.size(); declaredNamespaceIndex < size;
declaredNamespaceIndex++) {
Namespace namespace = namespaceStack
.getNamespace(declaredNamespaceIndex);
String attributeName = attributeNameForNamespace(namespace);
((DOMElement)element).setAttribute(attributeName, namespace.getURI());
}
}
内容来源于网络,如有侵权,请联系作者删除!