List of utility methods to do XML Transform Usage
XMLStreamReader | createSafeReader(InputStream inputStream) create Safe Reader if (inputStream == null) { throw new IllegalArgumentException("The provided input stream cannot be null"); return createSafeReader(new StreamSource(inputStream)); |
Source | createSource(InputStream is) Creates a Source from an InputStream. return new StreamSource(is); |
Result | createStaxResult(XMLStreamWriter streamWriter) Create a JAXP 1.4 StAXResult for the given XMLStreamWriter . return new StAXResult(streamWriter); |
Source | createStaxSource(XMLStreamReader streamReader) Create a JAXP 1.4 javax.xml.transform.stax.StAXSource for the given javax.xml.stream.XMLStreamReader . return new StAXSource(streamReader); |
StreamResult | createStreamResult(File outFile) Creae a stream result based on a File. final StreamResult result = new StreamResult(outFile); result.setOutputStream(new FileOutputStream(outFile)); return result; |
StreamResult | createUnixStreamResultForEntry(OutputStream outputEntry) Creates a StreamResult by wrapping the given outputEntry in an OutputStreamWriter that transforms Windows line endings (\r\n) into Unix line endings (\n) on Windows for consistency with Roo's templates. final Writer writer; if (System.getProperty("line.separator").equals("\r\n")) { writer = new OutputStreamWriter(outputEntry, "ISO-8859-1") { public void write(char[] cbuf, int off, int len) throws IOException { for (int i = off; i < off + len; i++) { if (cbuf[i] != '\r' || (i < cbuf.length - 1 && cbuf[i + 1] != '\n')) { super.write(cbuf[i]); public void write(int c) throws IOException { if (c != '\r') super.write(c); public void write(String str, int off, int len) throws IOException { String orig = str.substring(off, off + len); String filtered = orig.replace("\r\n", "\n"); int lengthDiff = orig.length() - filtered.length(); if (filtered.endsWith("\r")) { super.write(filtered.substring(0, filtered.length() - 1), 0, len - lengthDiff - 1); } else { super.write(filtered, 0, len - lengthDiff); }; } else { writer = new OutputStreamWriter(outputEntry, "ISO-8859-1"); return new StreamResult(writer); |
XMLGregorianCalendar | dateToGregorian(Date date) Transform a date in Date to XMLGregorianCalendar return longToGregorian(date.getTime());
|
XMLGregorianCalendar | DateToXML(Date date) Date To XML GregorianCalendar c = new GregorianCalendar(); c.setTime(date); XMLGregorianCalendar xmlDate = null; try { xmlDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(c); } catch (Exception e) { try { c.setTime(new Date()); ... |
void | dumpMetadata(IIOMetadata meta) dump Metadata String format = meta.getNativeMetadataFormatName(); Node node = meta.getAsTree(format); dumpNode(node); |
void | dumpMetadataToSystemOut(IIOMetadata iiometa) Dumps the content of an IIOMetadata instance to System.out. String[] metanames = iiometa.getMetadataFormatNames(); for (int j = 0; j < metanames.length; j++) { System.out.println("--->" + metanames[j]); dumpNodeToSystemOut(iiometa.getAsTree(metanames[j])); |