List of utility methods to do XML Transform Usage
String | encodeBase64(Element elm) encode Base ByteArrayOutputStream ostream = new ByteArrayOutputStream(); TransformerFactory transFac = TransformerFactory.newInstance(); Transformer trans = transFac.newTransformer(); trans.transform(new DOMSource(elm), new StreamResult(ostream)); return (new String(Base64.encodeBase64(ostream.toByteArray(), true))); |
String | getCalendarAsXsdDateTime(Calendar c) Transforms a given Java Calendar object to a xsd:DateTime String. return DatatypeConverter.printDateTime(c);
|
String | getContentText(Element element) get Content Text StringBuffer buffer = new StringBuffer(); NodeList nodeList = element.getChildNodes(); for (int i = 0; i < nodeList.getLength(); i++) { Node node = nodeList.item(i); if (node instanceof CharacterData) { CharacterData characterData = (CharacterData) node; buffer.append(characterData.getData()); return buffer.toString(); |
Date | getDate(final XMLGregorianCalendar xmlGregorianCalendar) Takes an XMLGregorianCalendar and converts it to an Date . Date date = null; if (xmlGregorianCalendar != null) { final GregorianCalendar gregorianCalendar = xmlGregorianCalendar.toGregorianCalendar(); date = gregorianCalendar.getTime(); return date; |
void | getEmptyXmlFile(File xmlFile) creates a new xmlfile with a "reports" son for the reports usage Element main;
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = db.newDocument();
main = doc.createElement("reports");
doc.appendChild(main);
saveDocumentToFile(doc, xmlFile);
|
Object | getImplementationObject() get Implementation Object Service service = Service.create(new QName("dummyService")); Object obj = service.getHandlerResolver(); if (obj == null) { service.addPort(new QName("dummyPort"), SOAPBinding.SOAP11HTTP_BINDING, "http://dummy-address"); obj = service.createDispatch(new QName("dummyPort"), Source.class, Mode.PAYLOAD); return obj; |
Reader | getNormalizedReader(Reader reader) get Normalized Reader return reader;
|
SAXSource | getSaxSource(File newFile, SAXParserFactory spf) get Sax Source XMLReader xmlReader = spf.newSAXParser().getXMLReader(); return new SAXSource(xmlReader, new InputSource(new FileInputStream(newFile))); |
Schema | getSchema(InputStream... inputs) get Schema StreamSource[] streamSource = new StreamSource[inputs.length]; for (int i = 0; i < inputs.length; i++) { streamSource[i] = new StreamSource(inputs[i]); SchemaFactory sf = SchemaFactory.newInstance(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = sf.newSchema(streamSource); return schema; |
Source | getSourceFromEndpointReference(EndpointReference epr) get Source From Endpoint Reference ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); StreamResult result = new StreamResult(outputStream); epr.writeTo(result); return new StreamSource(new ByteArrayInputStream(outputStream.toByteArray())); |