1 /*
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
231 "SAAJ0126.impl.cannot.locate.ns",
232 new String[] { prefix });
233 throw new SOAPExceptionImpl(
234 "Unable to locate namespace for prefix " + prefix);
235 }
236 return NameImpl.create(localName, prefix, namespace);
237 }
238
239 public Name createName(String localName) throws SOAPException {
240 return NameImpl.createFromUnqualifiedName(localName);
241 }
242
243 public void setOmitXmlDecl(String value) {
244 this.omitXmlDecl = value;
245 }
246
247 public void setXmlDecl(String value) {
248 this.xmlDecl = value;
249 }
250
251 private String getOmitXmlDecl() {
252 return this.omitXmlDecl;
253 }
254
255 public void setCharsetEncoding(String value) {
256 charset = value;
257 }
258
259 public void output(OutputStream out) throws IOException {
260 try {
261 // materializeBody();
262 Transformer transformer =
263 EfficientStreamingTransformer.newTransformer();
264
265 transformer.setOutputProperty(
266 OutputKeys.OMIT_XML_DECLARATION, "yes");
267 /*omitXmlDecl);*/
268 // no equivalent for "setExpandEmptyElements"
269 transformer.setOutputProperty(
270 OutputKeys.ENCODING,
271 charset);
272
273 if (omitXmlDecl.equals("no") && xmlDecl == null) {
274 xmlDecl = "<?xml version=\"" + getOwnerDocument().getXmlVersion() + "\" encoding=\"" +
292
293 //StreamResult result = new StreamResult(out);
294 transformer.transform(getContent(), result);
295 } catch (Exception ex) {
296 throw new IOException(ex.getMessage());
297 }
298 }
299
300 /**
301 * Serialize to FI if boolean parameter set.
302 */
303 public void output(OutputStream out, boolean isFastInfoset)
304 throws IOException
305 {
306 if (!isFastInfoset) {
307 output(out);
308 }
309 else {
310 try {
311 // Run transform and generate FI output from content
312 Source source = getContent();
313 Transformer transformer = EfficientStreamingTransformer.newTransformer();
314 transformer.transform(getContent(),
315 FastInfosetReflection.FastInfosetResult_new(out));
316 }
317 catch (Exception ex) {
318 throw new IOException(ex.getMessage());
319 }
320 }
321 }
322
323 // public void prettyPrint(OutputStream out) throws IOException {
324 // if (getDocument() == null)
325 // initDocument();
326 //
327 // OutputFormat format = OutputFormat.createPrettyPrint();
328 //
329 // format.setIndentSize(2);
330 // format.setNewlines(true);
331 // format.setTrimText(true);
332 // format.setPadText(true);
|
1 /*
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
231 "SAAJ0126.impl.cannot.locate.ns",
232 new String[] { prefix });
233 throw new SOAPExceptionImpl(
234 "Unable to locate namespace for prefix " + prefix);
235 }
236 return NameImpl.create(localName, prefix, namespace);
237 }
238
239 public Name createName(String localName) throws SOAPException {
240 return NameImpl.createFromUnqualifiedName(localName);
241 }
242
243 public void setOmitXmlDecl(String value) {
244 this.omitXmlDecl = value;
245 }
246
247 public void setXmlDecl(String value) {
248 this.xmlDecl = value;
249 }
250
251 public void setCharsetEncoding(String value) {
252 charset = value;
253 }
254
255 public void output(OutputStream out) throws IOException {
256 try {
257 // materializeBody();
258 Transformer transformer =
259 EfficientStreamingTransformer.newTransformer();
260
261 transformer.setOutputProperty(
262 OutputKeys.OMIT_XML_DECLARATION, "yes");
263 /*omitXmlDecl);*/
264 // no equivalent for "setExpandEmptyElements"
265 transformer.setOutputProperty(
266 OutputKeys.ENCODING,
267 charset);
268
269 if (omitXmlDecl.equals("no") && xmlDecl == null) {
270 xmlDecl = "<?xml version=\"" + getOwnerDocument().getXmlVersion() + "\" encoding=\"" +
288
289 //StreamResult result = new StreamResult(out);
290 transformer.transform(getContent(), result);
291 } catch (Exception ex) {
292 throw new IOException(ex.getMessage());
293 }
294 }
295
296 /**
297 * Serialize to FI if boolean parameter set.
298 */
299 public void output(OutputStream out, boolean isFastInfoset)
300 throws IOException
301 {
302 if (!isFastInfoset) {
303 output(out);
304 }
305 else {
306 try {
307 // Run transform and generate FI output from content
308 Transformer transformer = EfficientStreamingTransformer.newTransformer();
309 transformer.transform(getContent(),
310 FastInfosetReflection.FastInfosetResult_new(out));
311 }
312 catch (Exception ex) {
313 throw new IOException(ex.getMessage());
314 }
315 }
316 }
317
318 // public void prettyPrint(OutputStream out) throws IOException {
319 // if (getDocument() == null)
320 // initDocument();
321 //
322 // OutputFormat format = OutputFormat.createPrettyPrint();
323 //
324 // format.setIndentSize(2);
325 // format.setNewlines(true);
326 // format.setTrimText(true);
327 // format.setPadText(true);
|