List of usage examples for javax.xml.namespace QName QName
public QName(final String namespaceURI, final String localPart)
QName
constructor specifying the Namespace URI and local part.
If the Namespace URI is null
, it is set to javax.xml.XMLConstants#NULL_NS_URI XMLConstants.NULL_NS_URI .
From source file:Main.java
public static QName getNamespace(Map<String, String> namespaces, String str, String defaultNamespace) { String prefix = null;/*ww w. j a v a2 s.co m*/ String localName = null; StringTokenizer tokenizer = new StringTokenizer(str, ":"); if (tokenizer.countTokens() == 2) { prefix = tokenizer.nextToken(); localName = tokenizer.nextToken(); } else if (tokenizer.countTokens() == 1) { localName = tokenizer.nextToken(); } String namespceURI = defaultNamespace; if (prefix != null) { namespceURI = namespaces.get(prefix); } return new QName(namespceURI, localName); }
From source file:Main.java
/** * Get the name of the field by looking at the XmlElement annotation. * * @param jaxbClass//from w ww .j ava2 s. com * @param fieldName * @return * @throws NoSuchFieldException */ private static QName getXmlElementRefOrElementQName(Class<?> jaxbClass, Field field) throws NoSuchFieldException { XmlElementRef xmlElementRef = (XmlElementRef) getAnnotation(field, XmlElementRef.class); if (xmlElementRef != null) { return new QName(xmlElementRef.namespace(), xmlElementRef.name()); } XmlElement xmlElement = (XmlElement) getAnnotation(field, XmlElement.class); // If XmlElement does not exist, default to using the field name if (xmlElement == null || xmlElement.name().equals("##default")) { return new QName("", field.getName()); } return new QName(xmlElement.namespace(), xmlElement.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./* w ww .j av a 2 s .c o m*/ * * @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:Main.java
public static List<Element> elementsQName(Element element, Set<QName> allowedTagNames) { if (element == null || !element.hasChildNodes()) { return Collections.emptyList(); }/*from w w w. ja v a 2 s . c o m*/ List<Element> elements = new ArrayList<Element>(); for (Node child = element.getFirstChild(); child != null; child = child.getNextSibling()) { if (child.getNodeType() == Node.ELEMENT_NODE) { Element childElement = (Element) child; QName childQName = new QName(childElement.getNamespaceURI(), childElement.getLocalName()); if (allowedTagNames.contains(childQName)) { elements.add(childElement); } } } return elements; }
From source file:Main.java
public static List<Element> elementsQName(final Element element, final Set<QName> allowedTagNames) { List<Element> elements = null; final NodeList nodeList = element.getChildNodes(); if (nodeList != null) { for (int i = 0; i < nodeList.getLength(); i++) { final Node child = nodeList.item(i); if (Element.class.isAssignableFrom(child.getClass())) { final Element childElement = (Element) child; final QName childElementQName = new QName(childElement.getNamespaceURI(), childElement.getLocalName()); if (allowedTagNames.contains(childElementQName)) { if (elements == null) { elements = new ArrayList<Element>(); }//w w w . j a v a2 s . c om elements.add(childElement); } } } } return elements; }
From source file:org.maodian.flyingcat.xmpp.extensions.xep0077.InBandRegistrationExtension.java
@Override public void register(GlobalContext ctx) { org.springframework.context.ApplicationContext injector = getInjector(); RegistrationCodec codec = injector.getBean(RegistrationCodec.class); ctx.registerDecoder(new QName(InBandRegistration.REGISTER, "query"), codec); ctx.registerEncoder(Registration.class, codec); ctx.registerProcessor(Registration.class, codec); }
From source file:org.maodian.flyingcat.xmpp.extensions.xep0030.ServiceDiscoveryExtension.java
@Override public void register(GlobalContext ctx) { org.springframework.context.ApplicationContext injector = getInjector(); QueryInfoCodec queryInfoCodec = injector.getBean(QueryInfoCodec.class); QueryItemCodec queryItemCodec = injector.getBean(QueryItemCodec.class); ctx.registerDecoder(new QName(ServiceDiscovery.INFORMATION, "query"), queryInfoCodec); ctx.registerDecoder(new QName(ServiceDiscovery.ITEM, "query"), queryItemCodec); ctx.registerEncoder(QueryInfo.class, queryInfoCodec); ctx.registerEncoder(QueryItem.class, queryItemCodec); ctx.registerProcessor(QueryInfo.class, queryInfoCodec); ctx.registerProcessor(QueryItem.class, queryItemCodec); }
From source file:ca.sqlpower.dao.session.QNameConverter.java
@Override public QName convertToComplexType(String convertFrom) throws ConversionException { int namespaceEndIndex = convertFrom.indexOf("}"); if (namespaceEndIndex > 0) { String namespace = convertFrom.substring(1, namespaceEndIndex); String name = convertFrom.substring(namespaceEndIndex + 1); return new QName(namespace, name); } else {//from w ww . ja v a 2 s.c o m return new QName(convertFrom); } }
From source file:org.apache.servicemix.http.HttpEndpointLoadWsdlTest.java
public void testLoadWsdl() throws Exception { MyHttpEndpoint endpoint = new MyHttpEndpoint(); endpoint.setWsdlResource(new ClassPathResource("org/apache/servicemix/http/wsdl/relative.wsdl")); endpoint.setTargetEndpoint("TestPort"); endpoint.setTargetService(new QName("http://test.namespace/wsdl", "TestService")); endpoint.setLocationURI("http://0.0.0.0:1234/services/service1/"); endpoint.setSoap(true);//from w ww . j a va 2s. c om endpoint.setService(new QName("http://test.namespace/wsdl", "Service")); endpoint.loadWsdl(); assertFalse(endpoint.getWsdls().isEmpty()); assertEquals(1, endpoint.getWsdls().size()); assertTrue(endpoint.getWsdls().containsKey("Service1/Requests.xsd")); assertTrue(endpoint.getWsdls().containsKey("Service1/subschema/SubSchema.xsd")); assertTrue(endpoint.getWsdls().containsKey("common/DataType.xsd")); assertTrue(endpoint.getWsdls().containsKey("common/TestEnum.xsd")); assertTrue(endpoint.getWsdls().containsKey("Service1/Responses.xsd")); assertTrue(endpoint.getWsdls().containsKey("common/Fault.xsd")); assertTrue(endpoint.getWsdls().containsKey("main.wsdl")); }
From source file:io.mapzone.arena.csw.InsertRecordRequest.java
@Override protected void prepare(IProgressMonitor monitor) throws Exception { writeElement(CSW, "Insert", () -> { QName name = new QName(Namespaces.CSW, "Record"); writeObject(new JAXBElement(name, RecordXML.class, null, record)); });/* w ww . ja va2 s. c o m*/ }