| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.stax; |
| 9 |
|
| 10 |
import net.sf.saxon.event.Receiver; |
| 11 |
import net.sf.saxon.lib.StAXResultHandler; |
| 12 |
|
| 13 |
import javax.xml.transform.Result; |
| 14 |
import javax.xml.transform.stax.StAXResult; |
| 15 |
import java.util.Properties; |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
public class StAXResultHandlerImpl implements StAXResultHandler { |
| 22 |
|
| 23 |
public Receiver getReceiver(Result result, Properties properties) { |
| 24 |
if (((StAXResult) result).getXMLStreamWriter() != null) { |
| 25 |
return new ReceiverToXMLStreamWriter(((StAXResult) result).getXMLStreamWriter()); |
| 26 |
} else if (((StAXResult) result).getXMLEventWriter() != null) { |
| 27 |
throw new UnsupportedOperationException("XMLEventWriter is currently not supported as a Saxon output destination"); |
| 28 |
} else { |
| 29 |
throw new IllegalStateException("StAXResult contains neither an XMLStreamWriter nor XMLEventWriter"); |
| 30 |
} |
| 31 |
} |
| 32 |
} |
| 33 |
|