private static void doSerialize(OutputStream outputStream, Document document, String encoding) { try { Transformer transformer = new DefaultJAXPConfiguration().createTransformer(encoding); // Be sure to use actual encoding of the transformer which might be non-null even if encoding started as null. encoding = transformer.getOutputProperty(OutputKeys.ENCODING); Writer writer = encoding == null ? new OutputStreamWriter(outputStream) : new OutputStreamWriter(outputStream, encoding); transformer.transform(new DOMSource(document), new StreamResult(writer)); } catch (Exception exception) { WSDLPlugin.INSTANCE.log(exception); } }
saxParser = new DefaultJAXPConfiguration().createSAXParser(this);
/** * Builds a document using default JAXP. * @deprecated since 2.2 * @see #getDocument(InputSource, ErrorHandler, Map) * @param inputSource the contents to parse. * @param errorHandler the handled used by the parser. * @return a document. */ @Deprecated protected static Document getDocument(InputSource inputSource, ErrorHandler errorHandler) throws IOException { try { DocumentBuilder documentBuilder = new DefaultJAXPConfiguration().createDocumentBuilder(errorHandler); Document document = documentBuilder.parse(inputSource); return document; } catch (ParserConfigurationException exception) { throw new IOWrappedException(exception); } catch (SAXException exception) { throw new IOWrappedException(exception); } }
/** * Creates an instance using {@link DefaultJAXPConfiguration}. */ public DefaultJAXPPool() { this(new DefaultJAXPConfiguration()); }
/** * Creates a DocumentBuilder and sets some default options. * If features or properties are available, these features and properties are set on the documentBuilder. */ public DocumentBuilder createDocumentBuilder(ErrorHandler errorHandler) throws ParserConfigurationException { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); documentBuilderFactory.setValidating(false); try { documentBuilderFactory.setAttribute("http://apache.org/xml/features/dom/defer-node-expansion", Boolean.FALSE); } catch (IllegalArgumentException e) { // do nothing } DocumentBuilder parser = documentBuilderFactory.newDocumentBuilder(); parser.setEntityResolver(createEntityResolver()); parser.setErrorHandler(errorHandler); return parser; }
saxParser = new DefaultJAXPConfiguration().createSAXParser(this);
/** * Builds a document using default JAXP. * @deprecated since 2.2 * @see #getDocument(InputSource, ErrorHandler, Map) * @param inputSource the contents to parse. * @param errorHandler the handled used by the parser. * @return a document. */ @Deprecated protected static Document getDocument(InputSource inputSource, ErrorHandler errorHandler) throws IOException { try { DocumentBuilder documentBuilder = new DefaultJAXPConfiguration().createDocumentBuilder(errorHandler); Document document = documentBuilder.parse(inputSource); return document; } catch (ParserConfigurationException exception) { throw new IOWrappedException(exception); } catch (SAXException exception) { throw new IOWrappedException(exception); } }
/** * Creates JAXPPool using DefaultJAXPConfiguration implementation */ public DefaultJAXPPool() { this(new DefaultJAXPConfiguration()); }
/** * Creates a DocumentBuilder and sets some default options. * If features or properties are available, these features and properties are set on the documentBuilder. */ public DocumentBuilder createDocumentBuilder(ErrorHandler errorHandler) throws ParserConfigurationException { DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setNamespaceAware(true); documentBuilderFactory.setValidating(false); try { documentBuilderFactory.setAttribute("http://apache.org/xml/features/dom/defer-node-expansion", Boolean.FALSE); } catch (IllegalArgumentException e) { // do nothing } DocumentBuilder parser = documentBuilderFactory.newDocumentBuilder(); parser.setEntityResolver(createEntityResolver()); parser.setErrorHandler(errorHandler); return parser; }
protected String serialize(Element element) { if (transformer == null) { try { transformer = new DefaultJAXPConfiguration().createTransformer("UTF-8"); } catch (TransformerException exeption) { throw new RuntimeException(exeption); } } StringWriter writer = new StringWriter(); try { transformer.transform(new DOMSource(element), new StreamResult(writer)); } catch (TransformerException exception) { throw new RuntimeException(exception); } return writer.toString(); }
saxParser = new DefaultJAXPConfiguration().createSAXParser(this);
/** * @deprecated since 2.2 * @see #doSerialize(OutputStream, Document, Map) * @param outputStream * @param document * @param encoding * @throws IOException */ @Deprecated protected static void doSerialize(OutputStream outputStream, Document document, String encoding) throws IOException { try { Transformer transformer = new DefaultJAXPConfiguration().createTransformer(encoding); // Be sure to use actual encoding of the transformer which might be non-null even if encoding started as null. encoding = transformer.getOutputProperty(OutputKeys.ENCODING); Writer writer = encoding == null ? new OutputStreamWriter(outputStream) : new OutputStreamWriter(outputStream, encoding); transformer.transform(new DOMSource(document), new StreamResult(writer)); } catch (TransformerException exception) { XSDPlugin.INSTANCE.log(exception); } }
/** * @deprecated since 2.2 * @see #doSerialize(OutputStream, Document, Map) * @param outputStream * @param document * @param encoding * @throws IOException */ @Deprecated protected static void doSerialize(OutputStream outputStream, Document document, String encoding) throws IOException { try { Transformer transformer = new DefaultJAXPConfiguration().createTransformer(encoding); // Be sure to use actual encoding of the transformer which might be non-null even if encoding started as null. encoding = transformer.getOutputProperty(OutputKeys.ENCODING); Writer writer = encoding == null ? new OutputStreamWriter(outputStream) : new OutputStreamWriter(outputStream, encoding); transformer.transform(new DOMSource(document), new StreamResult(writer)); } catch (TransformerException exception) { XSDPlugin.INSTANCE.log(exception); } }
protected static void doSerialize(OutputStream outputStream, Element element, String encoding) throws IOException { try { Transformer transformer = new DefaultJAXPConfiguration().createTransformer(encoding); // Be sure to use actual encoding of the transformer which might be non-null even if encoding started as null. encoding = transformer.getOutputProperty(OutputKeys.ENCODING); Writer writer = encoding == null ? new OutputStreamWriter(outputStream) : new OutputStreamWriter(outputStream, encoding); transformer.transform(new DOMSource(element), new StreamResult(writer)); } catch (TransformerException exception) { XSDPlugin.INSTANCE.log(exception); } }
protected static void doSerialize(OutputStream outputStream, Element element, String encoding) throws IOException { try { Transformer transformer = new DefaultJAXPConfiguration().createTransformer(encoding); // Be sure to use actual encoding of the transformer which might be non-null even if encoding started as null. encoding = transformer.getOutputProperty(OutputKeys.ENCODING); Writer writer = encoding == null ? new OutputStreamWriter(outputStream) : new OutputStreamWriter(outputStream, encoding); transformer.transform(new DOMSource(element), new StreamResult(writer)); } catch (TransformerException exception) { XSDPlugin.INSTANCE.log(exception); } }
new DefaultJAXPConfiguration().createTransformer(encoding).transform(new DOMSource(document), new StreamResult(writer));
new DefaultJAXPConfiguration().createTransformer(encoding).transform(new DOMSource(document), new StreamResult(writer));