001: /*
002: * $Id: TransformerFactory.java,v 1.5 2001/11/02 22:07:45 db Exp $
003: * Copyright (C) 2001 Andrew Selkirk
004: * Copyright (C) 2001 David Brownell
005: *
006: * This file is part of GNU JAXP, a library.
007: *
008: * GNU JAXP is free software; you can redistribute it and/or modify
009: * it under the terms of the GNU General Public License as published by
010: * the Free Software Foundation; either version 2 of the License, or
011: * (at your option) any later version.
012: *
013: * GNU JAXP is distributed in the hope that it will be useful,
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
016: * GNU General Public License for more details.
017: *
018: * You should have received a copy of the GNU General Public License
019: * along with this program; if not, write to the Free Software
020: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
021: *
022: * As a special exception, if you link this library with other files to
023: * produce an executable, this library does not by itself cause the
024: * resulting executable to be covered by the GNU General Public License.
025: * This exception does not however invalidate any other reasons why the
026: * executable file might be covered by the GNU General Public License.
027: */
028: package javax.xml.transform;
029:
030: // Imports
031: import java.io.IOException;
032: import java.io.InputStream;
033: import java.io.FileInputStream;
034: import java.io.File;
035: import java.io.BufferedReader;
036: import java.io.InputStreamReader;
037: import java.util.Properties;
038:
039: /**
040: * Abstract class extended by implementations.
041: *
042: * @author Andrew Selkirk, David Brownell
043: * @version 1.0
044: */
045: public abstract class TransformerFactory {
046:
047: /** Constructor, for use by subclasses. */
048: protected TransformerFactory() {
049: }
050:
051: //-------------------------------------------------------------
052: // Methods ----------------------------------------------------
053: //-------------------------------------------------------------
054:
055: /**
056: * Returns an object encapsulating the <?xml-stylesheet ?>
057: * processing instruction from the document that matches the
058: * specified criteria.
059: */
060: public abstract Source getAssociatedStylesheet(Source source,
061: String media, String title, String charset)
062: throws TransformerConfigurationException;
063:
064: /** Returns an implementation-specific attribute */
065: public abstract Object getAttribute(String name)
066: throws IllegalArgumentException;
067:
068: /** Returns the ErrorListener used when parsing stylesheets. */
069: public abstract ErrorListener getErrorListener();
070:
071: /**
072: * Exposes capabilities of the underlying implementation.
073: * Examples include SAXSource.FEATURE and DOMResult.FEATURE.
074: */
075: public abstract boolean getFeature(String name);
076:
077: /** Returns the URIResolver used when parsing stylesheets. */
078: public abstract URIResolver getURIResolver();
079:
080: /**
081: * Returns a new TransformerFactory. The name of this class
082: * is found by checking, in order:
083: * the <em>javax.xml.transform.TransformerFactory</em>
084: * system property,
085: * <em>$JAVA_HOME/lib/jaxp.properties</em> for the key with
086: * that same name,
087: * JAR files in the class path with a <em>META-INF/services</em>
088: * file with that same name,
089: * else the compiled-in platform default.
090: */
091: public static TransformerFactory newInstance()
092: throws TransformerFactoryConfigurationError {
093: try {
094: return (TransformerFactory) ClassStuff.createFactory(
095: "javax.xml.transform.TransformerFactory",
096: "com.icl.saxon.TransformerFactoryImpl"
097: // "gnu.xml.util.SAXNullTransformerFactory"
098: // "org.apache.xalan.processor.TransformerFactoryImpl"
099: );
100: } catch (ClassCastException e) {
101: throw new TransformerFactoryConfigurationError(e);
102: }
103: }
104:
105: /**
106: * Returns a pre-compiled stylesheet.
107: * @param stylesheet XSLT stylesheet specifying transform
108: */
109: public abstract Templates newTemplates(Source stylesheet)
110: throws TransformerConfigurationException;
111:
112: /**
113: * Returns a transformer that performs the null transform.
114: */
115: public abstract Transformer newTransformer()
116: throws TransformerConfigurationException;
117:
118: /**
119: * Returns a transformer making a specified transform.
120: * @param stylesheet XSLT stylesheet specifying transform
121: */
122: public abstract Transformer newTransformer(Source stylesheet)
123: throws TransformerConfigurationException;
124:
125: /** Assigns an implementation-specific attribute */
126: public abstract void setAttribute(String name, Object value)
127: throws IllegalArgumentException;
128:
129: /** Assigns the ErrorListener used when parsing stylesheets. */
130: public abstract void setErrorListener(ErrorListener listener)
131: throws IllegalArgumentException;
132:
133: /** Assigns the URIResolver used when parsing stylesheets. */
134: public abstract void setURIResolver(URIResolver resolver);
135: }
|