public static OMElement xmlObjectToOMElement(XmlObject responseXmlObj) throws XMLStreamException { String responseXml; XmlOptions opts = new XmlOptions(); opts.setSaveOuter(); responseXml = responseXmlObj.xmlText(opts); OMElement outgoingMsg = org.apache.airavata.commons.WorkFlowUtils.reader2OMElement(new StringReader(responseXml)); return outgoingMsg; }
public static String createSampleForElement(SchemaGlobalElement element) { XmlObject xml = XmlObject.Factory.newInstance(); XmlCursor c = xml.newCursor(); c.toNextToken(); c.beginElement(element.getName()); new SampleXmlUtil(false).createSampleForType(element.getType(), c); c.dispose(); XmlOptions options = new XmlOptions(); options.put(XmlOptions.SAVE_PRETTY_PRINT); options.put(XmlOptions.SAVE_PRETTY_PRINT_INDENT, 3); options.put(XmlOptions.SAVE_AGGRESSIVE_NAMESPACES); options.setSaveOuter(); String result = xml.xmlText(options); return result; }
public static String createSampleForType(SchemaType sType) { XmlObject object = XmlObject.Factory.newInstance(); XmlCursor cursor = object.newCursor(); // Skip the document node cursor.toNextToken(); // Using the type and the cursor, call the utility method to get a // sample XML payload for that Schema element new SampleXmlUtil(false).createSampleForType(sType, cursor); // Cursor now contains the sample payload // Pretty print the result. Note that the cursor is positioned at the // end of the doc so we use the original xml object that the cursor was // created upon to do the xmlText() against. cursor.dispose(); XmlOptions options = new XmlOptions(); options.put(XmlOptions.SAVE_PRETTY_PRINT); options.put(XmlOptions.SAVE_PRETTY_PRINT_INDENT, 3); options.put(XmlOptions.SAVE_AGGRESSIVE_NAMESPACES); options.setSaveOuter(); String result = object.xmlText(options); return result; }