2
* Copyright 2003-2004 The Apache Software Foundation.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
// $Id: SAXTransformerFactory.java 226183 2005-04-08 10:39:14Z neeraj $
19
package javax.xml.transform.sax;
21
import javax.xml.transform.*;
23
import org.xml.sax.XMLFilter;
26
* This class extends TransformerFactory to provide SAX-specific
27
* factory methods. It provides two types of ContentHandlers,
28
* one for creating Transformers, the other for creating Templates
31
* <p>If an application wants to set the ErrorHandler or EntityResolver
32
* for an XMLReader used during a transformation, it should use a URIResolver
33
* to return the SAXSource which provides (with getXMLReader) a reference to
36
public abstract class SAXTransformerFactory extends TransformerFactory {
38
/** If {@link javax.xml.transform.TransformerFactory#getFeature}
39
* returns true when passed this value as an argument,
40
* the TransformerFactory returned from
41
* {@link javax.xml.transform.TransformerFactory#newInstance} may
42
* be safely cast to a SAXTransformerFactory.
44
public static final String FEATURE =
45
"http://javax.xml.transform.sax.SAXTransformerFactory/feature";
47
/** If {@link javax.xml.transform.TransformerFactory#getFeature}
48
* returns true when passed this value as an argument,
49
* the {@link #newXMLFilter(Source src)}
50
* and {@link #newXMLFilter(Templates templates)} methods are supported.
52
public static final String FEATURE_XMLFILTER =
53
"http://javax.xml.transform.sax.SAXTransformerFactory/feature/xmlfilter";
56
* The default constructor is protected on purpose.
58
protected SAXTransformerFactory() {}
61
* Get a TransformerHandler object that can process SAX
62
* ContentHandler events into a Result, based on the transformation
63
* instructions specified by the argument.
65
* @param src The Source of the transformation instructions.
67
* @return TransformerHandler ready to transform SAX events.
69
* @throws TransformerConfigurationException If for some reason the
70
* TransformerHandler can not be created.
72
public abstract TransformerHandler newTransformerHandler(Source src)
73
throws TransformerConfigurationException;
76
* Get a TransformerHandler object that can process SAX
77
* ContentHandler events into a Result, based on the Templates argument.
79
* @param templates The compiled transformation instructions.
81
* @return TransformerHandler ready to transform SAX events.
83
* @throws TransformerConfigurationException If for some reason the
84
* TransformerHandler can not be created.
86
public abstract TransformerHandler newTransformerHandler(
87
Templates templates) throws TransformerConfigurationException;
90
* Get a TransformerHandler object that can process SAX
91
* ContentHandler events into a Result. The transformation
92
* is defined as an identity (or copy) transformation, for example
93
* to copy a series of SAX parse events into a DOM tree.
95
* @return A non-null reference to a TransformerHandler, that may
96
* be used as a ContentHandler for SAX parse events.
98
* @throws TransformerConfigurationException If for some reason the
99
* TransformerHandler cannot be created.
101
public abstract TransformerHandler newTransformerHandler()
102
throws TransformerConfigurationException;
105
* Get a TemplatesHandler object that can process SAX
106
* ContentHandler events into a Templates object.
108
* @return A non-null reference to a TransformerHandler, that may
109
* be used as a ContentHandler for SAX parse events.
111
* @throws TransformerConfigurationException If for some reason the
112
* TemplatesHandler cannot be created.
114
public abstract TemplatesHandler newTemplatesHandler()
115
throws TransformerConfigurationException;
118
* Create an XMLFilter that uses the given Source as the
119
* transformation instructions.
121
* @param src The Source of the transformation instructions.
123
* @return An XMLFilter object, or null if this feature is not supported.
125
* @throws TransformerConfigurationException If for some reason the
126
* TemplatesHandler cannot be created.
128
public abstract XMLFilter newXMLFilter(Source src)
129
throws TransformerConfigurationException;
132
* Create an XMLFilter, based on the Templates argument..
134
* @param templates The compiled transformation instructions.
136
* @return An XMLFilter object, or null if this feature is not supported.
138
* @throws TransformerConfigurationException If for some reason the
139
* TemplatesHandler cannot be created.
141
public abstract XMLFilter newXMLFilter(Templates templates)
142
throws TransformerConfigurationException;