001    /*
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements. See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership. The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the  "License");
007     * you may not use this file except in compliance with the License.
008     * You may obtain a copy of the License at
009     *
010     *     http://www.apache.org/licenses/LICENSE-2.0
011     *
012     * Unless required by applicable law or agreed to in writing, software
013     * distributed under the License is distributed on an "AS IS" BASIS,
014     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015     * See the License for the specific language governing permissions and
016     * limitations under the License.
017     */
018    /*
019     * $Id: DOMSerializer.java 475350 2006-11-15 18:39:15Z minchau $
020     */
021    package org.apache.xml.serializer;
022    
023    import java.io.IOException;
024    
025    import org.w3c.dom.Node;
026    
027    /**
028     * Interface for a DOM serializer implementation.
029     * <p>
030     * The DOMSerializer is a facet of a serializer and is obtained from the
031     * asDOMSerializer() method of the ({@link Serializer}) interface. 
032     * A serializer may or may not support a DOM serializer, if it does not then the 
033     * return value from asDOMSerializer() is null.
034     * <p>
035     * Example:
036     * <pre>
037     * // Create a document to be serialized
038     * org.w3c.dom.Document doc = ...;
039     * 
040     * // Create a Serializer that will be used
041     * // to serialize the document  
042     * org.apache.xml.serializer.Serializer ser = ...;
043     *
044     * // Set the Writer to write output to, and 
045     * // serialize the DOM using that Serializer
046     * java.io.StringWriter sw = new java.io.StringWriter();
047     * ser.setWriter(sw);
048     * DOMSerialzier dser = ser.asDOMSerializer();
049     * dser.serialize(doc);
050     * 
051     * // Write out the serialized XML in the String.
052     * System.out.println(sw.toString());
053     * </pre>
054     * 
055     * @see OutputPropertiesFactory
056     * @see SerializerFactory
057     * @see Serializer
058     * 
059     * @xsl.usage general
060     *
061     */
062    public interface DOMSerializer
063    {
064        /**
065         * Serializes the DOM node. Throws an exception only if an I/O
066         * exception occured while serializing.
067         * 
068         * This interface is a public API.
069         *
070         * @param node the DOM node to serialize
071         * @throws IOException if an I/O exception occured while serializing
072         */
073        public void serialize(Node node) throws IOException;
074    }