1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 /* $Id: XMLHandler.java 426576 2006-07-28 15:44:37Z jeremias $ */ 19 20 package org.apache.fop.render; 21 22 import org.w3c.dom.Document; 23 24 /** 25 * This interface is implemented by classes that can handle a certain type 26 * of foreign objects. 27 */ 28 public interface XMLHandler { 29 30 /** Used to indicate that all MIME types or XML namespaces are handled. */ 31 String HANDLE_ALL = "*"; 32 33 /** 34 * <p>Handle an external xml document inside a Foreign Object Area. 35 * </p> 36 * <p>This may throw an exception if for some reason it cannot be handled. The 37 * caller is expected to deal with this exception. 38 * </p> 39 * <p>The implementation may convert the XML document internally to another 40 * XML dialect (SVG, for example) and call renderXML() on the AbstractRenderer 41 * again (which can be retrieved through the RendererContext).</p> 42 * 43 * @param context The RendererContext (contains the user agent) 44 * @param doc A DOM containing the foreign object to be 45 * processed 46 * @param ns The Namespace of the foreign object 47 * @exception Exception If an error occurs during processing. 48 */ 49 void handleXML(RendererContext context, 50 Document doc, String ns) throws Exception; 51 52 /** 53 * Checks if this XMLHandler supports handling an XML namespace for a particular renderer. 54 * @param renderer the renderer for which to check. 55 * @return true if this XML handler supports a particular renderer 56 */ 57 boolean supportsRenderer(Renderer renderer); 58 59 /** 60 * @return the XML namespace for the XML dialect this XMLHandler supports, 61 * null if all XML content is handled by this instance. 62 */ 63 String getNamespace(); 64 } 65 66