14c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson/* 24c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Licensed to the Apache Software Foundation (ASF) under one 34c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * or more contributor license agreements. See the NOTICE file 44c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * distributed with this work for additional information 54c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * regarding copyright ownership. The ASF licenses this file 64c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * to you under the Apache License, Version 2.0 (the "License"); 74c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * you may not use this file except in compliance with the License. 84c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * You may obtain a copy of the License at 94c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * http://www.apache.org/licenses/LICENSE-2.0 114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Unless required by applicable law or agreed to in writing, software 134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS, 144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * See the License for the specific language governing permissions and 164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * limitations under the License. 174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson/* 194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * $Id: Serializer.java 471981 2006-11-07 04:28:00Z minchau $ 204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonpackage org.apache.xml.serializer; 224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport java.io.IOException; 234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport java.io.OutputStream; 244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport java.io.Writer; 254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport java.util.Properties; 264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonimport org.xml.sax.ContentHandler; 284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson/** 304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * The Serializer interface is implemented by a serializer to enable users to: 314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <ul> 324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <li>get and set streams or writers 334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <li>configure the serializer with key/value properties 344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <li>get an org.xml.sax.ContentHandler or a DOMSerializer to provide input to 354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * </ul> 364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> 384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Here is an example using the asContentHandler() method: 394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <pre> 404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * java.util.Properties props = 414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * OutputPropertiesFactory.getDefaultMethodProperties(Method.TEXT); 424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Serializer ser = SerializerFactory.getSerializer(props); 434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * java.io.PrintStream ostream = System.out; 444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * ser.setOutputStream(ostream); 454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * // Provide the SAX input events 474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * ContentHandler handler = ser.asContentHandler(); 484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * handler.startDocument(); 494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * char[] chars = { 'a', 'b', 'c' }; 504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * handler.characters(chars, 0, chars.length); 514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * handler.endDocument(); 524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * ser.reset(); // get ready to use the serializer for another document 544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * // of the same output method (TEXT). 554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * </pre> 564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> 584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * As an alternate to supplying a series of SAX events as input through the 594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * ContentHandler interface, the input to serialize may be given as a DOM. 604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> 614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * For example: 624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <pre> 634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * org.w3c.dom.Document inputDoc; 644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * org.apache.xml.serializer.Serializer ser; 654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * java.io.Writer owriter; 664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * java.util.Properties props = 684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * OutputPropertiesFactory.getDefaultMethodProperties(Method.XML); 694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Serializer ser = SerializerFactory.getSerializer(props); 704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * owriter = ...; // create a writer to serialize the document to 714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * ser.setWriter( owriter ); 724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * inputDoc = ...; // create the DOM document to be serialized 744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * DOMSerializer dser = ser.asDOMSerializer(); // a DOM will be serialized 754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * dser.serialize(inputDoc); // serialize the DOM, sending output to owriter 764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * ser.reset(); // get ready to use the serializer for another document 784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * // of the same output method. 794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * </pre> 804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * This interface is a public API. 824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @see Method 844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @see OutputPropertiesFactory 854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @see SerializerFactory 864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @see DOMSerializer 874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @see ContentHandler 884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @xsl.usage general 904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilsonpublic interface Serializer { 924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Specifies an output stream to which the document should be 954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * serialized. This method should not be called while the 964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * serializer is in the process of serializing a document. 974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> 984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * The encoding specified in the output {@link Properties} is used, or 994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * if no encoding was specified, the default for the selected 1004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * output method. 1014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> 1024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Only one of setWriter() or setOutputStream() should be called. 1034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 1044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param output The output stream 1054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 1064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void setOutputStream(OutputStream output); 1074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 1084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 1094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Get the output stream where the events will be serialized to. 1104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 1114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return reference to the result stream, or null if only a writer was 1124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * set. 1134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 1144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public OutputStream getOutputStream(); 1154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 1164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 1174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Specifies a writer to which the document should be serialized. 1184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * This method should not be called while the serializer is in 1194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * the process of serializing a document. 1204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> 1214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * The encoding specified for the output {@link Properties} must be 1224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * identical to the output format used with the writer. 1234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 1244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> 1254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Only one of setWriter() or setOutputStream() should be called. 1264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 1274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param writer The output writer stream 1284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 1294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void setWriter(Writer writer); 1304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 1314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 1324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Get the character stream where the events will be serialized to. 1334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 1344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return Reference to the result Writer, or null. 1354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 1364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public Writer getWriter(); 1374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 1384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 1394c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Specifies an output format for this serializer. It the 1404c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * serializer has already been associated with an output format, 1414c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * it will switch to the new format. This method should not be 1424c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * called while the serializer is in the process of serializing 1434c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * a document. 1444c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> 1454c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * The standard property keys supported are: "method", "version", "encoding", 1464c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * "omit-xml-declaration", "standalone", doctype-public", 1474c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * "doctype-system", "cdata-section-elements", "indent", "media-type". 1484c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * These property keys and their values are described in the XSLT recommendation, 1494c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * see {@link <a href="http://www.w3.org/TR/1999/REC-xslt-19991116"> XSLT 1.0 recommendation</a>} 1504c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> 1514c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * The non-standard property keys supported are defined in {@link OutputPropertiesFactory}. 1524c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 1534c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> 1544c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * This method can be called multiple times before a document is serialized. Each 1554c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * time it is called more, or over-riding property values, can be specified. One 1564c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * property value that can not be changed is that of the "method" property key. 1574c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> 1584c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * The value of the "cdata-section-elements" property key is a whitespace 1594c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * separated list of elements. If the element is in a namespace then 1604c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * value is passed in this format: {uri}localName 1614c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> 1624c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * If the "cdata-section-elements" key is specified on multiple calls 1634c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * to this method the set of elements specified in the value 1644c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * is not replaced from one call to the 1654c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * next, but it is cumulative across the calls. 1664c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 1674c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @param format The output format to use, as a set of key/value pairs. 1684c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 1694c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public void setOutputFormat(Properties format); 1704c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 1714c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 1724c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Returns the output format properties for this serializer. 1734c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 1744c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return The output format key/value pairs in use. 1754c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 1764c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public Properties getOutputFormat(); 1774c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 1784c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 1794c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Return a {@link ContentHandler} interface to provide SAX input to. 1804c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Through the returned object the document to be serailized, 1814c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * as a series of SAX events, can be provided to the serialzier. 1824c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * If the serializer does not support the {@link ContentHandler} 1834c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * interface, it will return null. 1844c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> 1854c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * In principle only one of asDOMSerializer() or asContentHander() 1864c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * should be called. 1874c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 1884c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return A {@link ContentHandler} interface into this serializer, 1894c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * or null if the serializer is not SAX 2 capable 1904c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @throws IOException An I/O exception occured 1914c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 1924c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public ContentHandler asContentHandler() throws IOException; 1934c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 1944c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 1954c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Return a {@link DOMSerializer} interface into this serializer. 1964c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Through the returned object the document to be serialized, 1974c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * a DOM, can be provided to the serializer. 1984c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * If the serializer does not support the {@link DOMSerializer} 1994c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * interface, it should return null. 2004c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> 2014c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * In principle only one of asDOMSerializer() or asContentHander() 2024c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * should be called. 2034c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 2044c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return A {@link DOMSerializer} interface into this serializer, 2054c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * or null if the serializer is not DOM capable 2064c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @throws IOException An I/O exception occured 2074c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 2084c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public DOMSerializer asDOMSerializer() throws IOException; 2094c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 2104c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 2114c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * This method resets the serializer. 2124c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * If this method returns true, the 2134c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * serializer may be used for subsequent serialization of new 2144c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * documents. It is possible to change the output format and 2154c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * output stream prior to serializing, or to reuse the existing 2164c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * output format and output stream or writer. 2174c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 2184c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return True if serializer has been reset and can be reused 2194c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 2204c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public boolean reset(); 2214c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 2224c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson /** 2234c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Return an Object into this serializer to be cast to a DOM3Serializer. 2244c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * Through the returned object the document to be serialized, 2254c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * a DOM (Level 3), can be provided to the serializer. 2264c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * If the serializer does not support casting to a {@link DOM3Serializer} 2274c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * interface, it should return null. 2284c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * <p> 2294c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * In principle only one of asDOM3Serializer() or asContentHander() 2304c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * should be called. 2314c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * 2324c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @return An Object to be cast to a DOM3Serializer interface into this serializer, 2334c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * or null if the serializer is not DOM capable 2344c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson * @throws IOException An I/O exception occured 2354c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson */ 2364c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson public Object asDOM3Serializer() throws IOException; 2374c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson} 2384c7a0d97cf2b27790e6236965a1d798d710d7ec7Jesse Wilson 239