本文整理了Java中org.dom4j.Namespace.getPrefix()
方法的一些代码示例,展示了Namespace.getPrefix()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Namespace.getPrefix()
方法的具体详情如下:
包路径:org.dom4j.Namespace
类名称:Namespace
方法名:getPrefix
[英]DOCUMENT ME!
[中]记录我!
代码示例来源:origin: jaxen/jaxen
public String getNamespacePrefix(Object obj)
{
Namespace ns = (Namespace) obj;
return ns.getPrefix();
}
代码示例来源: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
if (namespace != Namespace.NO_NAMESPACE)
String prefix = namespace.getPrefix();
if ( ! prefixes.contains( prefix ) ) {
prefixes.add( prefix );
代码示例来源:origin: igniterealtime/Openfire
Namespace ns = attribute.getNamespace();
if (ns != null && ns != Namespace.NO_NAMESPACE && ns != Namespace.XML_NAMESPACE) {
String prefix = ns.getPrefix();
String uri = namespaceStack.getURI(prefix);
if (!ns.getURI().equals(uri)) { // output a new namespace declaration
代码示例来源:origin: org.dom4j/dom4j
/**
* DOCUMENT ME!
*
* @return the namespace URI of this QName
*/
public String getNamespacePrefix() {
if (namespace == null) {
return "";
}
return namespace.getPrefix();
}
代码示例来源:origin: org.dom4j/dom4j
protected String attributeNameForNamespace(Namespace namespace) {
String xmlns = "xmlns";
String prefix = namespace.getPrefix();
if (prefix.length() > 0) {
return xmlns + ":" + prefix;
}
return xmlns;
}
代码示例来源:origin: org.dom4j/dom4j
protected String attributeNameForNamespace(Namespace namespace) {
String xmlns = "xmlns";
String prefix = namespace.getPrefix();
if (prefix.length() > 0) {
return xmlns + ":" + prefix;
}
return xmlns;
}
代码示例来源:origin: org.dom4j/dom4j
/**
* Attempts to find the current default namespace on the stack right now or
* returns null if one could not be found
*
* @return DOCUMENT ME!
*/
protected Namespace findDefaultNamespace() {
for (int i = namespaceStack.size() - 1; i >= 0; i--) {
Namespace namespace = namespaceStack.get(i);
if (namespace != null) {
String prefix = namespace.getPrefix();
if ((prefix == null) || (namespace.getPrefix().length() == 0)) {
return namespace;
}
}
}
return null;
}
代码示例来源:origin: org.dom4j/dom4j
/**
* Pushes the given namespace onto the stack so that its prefix becomes
* available.
*
* @param namespace
* is the <code>Namespace</code> to add to the stack.
*/
public void push(Namespace namespace) {
namespaceStack.add(namespace);
namespaceCacheList.add(null);
currentNamespaceCache = null;
String prefix = namespace.getPrefix();
if ((prefix == null) || (prefix.length() == 0)) {
defaultNamespace = namespace;
}
}
代码示例来源: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 toString() {
return super.toString() + " [Namespace: prefix " + getPrefix()
+ " mapped to URI \"" + getURI() + "\"]";
}
代码示例来源:origin: org.dom4j/dom4j
public String getNamespacePrefix(String uri) {
Namespace namespace = getNamespaceForURI(uri);
return (namespace != null) ? namespace.getPrefix() : null;
}
代码示例来源:origin: org.dom4j/dom4j
public String asXML() {
StringBuffer asxml = new StringBuffer(10);
String pref = getPrefix();
if ((pref != null) && (pref.length() > 0)) {
asxml.append("xmlns:");
asxml.append(pref);
asxml.append("=\"");
} else {
asxml.append("xmlns=\"");
}
asxml.append(getURI());
asxml.append("\"");
return asxml.toString();
}
代码示例来源:origin: org.dom4j/dom4j
public javax.xml.stream.events.Namespace next() {
Namespace ns = iter.next();
String prefix = ns.getPrefix();
String nsURI = ns.getURI();
return factory.createNamespace(prefix, nsURI);
}
代码示例来源: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 String getNamespacePrefix(String uri) {
Element parentElement = getParent();
if (parentElement != null) {
Namespace namespace = parentElement.getNamespaceForURI(uri);
if (namespace != null) {
return namespace.getPrefix();
}
}
return null;
}
代码示例来源:origin: org.dom4j/dom4j
protected Node createXPathResult(Element parent) {
return new DefaultNamespace(parent, getPrefix(), getURI());
}
}
代码示例来源:origin: org.dom4j/dom4j
/**
* Constructs a STAX {@link javax.xml.stream.events.Namespace}event from a
* DOM4J {@link Namespace}.
*
* @param ns
* The {@link Namespace}from which to construct the event.
*
* @return The constructed {@link javax.xml.stream.events.Namespace}event.
*/
public javax.xml.stream.events.Namespace createNamespace(Namespace ns) {
String prefix = ns.getPrefix();
String uri = ns.getURI();
return factory.createNamespace(prefix, uri);
}
内容来源于网络,如有侵权,请联系作者删除!