List of utility methods to do XML Transform Usage
StreamSource[] | getStreamSources(File[] stylesheets) get Stream Sources StreamSource[] ss = new StreamSource[stylesheets.length]; for (int i = 0; i < stylesheets.length; i++) { ss[i] = new StreamSource(stylesheets[i]); return ss; |
Templates | getTemplatesByName(File xslF) get Templates By Name Templates templates = null; TransformerFactory tfactory = TransformerFactory.newInstance(); tfactory.setAttribute("http://xml.apache.org/xalan/features/incremental", java.lang.Boolean.TRUE); InputStream is = null; try { StreamSource ss = new StreamSource(xslF); is = ss.getInputStream(); templates = tfactory.newTemplates(ss); ... |
String | getWSAAddress(W3CEndpointReference ref) get WSA Address try { Document xmlDocument = null; xmlDocument = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument(); Element element = xmlDocument.createElement("elem"); ref.writeTo(new DOMResult(element)); NodeList nl = element.getElementsByTagNameNS("http://www.w3.org/2005/08/addressing", "Address"); if (nl != null && nl.getLength() > 0) { Element e = (Element) nl.item(0); ... |
XMLGregorianCalendar | getXMLCalendar(Date date) Transform a Java date into a XML calendar. GregorianCalendar c = new GregorianCalendar(); c.setTimeZone(TimeZone.getTimeZone("UTC")); c.setTime(date); try { return getDatatypeFactory().newXMLGregorianCalendar(c); } catch (DatatypeConfigurationException e) { return null; |
XMLEventWriter | getXmlEventWriter(Result r) get Xml Event Writer Method m = r.getClass().getDeclaredMethod("getXMLEventWriter", new Class[] {}); boolean accessible = m.isAccessible(); m.setAccessible(true); Object result = m.invoke(r); m.setAccessible(accessible); return (XMLEventWriter) result; |
XMLGregorianCalendar | longToGregorian(long date) Transform a date in a long to a GregorianCalendar DatatypeFactory dataTypeFactory; try { dataTypeFactory = DatatypeFactory.newInstance(); } catch (DatatypeConfigurationException e) { throw new RuntimeException(e); GregorianCalendar gc = new GregorianCalendar(); gc.setTimeInMillis(date); ... |
String | map2Xml(Map map) map Xml StringBuffer sbf = new StringBuffer(); map2Xml(sbf, map); return xmlFormat(sbf.toString()); |
Schema | newSchema(File xmlSchema) Creates a new Schema using the default XML implementation try { return W3X_XML_SCHEMA_FACTORY.newSchema(xmlSchema); } catch (SAXException e) { throw new RuntimeException("Could not create schema for file '" + xmlSchema.getName() + "'!", e); |
Schema | newSchema(Source[] schemas) new Schema synchronized (XSD_SCHEMA_FACTORY) { return XSD_SCHEMA_FACTORY.newSchema(schemas); |
boolean | paramsEqual(AlgorithmParameterSpec spec1, AlgorithmParameterSpec spec2) params Equal if (spec1 == spec2) { return true; if (spec1 instanceof XPathFilter2ParameterSpec && spec2 instanceof XPathFilter2ParameterSpec) { return paramsEqual((XPathFilter2ParameterSpec) spec1, (XPathFilter2ParameterSpec) spec2); if (spec1 instanceof ExcC14NParameterSpec && spec2 instanceof ExcC14NParameterSpec) { return paramsEqual((ExcC14NParameterSpec) spec1, (ExcC14NParameterSpec) spec2); ... |