List of usage examples for javax.xml.namespace QName getNamespaceURI
public String getNamespaceURI()
Get the Namespace URI of this QName
.
From source file:Main.java
private static boolean checkNameAndNamespace(XMLEvent event, String tagName, String namespace) { if (event.isStartElement()) { StartElement element = (StartElement) event; QName name = element.getName(); return tagName.equalsIgnoreCase(name.getLocalPart()) && namespace.equalsIgnoreCase(name.getNamespaceURI()); } else if (event.isEndElement()) { EndElement element = (EndElement) event; QName name = element.getName(); return tagName.equalsIgnoreCase(name.getLocalPart()) && namespace.equalsIgnoreCase(name.getNamespaceURI()); }/*from ww w. j a va2 s. c o m*/ return false; }
From source file:net.di2e.ecdr.search.transform.atom.response.security.SecurityMarkingParser.java
public static SecurityDataImpl getFeedSecurityMarkings(Feed feed) { List<QName> attributes = feed.getAttributes(); if (attributes != null) { HashMap<String, List<String>> securityProps = new HashMap<String, List<String>>(); String feedNamespace = null; for (QName qName : attributes) { String namespace = qName.getNamespaceURI(); if (NAMESPACES.contains(namespace)) { String value = feed.getAttributeValue(qName); if (StringUtils.isNotBlank(value)) { securityProps.put(qName.getLocalPart(), getValues(value)); if (feedNamespace == null) { feedNamespace = namespace; }//from w w w. j av a 2 s. c o m } } } if (!securityProps.isEmpty()) { return new SecurityDataImpl(securityProps, feedNamespace); } } return null; }
From source file:net.di2e.ecdr.search.transform.atom.response.security.SecurityMarkingParser.java
public static Metacard addSecurityToMetacard(Metacard metacard, Entry entry) { HashMap<String, List<String>> securityProps = new HashMap<String, List<String>>(); CDRMetacard metacardImpl = new CDRMetacard(metacard); List<QName> attributes = entry.getAttributes(); if (attributes != null) { String metacardSecurityNamespace = null; for (QName qName : attributes) { String namespace = qName.getNamespaceURI(); if (NAMESPACES.contains(namespace)) { String value = entry.getAttributeValue(qName); if (StringUtils.isNotBlank(value)) { securityProps.put(qName.getLocalPart(), getValues(value)); if (metacardSecurityNamespace == null) { metacardSecurityNamespace = namespace; }/*ww w.j a va 2 s . com*/ } } } if (!securityProps.isEmpty()) { metacardImpl.setSecurity(securityProps); metacardImpl.setAttribute(SecurityConstants.SECURITY_NAMESPACE, metacardSecurityNamespace); } } return metacardImpl; }
From source file:Main.java
public static boolean equal(final QName a, final QName b, final String defaultNamespace) { if (a.getLocalPart().equals(b.getLocalPart())) { String nsa = a.getNamespaceURI(); String nsb = b.getNamespaceURI(); if (nsa == null || nsa.length() == 0) { nsa = defaultNamespace;//from w w w.j a v a2s .c o m } if (nsb == null || nsb.length() == 0) { nsb = defaultNamespace; } return nsa.equals(nsb); } return false; }
From source file:Main.java
/** * Like {@link javanet.staxutils.XMLStreamUtils#mergeAttributes} but it can * also merge namespaces/*from ww w . ja va 2 s .co m*/ * * @param tag * @param attrs * @param nsps */ public static StartElement mergeAttributes(StartElement tag, Iterator<? extends Attribute> attrs, Iterator<? extends Namespace> nsps, XMLEventFactory factory) { // create Attribute map Map<QName, Attribute> attributes = new HashMap<QName, Attribute>(); // iterate through start tag's attributes for (Iterator i = tag.getAttributes(); i.hasNext();) { Attribute attr = (Attribute) i.next(); attributes.put(attr.getName(), attr); } if (attrs != null) { // iterate through new attributes while (attrs.hasNext()) { Attribute attr = attrs.next(); attributes.put(attr.getName(), attr); } } Map<QName, Namespace> namespaces = new HashMap<QName, Namespace>(); for (Iterator i = tag.getNamespaces(); i.hasNext();) { Namespace ns = (Namespace) i.next(); namespaces.put(ns.getName(), ns); } if (nsps != null) { while (nsps.hasNext()) { Namespace ns = nsps.next(); namespaces.put(ns.getName(), ns); } } factory.setLocation(tag.getLocation()); QName tagName = tag.getName(); return factory.createStartElement(tagName.getPrefix(), tagName.getNamespaceURI(), tagName.getLocalPart(), attributes.values().iterator(), namespaces.values().iterator(), tag.getNamespaceContext()); }
From source file:Main.java
/** * Searches through an entire sub-tree for child Elements whose QName * matches the one given. The results are not guaranteed to be in any * particular order, and are <b>not</b> limited to direct children of * the given context node. <br>/*from www .j av a 2s.c o m*/ * <br> * If you want to limit your search for Elements to the direct children * of a given Element, use the getAllElement, getElement, and getElements * methods. Those guarantee that all results are directly beneath the * given context. * * @param context * The root node from which the search will be done. * @param qname * The QName of the Element to search for. * @return An array with all occurrences of child Elements with the * given name. The Elements may be anywhere in the sub-tree, * meaning they may not be direct children of the context node. * The only guarantee is that they are somewhere beneath the * context node. The method returns an empty array if no * occurrences are found. * @see Element#getElementsByTagNameNS(String, String) * @see #getAllElements(Node) * @see #getElement(Node, QName) * @see #getElements(Node, QName) */ public static Element[] findInSubTree(final Element context, final QName qname) { final String name = qname.getLocalPart(); final String uri = qname.getNamespaceURI(); // // DOM's getElementsByTagName methods search the whole subtree // final NodeList matches = context.getElementsByTagNameNS(uri, name); final int length = matches.getLength(); final Element[] asArray = new Element[length]; for (int n = 0; n < length; ++n) asArray[n] = (Element) matches.item(n); return asArray; }
From source file:com.predic8.membrane.core.util.SOAPUtil.java
public static boolean isSOAP(XMLInputFactory xmlInputFactory, XOPReconstitutor xopr, Message msg) { try {/*w w w .j ava 2s. c o m*/ XMLEventReader parser; synchronized (xmlInputFactory) { parser = xmlInputFactory.createXMLEventReader(xopr.reconstituteIfNecessary(msg)); } while (parser.hasNext()) { XMLEvent event = parser.nextEvent(); if (event.isStartElement()) { QName name = ((StartElement) event).getName(); return (Constants.SOAP11_NS.equals(name.getNamespaceURI()) || Constants.SOAP12_NS.equals(name.getNamespaceURI())) && "Envelope".equals(name.getLocalPart()); } } } catch (Exception e) { log.warn("Ignoring exception: ", e); } return false; }
From source file:com.moss.jaxwslite.ServiceFactory.java
public static <T> T createDefault(URL url, QName qname, Class<T> iface) { return defaultFactory.create(url, qname.getNamespaceURI(), iface); }
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:com.evolveum.midpoint.util.QNameUtil.java
public static String qNameToUri(QName qname) { String qUri = qname.getNamespaceURI(); StringBuilder sb = new StringBuilder(qUri); // TODO: Check if there's already a fragment // e.g. http://foo/bar#baz if (!qUri.endsWith("#") && !qUri.endsWith("/")) { sb.append("#"); }//ww w.ja v a 2 s . c o m sb.append(qname.getLocalPart()); return sb.toString(); }