List of usage examples for javax.xml.transform.dom DOMResult getNode
public Node getNode()
From source file:org.docx4j.openpackaging.parts.PresentationML.SlidePart.java
/** * Unmarshal XML data from the specified InputStream and return the * resulting content tree. Validation event location information may * be incomplete when using this form of the unmarshal API. * * <p>//from w w w .j a v a 2 s . c om * Implements <a href="#unmarshalGlobal">Unmarshal Global Root Element</a>. * * @param is the InputStream to unmarshal XML data from * @return the newly created root object of the java content tree * * @throws JAXBException * If any unexpected errors occur while unmarshalling */ @Override public Sld unmarshal(java.io.InputStream is) throws JAXBException { try { // InputStream to Document org.w3c.dom.Document doc = XmlUtils.getNewDocumentBuilder().parse(is); /* Note: 2013 04 25 * * If a slide (or slide master etc) contains: * <a:graphicData uri="http://schemas.openxmlformats.org/presentationml/2006/ole"> <mc:AlternateContent xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"> <mc:Choice xmlns:v="urn:schemas-microsoft-com:vml" Requires="v"> <p:oleObj spid="_x0000_s574471" name="Slide" r:id="rId4" imgW="4657680" imgH="3492360" progId="PowerPoint.Slide.8"> <p:embed/> </p:oleObj> </mc:Choice> * * this alternate content wouldn't get stripped by: * * (Sld) binder.unmarshal( doc ); * * because the content model for a:graphicData is: * * <xsd:sequence> <xsd:any minOccurs="0" maxOccurs="unbounded" processContents="strict"/> </xsd:sequence> * * The problem with this is that JAXB marshalls it as: * <a:graphicData uri="http://schemas.openxmlformats.org/presentationml/2006/ole"> <mc:AlternateContent> <mc:Choice Requires="v"> <p:oleObj xmlns:v="urn:schemas-microsoft-com:vml" imgH="3492360" imgW="4657680" name="Slide" progId="PowerPoint.Slide.8" r:id="rId4" spid="_x0000_s574471"> <p:embed/> </p:oleObj> </mc:Choice> * * (note the namespace declaration is legitimately missing from the mc:Choice element; * but this causes Powerpoint 2010 to say the file needs to be repaired!!!). * * I don't think there's a way to cajole JAXB to add a namespace where it is not necessary. * After marshalling, we could post process to add it back in (not with XSLT, since * that'll do its own thing with namespaces, but we could with regex). * * But it is better, I think to always get rid of the alternate content entirely. * * 2015 07 29 Update: since we do add the VML namespace (see marshal method above), * there is no need to remove it during unmashalling, so we could get rid of this * Override. But not for 3.2.2 which is so close to release. */ log.info("proactively pre-processing to remove any AlternateContent"); JaxbValidationEventHandler eventHandler = new JaxbValidationEventHandler(); eventHandler.setContinue(true); // There is no JAXBResult(binder), // so use a DOMResult result = new DOMResult(); Templates mcPreprocessorXslt = JaxbValidationEventHandler.getMcPreprocessor(); XmlUtils.transform(doc, mcPreprocessorXslt, null, result); doc = (org.w3c.dom.Document) result.getNode(); try { binder = jc.createBinder(); // eventHandler.setContinue(false); // review binder.setEventHandler(eventHandler); jaxbElement = (Sld) binder.unmarshal(doc); } catch (ClassCastException cce) { log.warn("Binder not available for this slide"); Unmarshaller u = jc.createUnmarshaller(); jaxbElement = (Sld) u.unmarshal(doc); /* * Work around for issue with JAXB binder, in Java 1.6 * encountered with /src/test/resources/jaxb-binder-issue.docx * See http://old.nabble.com/BinderImpl.associativeUnmarshal-ClassCastException-casting-to-JAXBElement-td32456585.html * and http://java.net/jira/browse/JAXB-874 * * java.lang.ClassCastException: org.docx4j.wml.PPr cannot be cast to javax.xml.bind.JAXBElement at com.sun.xml.internal.bind.v2.runtime.ElementBeanInfoImpl$IntercepterLoader.intercept(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallingContext.endElement(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.unmarshaller.InterningXmlVisitor.endElement(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.unmarshaller.SAXConnector.endElement(Unknown Source) at com.sun.xml.internal.bind.unmarshaller.DOMScanner.visit(Unknown Source) at com.sun.xml.internal.bind.unmarshaller.DOMScanner.scan(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.BinderImpl.associativeUnmarshal(Unknown Source) at com.sun.xml.internal.bind.v2.runtime.BinderImpl.unmarshal(Unknown Source) at org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart.unmarshal(MainDocumentPart.java:321) */ } return jaxbElement; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:org.docx4j.openpackaging.parts.PresentationML.SlidePart.java
public Sld unmarshal(org.w3c.dom.Element el) throws JAXBException { // Note comments above about AlternateContent. // unmarshalling here from an Element doesn't implement that fix, so beware. try {/*from w w w .j a va2 s.c o m*/ binder = jc.createBinder(); JaxbValidationEventHandler eventHandler = new JaxbValidationEventHandler(); eventHandler.setContinue(false); binder.setEventHandler(eventHandler); try { jaxbElement = (Sld) binder.unmarshal(el); } catch (UnmarshalException ue) { log.info("encountered unexpected content; pre-processing"); try { org.w3c.dom.Document doc; if (el instanceof org.w3c.dom.Document) { doc = (org.w3c.dom.Document) el; } else { // Hope for the best. Dodgy though; what if this is // being used on something deep in the tree? // TODO: revisit doc = el.getOwnerDocument(); } eventHandler.setContinue(true); DOMResult result = new DOMResult(); Templates mcPreprocessorXslt = JaxbValidationEventHandler.getMcPreprocessor(); XmlUtils.transform(doc, mcPreprocessorXslt, null, result); doc = (org.w3c.dom.Document) result.getNode(); jaxbElement = (Sld) binder.unmarshal(doc); } catch (Exception e) { throw new JAXBException("Preprocessing exception", e); } } return jaxbElement; } catch (JAXBException e) { log.error(e.getMessage(), e); throw e; } }
From source file:org.easyrec.service.domain.profile.impl.TypeSpecificProfileMatcherImpl.java
public float match(ItemVO<Integer, String> item1, ItemVO<Integer, String> item2) { //DocumentInfo param=null; //XdmNode param=null; //TODO: lookup-code for profiles from Manager float ret = -1; StringBuffer sb = new StringBuffer(PROFILES_START); String profile1 = profileService.getProfile(item1.getTenant(), item1.getItem(), item1.getType()); String profile2 = profileService.getProfile(item2.getTenant(), item2.getItem(), item2.getType()); // StreamSource refP = new StreamSource(new StringReader(profile1)); // try { // DocumentBuilder db = proc.newDocumentBuilder(); // param = db.build(refP); ////from w w w.ja v a2s .c om // //param = cfg.buildDocument(refP); // } catch (Exception e) { // logger.debug("Error building refParameter"); // } // logger.debug(param.getStringValue()); sb.append(profile1).append(profile2).append(PROFILES_STOP); logger.debug(sb.toString()); //XSLTMatcher.setParameter("refProfile", param.axisIterator(Axis.CHILD)); try { DOMResult result = new DOMResult(); //StreamResult result = new StreamResult(System.out); XSLTMatcher.transform(new StreamSource(new StringReader(sb.toString())), result); // logger.debug(result.getNode().getFirstChild().getTextContent()); //logger.debug(result.getNode().getFirstChild().getNodeType()); ret = Float.valueOf(result.getNode().getFirstChild().getTextContent()); } catch (Exception e) { logger.debug("Error matching profiles!" + e); } return ret; }
From source file:org.f2o.absurdum.puck.gui.PuckFrame.java
private void openSource(StreamSource s) throws TransformerException { Transformer t = TransformerFactory.newInstance().newTransformer(); DOMResult r = new DOMResult(); t.transform(s, r);//from www. j a v a2s. co m GraphElementPanel.emptyQueue(); graphPanel.clear(); propPanel.clear(); JSyntaxBSHCodeFrame.closeAllInstances(); WorldPanel wp = new WorldPanel(graphPanel); WorldNode wn = new WorldNode(wp); graphPanel.setWorldNode(wn); wp.initFromXML(((Document) r.getNode()).getFirstChild()); //revalidate(); //only since java 1.7 //invalidate(); //validate(); split.revalidate(); //JComponents do have it before java 1.7 (not JFrame) }
From source file:org.finra.jtaf.ewd.impl.DefaultExtWebDriver.java
@Override public String evaluateXpath(String xpath) throws Exception { XPathFactory xpathFac = XPathFactory.newInstance(); XPath theXpath = xpathFac.newXPath(); String html = getHtmlSource(); html = html.replaceAll(">\\s+<", "><"); InputStream input = new ByteArrayInputStream(html.getBytes()); XMLReader reader = new Parser(); reader.setFeature(Parser.namespacesFeature, false); Transformer transformer = TransformerFactory.newInstance().newTransformer(); DOMResult result = new DOMResult(); transformer.transform(new SAXSource(reader, new InputSource(input)), result); Node htmlNode = result.getNode(); // This code gets a Node from the // result./*from www . j a v a 2s. co m*/ return (String) theXpath.evaluate(xpath, htmlNode, XPathConstants.STRING); }
From source file:org.finra.jtaf.ewd.widget.element.Element.java
/** * Get the list of nodes which satisfy the xpath expression passed in * //from w w w . j av a 2 s . c o m * @param xpath * the input xpath expression * @return the nodeset of matching elements * @throws Exception */ private NodeList getNodeListUsingJavaXPath(String xpath) throws Exception { XPathFactory xpathFac = XPathFactory.newInstance(); XPath theXpath = xpathFac.newXPath(); String html = getGUIDriver().getHtmlSource(); html = html.replaceAll(">\\s+<", "><"); InputStream input = new ByteArrayInputStream(html.getBytes()); XMLReader reader = new Parser(); reader.setFeature(Parser.namespacesFeature, false); Transformer transformer = TransformerFactory.newInstance().newTransformer(); DOMResult result = new DOMResult(); transformer.transform(new SAXSource(reader, new InputSource(input)), result); Node htmlNode = result.getNode(); // This code gets a Node from the // result. NodeList nodes = (NodeList) theXpath.evaluate(xpath, htmlNode, XPathConstants.NODESET); return nodes; }
From source file:org.fireflow.pdl.fpdl.test.service.callback.TheCallbackServiceProcessTest1.java
@Test public void testCallbackService() { final WorkflowSession session = WorkflowSessionFactory.createWorkflowSession(fireflowRuntimeContext, FireWorkflowSystem.getInstance()); final WorkflowStatement stmt = session.createWorkflowStatement(FpdlConstants.PROCESS_TYPE_FPDL20); //0??/* ww w . j a va2 s . c o m*/ final WorkflowProcess process = getWorkflowProcess(); //1??? transactionTemplate.execute(new TransactionCallback() { public Object doInTransaction(TransactionStatus arg0) { //? try { ProcessDescriptor descriptor = stmt.uploadProcessObject(process, 0); ((ProcessDescriptorImpl) descriptor).setPublishState(true); stmt.updateProcessDescriptor(descriptor); } catch (InvalidModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }); //2?CallbackManagerinit?Webservice //TODO WorkflowServer?webservice /* WebServiceManager callbackManager = this.runtimeContext.getEngineModule(WebServiceManager.class, FpdlConstants.PROCESS_TYPE_FPDL20); try { callbackManager.publishAllCallbackServices(); } catch (WebservicePublishException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } */ //3??? transactionTemplate.execute(new TransactionCallback() { public Object doInTransaction(TransactionStatus arg0) { //?? try { ProcessInstance processInstance = stmt.startProcess(process.getId(), bizId, null); if (processInstance != null) { processInstanceId = processInstance.getId(); } } catch (InvalidModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (WorkflowProcessNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvalidOperationException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }); //JaxwsWebservice Environment env = fireflowRuntimeContext.getEngineModule(Environment.class, FpdlConstants.PROCESS_TYPE_FPDL20); URL url = null; try { String contextPath = env.getWebserviceContextPath(); if (!contextPath.startsWith("/")) { contextPath = "/" + contextPath; } if (!contextPath.endsWith("/")) { contextPath = contextPath + "/"; } String address = "http://" + env.getWebserviceIP() + ":" + Integer.toString(env.getWebservicePort()) + contextPath; url = new URL(address + serviceQName.getLocalPart() + "?wsdl"); } catch (Exception e) { e.printStackTrace(); } javax.xml.ws.Service jawsService = javax.xml.ws.Service.create(url, serviceQName); Dispatch<Source> dispatch = jawsService.createDispatch(portQName, Source.class, javax.xml.ws.Service.Mode.PAYLOAD); String messageStr = "<cal:acceptRequest xmlns:cal=\"http://www.fireflow.org/junit/callbackservice\">" + "<cal:id>" + bizId + "</cal:id>" + "<cal:approveResult>" + approveResult + "</cal:approveResult>" + "</cal:acceptRequest>"; java.io.ByteArrayInputStream byteInStream = new java.io.ByteArrayInputStream(messageStr.getBytes()); StreamSource source = new StreamSource(byteInStream); Source response = dispatch.invoke(source); DOMResult result = new DOMResult(); // StreamResult result = new StreamResult(System.out); Transformer transformer = null; try { TransformerFactory transformerFactory = TransformerFactory.newInstance(); transformer = transformerFactory.newTransformer(); transformer.transform(response, result); } catch (TransformerConfigurationException e) { throw new RuntimeException("Couldn't parse response stream.", e); } catch (TransformerException e) { throw new RuntimeException("Couldn't parse response stream.", e); } Document theResponsePayload = (Document) result.getNode(); Assert.assertNotNull(theResponsePayload); JXPathContext jxpathContext = JXPathContext.newContext(theResponsePayload); jxpathContext.registerNamespace("ns0", targetNsUri); String response2 = (String) jxpathContext.getValue("ns0:acceptResponse/ns0:response2"); Assert.assertEquals(responseResult, response2); this.assertResult(session); }
From source file:org.fireflow.pdl.fpdl.test.service.callback.WebserviceStartProcessTest.java
@Test public void testCallbackService() { final WorkflowSession session = WorkflowSessionFactory.createWorkflowSession(fireflowRuntimeContext, FireWorkflowSystem.getInstance()); final WorkflowStatement stmt = session.createWorkflowStatement(FpdlConstants.PROCESS_TYPE_FPDL20); //0??//from www .j a v a 2 s . com final WorkflowProcess process = getWorkflowProcess(); //1??? transactionTemplate.execute(new TransactionCallback() { public Object doInTransaction(TransactionStatus arg0) { //? try { ProcessDescriptor descriptor = stmt.uploadProcessObject(process, 0); ((ProcessDescriptorImpl) descriptor).setPublishState(true); stmt.updateProcessDescriptor(descriptor); } catch (InvalidModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }); //2?CallbackManagerinit?Webservice //TODO WorkflowServer?webservice // WebServiceManager callbackManager = this.runtimeContext.getEngineModule(WebServiceManager.class, FpdlConstants.PROCESS_TYPE_FPDL20); // try { // callbackManager.publishAllCallbackServices(); // } catch (WebservicePublishException e1) { // // TODO Auto-generated catch block // e1.printStackTrace(); // } //JaxwsWebservice Environment env = fireflowRuntimeContext.getEngineModule(Environment.class, FpdlConstants.PROCESS_TYPE_FPDL20); URL url = null; try { String contextPath = env.getWebserviceContextPath(); if (!contextPath.startsWith("/")) { contextPath = "/" + contextPath; } if (!contextPath.endsWith("/")) { contextPath = contextPath + "/"; } String address = "http://" + env.getWebserviceIP() + ":" + Integer.toString(env.getWebservicePort()) + contextPath; url = new URL(address + serviceQName.getLocalPart() + "?wsdl"); } catch (Exception e) { e.printStackTrace(); } javax.xml.ws.Service jawsService = javax.xml.ws.Service.create(url, serviceQName); Dispatch<Source> dispatch = jawsService.createDispatch(portQName, Source.class, javax.xml.ws.Service.Mode.PAYLOAD); String messageStr = "<cal:acceptRequest xmlns:cal=\"" + targetNsUri + "\">" + "<cal:id>" + bizId + "</cal:id>" + "<cal:approveResult>" + approveResult + "</cal:approveResult>" + "</cal:acceptRequest>"; java.io.ByteArrayInputStream byteInStream = new java.io.ByteArrayInputStream(messageStr.getBytes()); StreamSource source = new StreamSource(byteInStream); Source response = dispatch.invoke(source); DOMResult result = new DOMResult(); // StreamResult result = new StreamResult(System.out); Transformer transformer = null; try { TransformerFactory transformerFactory = TransformerFactory.newInstance(); transformer = transformerFactory.newTransformer(); transformer.transform(response, result); } catch (TransformerConfigurationException e) { throw new RuntimeException("Couldn't parse response stream.", e); } catch (TransformerException e) { throw new RuntimeException("Couldn't parse response stream.", e); } Document theResponsePayload = (Document) result.getNode(); Assert.assertNotNull(theResponsePayload); JXPathContext jxpathContext = JXPathContext.newContext(theResponsePayload); jxpathContext.registerNamespace("ns0", targetNsUri); String response2 = (String) jxpathContext.getValue("ns0:acceptResponse/ns0:response2"); String response1 = (String) jxpathContext.getValue("ns0:acceptResponse/ns0:response1"); Assert.assertEquals(responseResult, response2); Assert.assertNotNull(response1); this.processInstanceId = response1; this.assertResult(session); }
From source file:org.fireflow.pdl.fpdl20.test.service.callback.TheCallbackServiceProcessTest1.java
@Test public void testCallbackService() { final WorkflowSession session = WorkflowSessionFactory.createWorkflowSession(runtimeContext, FireWorkflowSystem.getInstance()); final WorkflowStatement stmt = session.createWorkflowStatement(FpdlConstants.PROCESS_TYPE_FPDL20); //0??//from w w w. j av a 2 s . c o m final WorkflowProcess process = getWorkflowProcess(); //1??? transactionTemplate.execute(new TransactionCallback() { public Object doInTransaction(TransactionStatus arg0) { //? try { stmt.uploadProcessObject(process, true, null, null); } catch (InvalidModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }); //2?CallbackManagerinit?Webservice WebServiceManager callbackManager = this.runtimeContext.getEngineModule(WebServiceManager.class, FpdlConstants.PROCESS_TYPE_FPDL20); try { callbackManager.publishAllCallbackServices(); } catch (WebservicePublishException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //3??? transactionTemplate.execute(new TransactionCallback() { public Object doInTransaction(TransactionStatus arg0) { //?? try { ProcessInstance processInstance = stmt.startProcess(process.getId(), bizId, null); if (processInstance != null) { processInstanceId = processInstance.getId(); } } catch (InvalidModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (WorkflowProcessNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvalidOperationException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }); //JaxwsWebservice Environment env = runtimeContext.getEngineModule(Environment.class, FpdlConstants.PROCESS_TYPE_FPDL20); URL url = null; try { String contextPath = env.getWebserviceContextPath(); if (!contextPath.startsWith("/")) { contextPath = "/" + contextPath; } if (!contextPath.endsWith("/")) { contextPath = contextPath + "/"; } String address = "http://" + env.getWebserviceIP() + ":" + Integer.toString(env.getWebservicePort()) + contextPath; url = new URL(address + serviceQName.getLocalPart() + "?wsdl"); } catch (Exception e) { e.printStackTrace(); } javax.xml.ws.Service jawsService = javax.xml.ws.Service.create(url, serviceQName); Dispatch<Source> dispatch = jawsService.createDispatch(portQName, Source.class, javax.xml.ws.Service.Mode.PAYLOAD); String messageStr = "<cal:acceptRequest xmlns:cal=\"http://www.fireflow.org/junit/callbackservice\">" + "<cal:id>" + bizId + "</cal:id>" + "<cal:approveResult>" + approveResult + "</cal:approveResult>" + "</cal:acceptRequest>"; java.io.ByteArrayInputStream byteInStream = new java.io.ByteArrayInputStream(messageStr.getBytes()); StreamSource source = new StreamSource(byteInStream); Source response = dispatch.invoke(source); DOMResult result = new DOMResult(); // StreamResult result = new StreamResult(System.out); Transformer transformer = null; try { TransformerFactory transformerFactory = TransformerFactory.newInstance(); transformer = transformerFactory.newTransformer(); transformer.transform(response, result); } catch (TransformerConfigurationException e) { throw new RuntimeException("Couldn't parse response stream.", e); } catch (TransformerException e) { throw new RuntimeException("Couldn't parse response stream.", e); } Document theResponsePayload = (Document) result.getNode(); Assert.assertNotNull(theResponsePayload); JXPathContext jxpathContext = JXPathContext.newContext(theResponsePayload); jxpathContext.registerNamespace("ns0", targetNsUri); String response2 = (String) jxpathContext.getValue("ns0:acceptResponse/ns0:response2"); Assert.assertEquals(responseResult, response2); this.assertResult(session); }
From source file:org.fireflow.pdl.fpdl20.test.service.callback.WebserviceStartProcessTest.java
@Test public void testCallbackService() { final WorkflowSession session = WorkflowSessionFactory.createWorkflowSession(runtimeContext, FireWorkflowSystem.getInstance()); final WorkflowStatement stmt = session.createWorkflowStatement(FpdlConstants.PROCESS_TYPE_FPDL20); //0??// ww w . j ava 2 s. c o m final WorkflowProcess process = getWorkflowProcess(); //1??? transactionTemplate.execute(new TransactionCallback() { public Object doInTransaction(TransactionStatus arg0) { //? try { stmt.uploadProcessObject(process, true, null, null); } catch (InvalidModelException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; } }); //2?CallbackManagerinit?Webservice WebServiceManager callbackManager = this.runtimeContext.getEngineModule(WebServiceManager.class, FpdlConstants.PROCESS_TYPE_FPDL20); try { callbackManager.publishAllCallbackServices(); } catch (WebservicePublishException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } //JaxwsWebservice Environment env = runtimeContext.getEngineModule(Environment.class, FpdlConstants.PROCESS_TYPE_FPDL20); URL url = null; try { String contextPath = env.getWebserviceContextPath(); if (!contextPath.startsWith("/")) { contextPath = "/" + contextPath; } if (!contextPath.endsWith("/")) { contextPath = contextPath + "/"; } String address = "http://" + env.getWebserviceIP() + ":" + Integer.toString(env.getWebservicePort()) + contextPath; url = new URL(address + serviceQName.getLocalPart() + "?wsdl"); } catch (Exception e) { e.printStackTrace(); } javax.xml.ws.Service jawsService = javax.xml.ws.Service.create(url, serviceQName); Dispatch<Source> dispatch = jawsService.createDispatch(portQName, Source.class, javax.xml.ws.Service.Mode.PAYLOAD); String messageStr = "<cal:acceptRequest xmlns:cal=\"" + targetNsUri + "\">" + "<cal:id>" + bizId + "</cal:id>" + "<cal:approveResult>" + approveResult + "</cal:approveResult>" + "</cal:acceptRequest>"; java.io.ByteArrayInputStream byteInStream = new java.io.ByteArrayInputStream(messageStr.getBytes()); StreamSource source = new StreamSource(byteInStream); Source response = dispatch.invoke(source); DOMResult result = new DOMResult(); // StreamResult result = new StreamResult(System.out); Transformer transformer = null; try { TransformerFactory transformerFactory = TransformerFactory.newInstance(); transformer = transformerFactory.newTransformer(); transformer.transform(response, result); } catch (TransformerConfigurationException e) { throw new RuntimeException("Couldn't parse response stream.", e); } catch (TransformerException e) { throw new RuntimeException("Couldn't parse response stream.", e); } Document theResponsePayload = (Document) result.getNode(); Assert.assertNotNull(theResponsePayload); JXPathContext jxpathContext = JXPathContext.newContext(theResponsePayload); jxpathContext.registerNamespace("ns0", targetNsUri); String response2 = (String) jxpathContext.getValue("ns0:acceptResponse/ns0:response2"); String response1 = (String) jxpathContext.getValue("ns0:acceptResponse/ns0:response1"); Assert.assertEquals(responseResult, response2); Assert.assertNotNull(response1); this.processInstanceId = response1; this.assertResult(session); }