1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 /* 19 * $Id: DOMSerializer.java 475350 2006-11-15 18:39:15Z minchau $ 20 */ 21 package org.apache.xml.serializer; 22 23 import java.io.IOException; 24 25 import org.w3c.dom.Node; 26 27 /** 28 * Interface for a DOM serializer implementation. 29 * <p> 30 * The DOMSerializer is a facet of a serializer and is obtained from the 31 * asDOMSerializer() method of the ({@link Serializer}) interface. 32 * A serializer may or may not support a DOM serializer, if it does not then the 33 * return value from asDOMSerializer() is null. 34 * <p> 35 * Example: 36 * <pre> 37 * // Create a document to be serialized 38 * org.w3c.dom.Document doc = ...; 39 * 40 * // Create a Serializer that will be used 41 * // to serialize the document 42 * org.apache.xml.serializer.Serializer ser = ...; 43 * 44 * // Set the Writer to write output to, and 45 * // serialize the DOM using that Serializer 46 * java.io.StringWriter sw = new java.io.StringWriter(); 47 * ser.setWriter(sw); 48 * DOMSerialzier dser = ser.asDOMSerializer(); 49 * dser.serialize(doc); 50 * 51 * // Write out the serialized XML in the String. 52 * System.out.println(sw.toString()); 53 * </pre> 54 * 55 * @see OutputPropertiesFactory 56 * @see SerializerFactory 57 * @see Serializer 58 * 59 * @xsl.usage general 60 * 61 */ 62 public interface DOMSerializer 63 { 64 /** 65 * Serializes the DOM node. Throws an exception only if an I/O 66 * exception occured while serializing. 67 * 68 * This interface is a public API. 69 * 70 * @param node the DOM node to serialize 71 * @throws IOException if an I/O exception occured while serializing 72 */ serialize(Node node)73 public void serialize(Node node) throws IOException; 74 } 75