Re: How to set Woodstox output properties ?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to set Woodstox output properties ?

forums
I have found the answer myself. First you need create your own version of an
XMLOutputFactory [1]. Here's what I do: package package org.fantastic.ws;
public class MyXMLOutputFactory extends WstxOutputFactory { public
AvenueXMLOutputFactory() { super();
SetProperty(WstxOutputProperties.P_OUTPUT_INVALID_CHAR_HANDLER, new
InvalidCharHandler.ReplacingHandler(' ')); } } Then comes the next problem.
Had to look into JDK code for this one: What determines which
XMLOutputFactory that JAX-WS uses? Well, it turns out this can be overridden
by the use of a System Property, namely
"System.setProperty("javax.xml.stream.XMLOutputFactory". As you may have
quessed there's an equivalent one for XMLInputFactory but in this posting
we're only concerned with the XML output part. I like best to set the System
Property programmatically
System.setProperty("javax.xml.stream.XMLOutputFactory",
"org.fantastic.ws.MyXMLOutputFactory"); but you can of course also do it from
command line. That is all. Works as expected for my part. You can use the
same method to change other configuration properties for Woodstox and thereby
change how JAX-WS's default XML encoder/decoder works.

[1]  
http://docs.oracle.com/javase/7/docs/api/javax/xml/stream/XMLOutputFactory.html

--

[Message sent by forum member 'phans33']

View Post: http://forums.java.net/node/896699


Loading...