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:se.vgregion.portal.patientcontext.SearchController.java
/** * Reset PatientEvent./*ww w. ja v a 2s . c om*/ * Remove current active PatientEvent from context. * * @param patientContext PatientContext. * @param response ActionResponse for event propagation. */ @ActionMapping("resetEvent") public void resetEvent(@ModelAttribute("patientContext") PatientContext patientContext, ActionResponse response) { patientContext.clear(); // event QName qname = new QName("http://vgregion.se/patientcontext/events", "pctx.reset"); response.setEvent(qname, "reset"); }
From source file:com._4dconcept.springframework.data.marklogic.repository.query.PartTreeMarklogicQueryTest.java
@Test public void collectionFieldsShouldBeConsideredAsAndCriteria() { List<String> skills = new ArrayList<>(); skills.add("foo"); skills.add("bar"); Query query = deriveQueryFromMethod("findBySkills", skills); assertThat(query.getCriteria().getOperator(), is(Criteria.Operator.and)); assertThat(query.getCriteria().getCriteriaObject(), instanceOf(List.class)); List<Criteria> criteriaList = extractListCriteria(query.getCriteria()); assertCriteria(criteriaList.get(0), is(new QName("http://spring.data.marklogic/test/contact", "skill")), is("foo")); assertCriteria(criteriaList.get(1), is(new QName("http://spring.data.marklogic/test/contact", "skill")), is("bar")); }
From source file:com.example.soaplegacy.WsdlValidator.java
private List<AssertionError> convertErrors(List<XmlError> errors) { if (errors.size() > 0) { List<AssertionError> response = new ArrayList<AssertionError>(); for (Iterator<XmlError> i = errors.iterator(); i.hasNext();) { XmlError error = i.next();/*from w w w . j ava 2s . c o m*/ if (error instanceof XmlValidationError) { XmlValidationError e = ((XmlValidationError) error); QName offendingQName = e.getOffendingQName(); if (offendingQName != null) { if (offendingQName.equals( new QName(wsdlContext.getSoapVersion().getEnvelopeNamespace(), "encodingStyle"))) { log.debug("ignoring encodingStyle validation.."); continue; } else if (offendingQName.equals( new QName(wsdlContext.getSoapVersion().getEnvelopeNamespace(), "mustUnderstand"))) { log.debug("ignoring mustUnderstand validation.."); continue; } } } AssertionError assertionError = new AssertionError(error); if (!response.contains(assertionError)) response.add(assertionError); } return new ArrayList<AssertionError>(response); } return new ArrayList<AssertionError>(); }
From source file:hermes.impl.DefaultXMLHelper.java
public void saveContent(MessageSet messages, Writer writer) throws Exception { JAXBContext jc = JAXBContext.newInstance("hermes.xml"); Marshaller m = jc.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); m.marshal(new JAXBElement<MessageSet>(new QName("", "content"), MessageSet.class, messages), writer); writer.flush();//from w w w . j av a2s.c o m }
From source file:be.fedict.eid.pkira.xkmsws.util.XMLMarshallingUtil.java
public Document marshalBulkRegisterTypeToDocument(BulkRegisterType bulkRegisterType) throws XKMSClientException { QName qname = new QName("http://www.w3.org/2002/03/xkms-xbulk", "BulkRegister"); JAXBElement<BulkRegisterType> jaxbElement = new JAXBElement<BulkRegisterType>(qname, BulkRegisterType.class, bulkRegisterType);/*w w w . j a v a 2 s . co m*/ try { Document doc = documentBuilder.newDocument(); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.marshal(jaxbElement, doc); return doc; } catch (JAXBException e) { throw new XKMSClientException("Cannot marshal message.", e); } }
From source file:org.javelin.sws.ext.bind.jaxb.JaxbTest.java
@Test(expected = IllegalAnnotationsException.class) public void marshalIllegalProperties() throws Exception { JAXBContext ctx = JAXBContext.newInstance(org.javelin.sws.ext.bind.jaxb.context5.MyClassJ5_1.class); Marshaller m = ctx.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); org.javelin.sws.ext.bind.jaxb.context5.MyClassJ5_1 mc5 = new org.javelin.sws.ext.bind.jaxb.context5.MyClassJ5_1(); mc5.setC(String.class); m.marshal(new JAXBElement<org.javelin.sws.ext.bind.jaxb.context5.MyClassJ5_1>(new QName("a", "a"), org.javelin.sws.ext.bind.jaxb.context5.MyClassJ5_1.class, mc5), System.out); }
From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java
@Validated @Test//from ww w . j a v a2 s . com public void testAddAttributeFromNameWithNamespace() throws Exception { SOAPEnvelope envelope = saajUtil.createSOAP11Envelope(); SOAPBody body = envelope.addBody(); SOAPElement element = body.addChildElement(new QName("urn:test", "test")); SOAPElement retValue = element.addAttribute(envelope.createName("attr", "p", "urn:ns"), "value"); assertSame(element, retValue); Attr attr = element.getAttributeNodeNS("urn:ns", "attr"); assertEquals("urn:ns", attr.getNamespaceURI()); assertEquals("attr", attr.getLocalName()); assertEquals("p", attr.getPrefix()); assertEquals("value", attr.getValue()); Attr nsDecl = element.getAttributeNodeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "p"); assertNotNull(nsDecl); assertEquals("urn:ns", nsDecl.getValue()); }
From source file:nz.co.senanque.base.ObjectTest.java
@SuppressWarnings("unused") @Test/*from w w w . j ava 2 s . co m*/ public void test1() throws Exception { ValidationSession validationSession = m_validationEngine.createSession(); // create a customer Customer customer = m_customerDAO.createCustomer(); validationSession.bind(customer); Invoice invoice = new Invoice(); invoice.setDescription("test invoice"); customer.getInvoices().add(invoice); boolean exceptionFound = false; try { customer.setName("ttt"); } catch (ValidationException e) { exceptionFound = true; } assertTrue(exceptionFound); final ObjectMetadata customerMetadata = validationSession.getMetadata(customer); final FieldMetadata customerTypeMetadata = customerMetadata.getFieldMetadata(Customer.CUSTOMERTYPE); assertFalse(customerTypeMetadata.isActive()); assertFalse(customerTypeMetadata.isReadOnly()); assertFalse(customerTypeMetadata.isRequired()); customer.setName("aaaab"); assertTrue(customerTypeMetadata.isActive()); assertTrue(customerTypeMetadata.isReadOnly()); assertTrue(customerTypeMetadata.isRequired()); exceptionFound = false; try { customer.setCustomerType("B"); } catch (Exception e) { exceptionFound = true; } assertTrue(exceptionFound); exceptionFound = false; try { customer.setCustomerType("XXX"); } catch (Exception e) { exceptionFound = true; } assertTrue(exceptionFound); customer.setBusiness(IndustryType.AG); customer.setAmount(new Double(500.99)); final long id = m_customerDAO.save(customer); log.info(id); // fetch customer back customer = m_customerDAO.getCustomer(id); final int invoiceCount = customer.getInvoices().size(); validationSession.bind(customer); invoice = new Invoice(); invoice.setDescription("test invoice2"); customer.getInvoices().add(invoice); m_customerDAO.save(customer); // fetch customer again customer = m_customerDAO.getCustomer(id); customer.toString(); validationSession.bind(customer); final Invoice inv = customer.getInvoices().get(0); customer.getInvoices().remove(inv); //ObjectMetadata metadata = validationSession.getMetadata(customer); ObjectMetadata metadata = customer.getMetadata(); org.junit.Assert.assertEquals("this is a description", metadata.getFieldMetadata(Customer.NAME).getDescription()); List<ChoiceBase> choices = metadata.getFieldMetadata(Customer.BUSINESS).getChoiceList(); assertEquals(1, choices.size()); List<ChoiceBase> choices2 = metadata.getFieldMetadata(Customer.CUSTOMERTYPE).getChoiceList(); assertEquals(2, choices2.size()); choices2 = metadata.getFieldMetadata(Customer.CUSTOMERTYPE).getChoiceList(); assertEquals(2, choices2.size()); customer.setName("aab"); choices2 = metadata.getFieldMetadata(Customer.CUSTOMERTYPE).getChoiceList(); assertEquals(6, choices2.size()); // Convert customer to XML QName qname = new QName("http://www.example.org/sandbox", "Session"); JAXBElement<Session> sessionJAXB = new JAXBElement<Session>(qname, Session.class, new Session()); sessionJAXB.getValue().getCustomers().add(customer); //??This fails to actually add StringWriter marshallWriter = new StringWriter(); Result marshallResult = new StreamResult(marshallWriter); m_marshaller.marshal(sessionJAXB, marshallResult); marshallWriter.flush(); String result = marshallWriter.getBuffer().toString().trim(); String xml = result.replaceAll("\\Qhttp://www.example.org/sandbox\\E", "http://www.example.org/sandbox"); log.info(xml); // Convert customer back to objects SAXBuilder builder = new SAXBuilder(); org.jdom.Document resultDOM = builder.build(new StringReader(xml)); @SuppressWarnings("unchecked") JAXBElement<Session> request = (JAXBElement<Session>) m_unmarshaller.unmarshal(new JDOMSource(resultDOM)); validationSession = m_validationEngine.createSession(); validationSession.bind(request.getValue()); assertEquals(3, validationSession.getProxyCount()); List<Customer> customers = request.getValue().getCustomers(); assertEquals(1, customers.size()); customers.clear(); assertEquals(1, validationSession.getProxyCount()); request.toString(); validationSession.close(); }
From source file:com.eviware.soapui.impl.wsdl.submit.transports.http.AttachmentUtils.java
private static void buildXopInclude(XmlCursor cursor, String contentId) { // build xop:Include XmlCursor c = cursor.newCursor();/*w w w. j a va2 s . c o m*/ c.removeXmlContents(); c.toFirstContentToken(); c.beginElement(new QName("http://www.w3.org/2004/08/xop/include", "Include")); c.insertAttributeWithValue(new QName("href"), "cid:" + contentId); c.toNextSibling(); c.removeXml(); c.dispose(); }
From source file:org.n52.lod.csw.CatalogInteractor.java
public long getNumberOfRecords() throws HttpClientException, IllegalStateException, IOException, XmlException { // ParameterContainer paramCon = new ParameterContainer(); // paramCon.addParameterShell(CSWRequestBuilder.GET_RECORDS_MAX_RECORDS, // 1);/* www . j a va 2s.co m*/ // paramCon.addParameterShell(CSWRequestBuilder.GET_RECORDS_START_POSITION, // 0); // paramCon.addParameterShell(CSWRequestBuilder.GET_RECORDS_RESULT_TYPE, // ResultType.HITS.toString()); // TODO HITS not implemented in OX-F yet... // paramCon.addParameterShell(CSWRequestBuilder.GET_RECORDS_OUTPUT_SCHEMA_FORMAT, // "http://www.opengis.net/cat/csw/2.0.2"); // paramCon.addParameterShell(CSWRequestBuilder.GET_RECORDS_QUERY_TYPE_NAMES_PARAMETER, // "csw:Record"); // paramCon.addParameterShell(CSWRequestBuilder.GET_RECORDS_ELEMENT_SET_NAME_FORMAT, // ElementSetNameType.BRIEF.toString()); // csw?request=GetRecords&service=CSW // &version=2.0.2&namespace=xmlns(csw=http://www.opengis.net/cat/csw) // &resultType=results&outputSchema=http://www.opengis.net/cat/csw/2.0.2 // &outputFormat=application/xml // catalog only support POST for GetRecords GetRecordsDocument xb_getRecordsDocument = GetRecordsDocument.Factory.newInstance(); GetRecordsType xb_getRecords = xb_getRecordsDocument.addNewGetRecords(); xb_getRecords.setService(CSWAdapter.SERVICE_TYPE); xb_getRecords.setVersion(CSWAdapter.SUPPORTED_VERSIONS[0]); xb_getRecords.setResultType(ResultType.HITS); QueryType xb_query = QueryType.Factory.newInstance(); List<QName> typeNameList = new ArrayList<>(); typeNameList.add(new QName(CSWAdapter.NAMESPACE, "Record")); xb_query.setTypeNames(typeNameList); AbstractQueryType abstractQuery = xb_getRecords.addNewAbstractQuery(); abstractQuery.set(xb_query); XmlUtil.qualifySubstitutionGroup(xb_getRecords.getAbstractQuery(), QueryDocument.type.getDocumentElementName(), QueryType.type); String request = xb_getRecordsDocument.xmlText(new XmlOptions().setSavePrettyPrint()); SimpleHttpClient httpClient = new SimpleHttpClient(20000); String cswUrl = config.getUrlCSW(); HttpResponse response = httpClient.executePost(cswUrl, request, ContentType.TEXT_XML); GetRecordsResponseDocument doc = GetRecordsResponseDocument.Factory .parse(response.getEntity().getContent()); BigInteger numberOfRecordsMatched = doc.getGetRecordsResponse().getSearchResults() .getNumberOfRecordsMatched(); return numberOfRecordsMatched.longValue(); }