List of usage examples for javax.xml.namespace QName getLocalPart
public String getLocalPart()
Get the local part of this QName
.
From source file:com.evolveum.midpoint.util.QNameUtil.java
public static QName nullNamespace(QName qname) { return new QName(null, qname.getLocalPart(), qname.getPrefix()); }
From source file:Main.java
/** * @param qname/*from ww w. ja va 2s . c o m*/ * The QName to serialize into prefix:localName form. * @return This method returns a different value than QName.toString(). The * QName.toString() returns a string of the format: <br> * <br> * <em>{namespace URI}:name</em> <br> * <br> * whereas this method returns: <br> * <br> * <em>prefix:name</em> <br> * <br> * which is a valid representation to put into XML documents. If * the QName has no prefix, the local name is returned. */ public static String toString(final QName qname) { final String prefix = qname.getPrefix(); final String name = qname.getLocalPart(); if (prefix == null || prefix.length() == 0) return name; return prefix + ':' + name; }
From source file:eu.esdihumboldt.hale.common.instance.orient.internal.ONamespaceMap.java
/** * Map the namespace of the given qualified name to a short identifier and * return the adapted name./* ww w.ja v a 2 s. c om*/ * * @param org the original qualified name * @return the adapted qualified name */ public static QName map(QName org) { if (XMLConstants.NULL_NS_URI.equals(org.getNamespaceURI())) { return org; } return new QName(IDS.getId(org.getNamespaceURI()), org.getLocalPart()); }
From source file:eu.esdihumboldt.hale.common.instance.orient.internal.ONamespaceMap.java
/** * Determine the original namespace of the given qualified name with a * namespace previously mapped with {@link #map(QName)} and return the * original name./*from w w w. j ava 2 s.com*/ * * @param mapped the adapted qualified name * @return the original qualified name */ public static QName unmap(QName mapped) { if (XMLConstants.NULL_NS_URI.equals(mapped.getNamespaceURI())) { return mapped; } return new QName(IDS.getObject(mapped.getNamespaceURI()), mapped.getLocalPart()); }
From source file:Main.java
private static void writeAsEncodedUnicode(EndElement element, Writer writer) throws XMLStreamException { try {/*from ww w. jav a 2 s .c o m*/ // Write end tags. writer.write("</"); QName name = element.getName(); String prefix = name.getPrefix(); if (prefix != null && prefix.length() > 0) { writer.write(prefix); writer.write(':'); } writer.write(name.getLocalPart()); writer.write('>'); } catch (IOException ioe) { throw new XMLStreamException(ioe); } }
From source file:eu.esdihumboldt.hale.common.instance.orient.internal.ONamespaceMap.java
/** * Encode a {@link QName} for runtime use with OrientDB. * // ww w . j av a2s . co m * @param org the qualified name * @return the encoded name */ public static String encode(QName org) { String ns = org.getNamespaceURI(); if (!XMLConstants.NULL_NS_URI.equals(ns)) { ns = IDS.getId(org.getNamespaceURI()); } return ns + "_" + ONameUtil.encodeName(org.getLocalPart()); }
From source file:mp.platform.cyclone.webservices.utils.WebServiceHelper.java
public static String getWebServiceOperationName(final SoapMessage message) { final MessageInfo messageInfo = message.get(MessageInfo.class); final OperationInfo operation = messageInfo.getOperation(); final QName operationQName = operation.getName(); return operationQName.getLocalPart(); }
From source file:com.evolveum.midpoint.util.QNameUtil.java
public static boolean compareQName(QName qname, Node node) { return (qname.getNamespaceURI().equals(node.getNamespaceURI()) && qname.getLocalPart().equals(node.getLocalName())); }
From source file:Main.java
private static void writeAsEncodedUnicode(StartElement element, Writer writer, boolean isEmpty) throws XMLStreamException { try {//from w ww. j a v a2 s . c om // Write start tag. writer.write('<'); QName name = element.getName(); String prefix = name.getPrefix(); if (prefix != null && prefix.length() > 0) { writer.write(prefix); writer.write(':'); } writer.write(name.getLocalPart()); // Write namespace declarations. Iterator nsIter = element.getNamespaces(); while (nsIter.hasNext()) { Namespace ns = (Namespace) nsIter.next(); writer.write(' '); ns.writeAsEncodedUnicode(writer); } // Write attributes Iterator attrIter = element.getAttributes(); while (attrIter.hasNext()) { Attribute attr = (Attribute) attrIter.next(); writer.write(' '); attr.writeAsEncodedUnicode(writer); } if (isEmpty) writer.write('/'); writer.write('>'); } catch (IOException ioe) { throw new XMLStreamException(ioe); } }
From source file:Main.java
/** * Creates a new Element having the specified qualified name. The element * must be {@link Document#adoptNode(Node) adopted} when inserted into * another Document./*from w w w. j a v a2s . co m*/ * * @param qName A QName object. * @return An Element node (with a Document owner but no parent). */ public static Element createElement(QName qName) { Document doc = null; try { doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); } catch (ParserConfigurationException e) { throw new RuntimeException(e); } Element elem = doc.createElementNS(qName.getNamespaceURI(), qName.getLocalPart()); return elem; }