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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 * $Id: TransformerFactoryImpl.java 468640 2006-10-28 06:53:53Z minchau $
21 package org.apache.xalan.processor;
23 import java.io.BufferedInputStream;
24 import java.io.IOException;
25 import java.io.InputStream;
26 import java.util.Enumeration;
27 import java.util.Properties;
29 import javax.xml.XMLConstants;
30 import javax.xml.transform.ErrorListener;
31 import javax.xml.transform.Source;
32 import javax.xml.transform.Templates;
33 import javax.xml.transform.Transformer;
34 import javax.xml.transform.TransformerConfigurationException;
35 import javax.xml.transform.TransformerException;
36 import javax.xml.transform.URIResolver;
37 import javax.xml.transform.dom.DOMResult;
38 import javax.xml.transform.dom.DOMSource;
39 import javax.xml.transform.sax.SAXResult;
40 import javax.xml.transform.sax.SAXSource;
41 import javax.xml.transform.sax.SAXTransformerFactory;
42 import javax.xml.transform.sax.TemplatesHandler;
43 import javax.xml.transform.sax.TransformerHandler;
44 import javax.xml.transform.stream.StreamResult;
45 import javax.xml.transform.stream.StreamSource;
47 import org.apache.xalan.res.XSLMessages;
48 import org.apache.xalan.res.XSLTErrorResources;
49 import org.apache.xalan.transformer.TrAXFilter;
50 import org.apache.xalan.transformer.TransformerIdentityImpl;
51 import org.apache.xalan.transformer.TransformerImpl;
52 import org.apache.xalan.transformer.XalanProperties;
54 import org.apache.xml.dtm.ref.sax2dtm.SAX2DTM;
55 import org.apache.xml.utils.DefaultErrorHandler;
56 import org.apache.xml.utils.SystemIDResolver;
57 import org.apache.xml.utils.TreeWalker;
58 import org.apache.xml.utils.StylesheetPIHandler;
59 import org.apache.xml.utils.StopParseException;
61 import org.w3c.dom.Node;
63 import org.xml.sax.InputSource;
64 import org.xml.sax.XMLFilter;
65 import org.xml.sax.XMLReader;
66 import org.xml.sax.helpers.XMLReaderFactory;
69 * The TransformerFactoryImpl, which implements the TRaX TransformerFactory
70 * interface, processes XSLT stylesheets into a Templates object
73 public class TransformerFactoryImpl extends SAXTransformerFactory
76 * The path/filename of the property file: XSLTInfo.properties
77 * Maintenance note: see also
78 * <code>org.apache.xpath.functions.FuncSystemProperty.XSLT_PROPERTIES</code>
80 public static final String XSLT_PROPERTIES =
81 "org/apache/xalan/res/XSLTInfo.properties";
84 * <p>State of secure processing feature.</p>
86 private boolean m_isSecureProcessing = false;
89 * Constructor TransformerFactoryImpl
92 public TransformerFactoryImpl()
96 /** Static string to be used for incremental feature */
97 public static final String FEATURE_INCREMENTAL =
98 "http://xml.apache.org/xalan/features/incremental";
100 /** Static string to be used for optimize feature */
101 public static final String FEATURE_OPTIMIZE =
102 "http://xml.apache.org/xalan/features/optimize";
104 /** Static string to be used for source_location feature */
105 public static final String FEATURE_SOURCE_LOCATION =
106 XalanProperties.SOURCE_LOCATION;
108 public javax.xml.transform.Templates processFromNode(Node node)
109 throws TransformerConfigurationException
114 TemplatesHandler builder = newTemplatesHandler();
115 TreeWalker walker = new TreeWalker(builder,
116 new org.apache.xml.utils.DOM2Helper(),
117 builder.getSystemId());
119 walker.traverse(node);
121 return builder.getTemplates();
123 catch (org.xml.sax.SAXException se)
125 if (m_errorListener != null)
129 m_errorListener.fatalError(new TransformerException(se));
131 catch (TransformerConfigurationException ex)
135 catch (TransformerException ex)
137 throw new TransformerConfigurationException(ex);
145 // Should remove this later... but right now diagnostics from
146 // TransformerConfigurationException are not good.
147 // se.printStackTrace();
148 throw new TransformerConfigurationException(XSLMessages.createMessage(XSLTErrorResources.ER_PROCESSFROMNODE_FAILED, null), se);
149 //"processFromNode failed", se);
152 catch (TransformerConfigurationException tce)
154 // Assume it's already been reported to the error listener.
157 /* catch (TransformerException tce)
159 // Assume it's already been reported to the error listener.
160 throw new TransformerConfigurationException(tce.getMessage(), tce);
164 if (m_errorListener != null)
168 m_errorListener.fatalError(new TransformerException(e));
170 catch (TransformerConfigurationException ex)
174 catch (TransformerException ex)
176 throw new TransformerConfigurationException(ex);
183 // Should remove this later... but right now diagnostics from
184 // TransformerConfigurationException are not good.
185 // se.printStackTrace();
186 throw new TransformerConfigurationException(XSLMessages.createMessage(XSLTErrorResources.ER_PROCESSFROMNODE_FAILED, null), e); //"processFromNode failed",
193 * The systemID that was specified in
194 * processFromNode(Node node, String systemID).
196 private String m_DOMsystemID = null;
199 * The systemID that was specified in
200 * processFromNode(Node node, String systemID).
202 * @return The systemID, or null.
204 String getDOMsystemID()
206 return m_DOMsystemID;
210 * Process the stylesheet from a DOM tree, if the
211 * processor supports the "http://xml.org/trax/features/dom/input"
214 * @param node A DOM tree which must contain
215 * valid transform instructions that this processor understands.
216 * @param systemID The systemID from where xsl:includes and xsl:imports
217 * should be resolved from.
219 * @return A Templates object capable of being used for transformation purposes.
221 * @throws TransformerConfigurationException
223 javax.xml.transform.Templates processFromNode(Node node, String systemID)
224 throws TransformerConfigurationException
227 m_DOMsystemID = systemID;
229 return processFromNode(node);
233 * Get InputSource specification(s) that are associated with the
234 * given document specified in the source param,
235 * via the xml-stylesheet processing instruction
236 * (see http://www.w3.org/TR/xml-stylesheet/), and that matches
237 * the given criteria. Note that it is possible to return several stylesheets
238 * that match the criteria, in which case they are applied as if they were
239 * a list of imports or cascades.
241 * <p>Note that DOM2 has it's own mechanism for discovering stylesheets.
242 * Therefore, there isn't a DOM version of this method.</p>
245 * @param source The XML source that is to be searched.
246 * @param media The media attribute to be matched. May be null, in which
247 * case the prefered templates will be used (i.e. alternate = no).
248 * @param title The value of the title attribute to match. May be null.
249 * @param charset The value of the charset attribute to match. May be null.
251 * @return A Source object capable of being used to create a Templates object.
253 * @throws TransformerConfigurationException
255 public Source getAssociatedStylesheet(
256 Source source, String media, String title, String charset)
257 throws TransformerConfigurationException
261 InputSource isource = null;
263 XMLReader reader = null;
265 if (source instanceof DOMSource)
267 DOMSource dsource = (DOMSource) source;
269 node = dsource.getNode();
270 baseID = dsource.getSystemId();
274 isource = SAXSource.sourceToInputSource(source);
275 baseID = isource.getSystemId();
278 // What I try to do here is parse until the first startElement
279 // is found, then throw a special exception in order to terminate
281 StylesheetPIHandler handler = new StylesheetPIHandler(baseID, media,
284 // Use URIResolver. Patch from Dmitri Ilyin
285 if (m_uriResolver != null)
287 handler.setURIResolver(m_uriResolver);
294 TreeWalker walker = new TreeWalker(handler, new org.apache.xml.utils.DOM2Helper(), baseID);
296 walker.traverse(node);
301 // Use JAXP1.1 ( if possible )
304 javax.xml.parsers.SAXParserFactory factory =
305 javax.xml.parsers.SAXParserFactory.newInstance();
307 factory.setNamespaceAware(true);
309 if (m_isSecureProcessing)
313 factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
315 catch (org.xml.sax.SAXException e) {}
318 javax.xml.parsers.SAXParser jaxpParser = factory.newSAXParser();
320 reader = jaxpParser.getXMLReader();
322 catch (javax.xml.parsers.ParserConfigurationException ex)
324 throw new org.xml.sax.SAXException(ex);
326 catch (javax.xml.parsers.FactoryConfigurationError ex1)
328 throw new org.xml.sax.SAXException(ex1.toString());
330 catch (NoSuchMethodError ex2){}
331 catch (AbstractMethodError ame){}
335 reader = XMLReaderFactory.createXMLReader();
338 // Need to set options!
339 reader.setContentHandler(handler);
340 reader.parse(isource);
343 catch (StopParseException spe)
348 catch (org.xml.sax.SAXException se)
350 throw new TransformerConfigurationException(
351 "getAssociatedStylesheets failed", se);
353 catch (IOException ioe)
355 throw new TransformerConfigurationException(
356 "getAssociatedStylesheets failed", ioe);
359 return handler.getAssociatedStylesheet();
363 * Create a new Transformer object that performs a copy
364 * of the source to the result.
366 * @return A Transformer object that may be used to perform a transformation
367 * in a single thread, never null.
369 * @throws TransformerConfigurationException May throw this during
370 * the parse when it is constructing the
371 * Templates object and fails.
373 public TemplatesHandler newTemplatesHandler()
374 throws TransformerConfigurationException
376 return new StylesheetHandler(this);
380 * <p>Set a feature for this <code>TransformerFactory</code> and <code>Transformer</code>s
381 * or <code>Template</code>s created by this factory.</p>
384 * Feature names are fully qualified {@link java.net.URI}s.
385 * Implementations may define their own features.
386 * An {@link TransformerConfigurationException} is thrown if this <code>TransformerFactory</code> or the
387 * <code>Transformer</code>s or <code>Template</code>s it creates cannot support the feature.
388 * It is possible for an <code>TransformerFactory</code> to expose a feature value but be unable to change its state.
391 * <p>See {@link javax.xml.transform.TransformerFactory} for full documentation of specific features.</p>
393 * @param name Feature name.
394 * @param value Is feature state <code>true</code> or <code>false</code>.
396 * @throws TransformerConfigurationException if this <code>TransformerFactory</code>
397 * or the <code>Transformer</code>s or <code>Template</code>s it creates cannot support this feature.
398 * @throws NullPointerException If the <code>name</code> parameter is null.
400 public void setFeature(String name, boolean value)
401 throws TransformerConfigurationException {
403 // feature name cannot be null
405 throw new NullPointerException(
406 XSLMessages.createMessage(
407 XSLTErrorResources.ER_SET_FEATURE_NULL_NAME, null));
410 // secure processing?
411 if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
412 m_isSecureProcessing = value;
414 // This implementation does not support the setting of a feature other than
415 // the secure processing feature.
418 throw new TransformerConfigurationException(
419 XSLMessages.createMessage(
420 XSLTErrorResources.ER_UNSUPPORTED_FEATURE,
421 new Object[] {name}));
426 * Look up the value of a feature.
427 * <p>The feature name is any fully-qualified URI. It is
428 * possible for an TransformerFactory to recognize a feature name but
429 * to be unable to return its value; this is especially true
430 * in the case of an adapter for a SAX1 Parser, which has
431 * no way of knowing whether the underlying parser is
432 * validating, for example.</p>
434 * @param name The feature name, which is a fully-qualified URI.
435 * @return The current state of the feature (true or false).
437 public boolean getFeature(String name) {
439 // feature name cannot be null
442 throw new NullPointerException(
443 XSLMessages.createMessage(
444 XSLTErrorResources.ER_GET_FEATURE_NULL_NAME, null));
447 // Try first with identity comparison, which
449 if ((DOMResult.FEATURE == name) || (DOMSource.FEATURE == name)
450 || (SAXResult.FEATURE == name) || (SAXSource.FEATURE == name)
451 || (StreamResult.FEATURE == name)
452 || (StreamSource.FEATURE == name)
453 || (SAXTransformerFactory.FEATURE == name)
454 || (SAXTransformerFactory.FEATURE_XMLFILTER == name))
456 else if ((DOMResult.FEATURE.equals(name))
457 || (DOMSource.FEATURE.equals(name))
458 || (SAXResult.FEATURE.equals(name))
459 || (SAXSource.FEATURE.equals(name))
460 || (StreamResult.FEATURE.equals(name))
461 || (StreamSource.FEATURE.equals(name))
462 || (SAXTransformerFactory.FEATURE.equals(name))
463 || (SAXTransformerFactory.FEATURE_XMLFILTER.equals(name)))
465 // secure processing?
466 else if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING))
467 return m_isSecureProcessing;
474 * Flag set by FEATURE_OPTIMIZE.
475 * This feature specifies whether to Optimize stylesheet processing. By
476 * default it is set to true.
478 private boolean m_optimize = true;
480 /** Flag set by FEATURE_SOURCE_LOCATION.
481 * This feature specifies whether the transformation phase should
482 * keep track of line and column numbers for the input source
483 * document. Note that this works only when that
484 * information is available from the source -- in other words, if you
485 * pass in a DOM, there's little we can do for you.
487 * The default is false. Setting it true may significantly
488 * increase storage cost per node.
490 private boolean m_source_location = false;
493 * Flag set by FEATURE_INCREMENTAL.
494 * This feature specifies whether to produce output incrementally, rather than
495 * waiting to finish parsing the input before generating any output. By
496 * default this attribute is set to false.
498 private boolean m_incremental = false;
501 * Allows the user to set specific attributes on the underlying
504 * @param name The name of the attribute.
505 * @param value The value of the attribute; Boolean or String="true"|"false"
507 * @throws IllegalArgumentException thrown if the underlying
508 * implementation doesn't recognize the attribute.
510 public void setAttribute(String name, Object value)
511 throws IllegalArgumentException
513 if (name.equals(FEATURE_INCREMENTAL))
515 if(value instanceof Boolean)
517 // Accept a Boolean object..
518 m_incremental = ((Boolean)value).booleanValue();
520 else if(value instanceof String)
522 // .. or a String object
523 m_incremental = (new Boolean((String)value)).booleanValue();
527 // Give a more meaningful error message
528 throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_BAD_VALUE, new Object[]{name, value})); //name + " bad value " + value);
531 else if (name.equals(FEATURE_OPTIMIZE))
533 if(value instanceof Boolean)
535 // Accept a Boolean object..
536 m_optimize = ((Boolean)value).booleanValue();
538 else if(value instanceof String)
540 // .. or a String object
541 m_optimize = (new Boolean((String)value)).booleanValue();
545 // Give a more meaningful error message
546 throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_BAD_VALUE, new Object[]{name, value})); //name + " bad value " + value);
550 // Custom Xalan feature: annotate DTM with SAX source locator fields.
551 // This gets used during SAX2DTM instantiation.
553 // %REVIEW% Should the name of this field really be in XalanProperties?
554 // %REVIEW% I hate that it's a global static, but didn't want to change APIs yet.
555 else if(name.equals(FEATURE_SOURCE_LOCATION))
557 if(value instanceof Boolean)
559 // Accept a Boolean object..
560 m_source_location = ((Boolean)value).booleanValue();
562 else if(value instanceof String)
564 // .. or a String object
565 m_source_location = (new Boolean((String)value)).booleanValue();
569 // Give a more meaningful error message
570 throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_BAD_VALUE, new Object[]{name, value})); //name + " bad value " + value);
576 throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_NOT_SUPPORTED, new Object[]{name})); //name + "not supported");
581 * Allows the user to retrieve specific attributes on the underlying
584 * @param name The name of the attribute.
585 * @return value The value of the attribute.
587 * @throws IllegalArgumentException thrown if the underlying
588 * implementation doesn't recognize the attribute.
590 public Object getAttribute(String name) throws IllegalArgumentException
592 if (name.equals(FEATURE_INCREMENTAL))
594 return new Boolean(m_incremental);
596 else if (name.equals(FEATURE_OPTIMIZE))
598 return new Boolean(m_optimize);
600 else if (name.equals(FEATURE_SOURCE_LOCATION))
602 return new Boolean(m_source_location);
605 throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_ATTRIB_VALUE_NOT_RECOGNIZED, new Object[]{name})); //name + " attribute not recognized");
609 * Create an XMLFilter that uses the given source as the
610 * transformation instructions.
612 * @param src The source of the transformation instructions.
614 * @return An XMLFilter object, or null if this feature is not supported.
616 * @throws TransformerConfigurationException
618 public XMLFilter newXMLFilter(Source src)
619 throws TransformerConfigurationException
622 Templates templates = newTemplates(src);
623 if( templates==null ) return null;
625 return newXMLFilter(templates);
629 * Create an XMLFilter that uses the given source as the
630 * transformation instructions.
632 * @param templates non-null reference to Templates object.
634 * @return An XMLFilter object, or null if this feature is not supported.
636 * @throws TransformerConfigurationException
638 public XMLFilter newXMLFilter(Templates templates)
639 throws TransformerConfigurationException
643 return new TrAXFilter(templates);
645 catch( TransformerConfigurationException ex )
647 if( m_errorListener != null)
651 m_errorListener.fatalError( ex );
654 catch( TransformerConfigurationException ex1 )
658 catch( TransformerException ex1 )
660 throw new TransformerConfigurationException(ex1);
668 * Get a TransformerHandler object that can process SAX
669 * ContentHandler events into a Result, based on the transformation
670 * instructions specified by the argument.
672 * @param src The source of the transformation instructions.
674 * @return TransformerHandler ready to transform SAX events.
676 * @throws TransformerConfigurationException
678 public TransformerHandler newTransformerHandler(Source src)
679 throws TransformerConfigurationException
682 Templates templates = newTemplates(src);
683 if( templates==null ) return null;
685 return newTransformerHandler(templates);
689 * Get a TransformerHandler object that can process SAX
690 * ContentHandler events into a Result, based on the Templates argument.
692 * @param templates The source of the transformation instructions.
694 * @return TransformerHandler ready to transform SAX events.
695 * @throws TransformerConfigurationException
697 public TransformerHandler newTransformerHandler(Templates templates)
698 throws TransformerConfigurationException
701 TransformerImpl transformer =
702 (TransformerImpl) templates.newTransformer();
703 transformer.setURIResolver(m_uriResolver);
704 TransformerHandler th =
705 (TransformerHandler) transformer.getInputContentHandler(true);
709 catch( TransformerConfigurationException ex )
711 if( m_errorListener != null )
715 m_errorListener.fatalError( ex );
718 catch (TransformerConfigurationException ex1 )
722 catch (TransformerException ex1 )
724 throw new TransformerConfigurationException(ex1);
733 // /** The identity transform string, for support of newTransformerHandler()
734 // * and newTransformer(). */
735 // private static final String identityTransform =
736 // "<xsl:stylesheet " + "xmlns:xsl='http://www.w3.org/1999/XSL/Transform' "
737 // + "version='1.0'>" + "<xsl:template match='/|node()'>"
738 // + "<xsl:copy-of select='.'/>" + "</xsl:template>" + "</xsl:stylesheet>";
740 // /** The identity transform Templates, built from identityTransform,
741 // * for support of newTransformerHandler() and newTransformer(). */
742 // private static Templates m_identityTemplate = null;
745 * Get a TransformerHandler object that can process SAX
746 * ContentHandler events into a Result.
748 * @return TransformerHandler ready to transform SAX events.
750 * @throws TransformerConfigurationException
752 public TransformerHandler newTransformerHandler()
753 throws TransformerConfigurationException
755 return new TransformerIdentityImpl(m_isSecureProcessing);
759 * Process the source into a Transformer object. Care must
760 * be given to know that this object can not be used concurrently
761 * in multiple threads.
763 * @param source An object that holds a URL, input stream, etc.
765 * @return A Transformer object capable of
766 * being used for transformation purposes in a single thread.
768 * @throws TransformerConfigurationException May throw this during the parse when it
769 * is constructing the Templates object and fails.
771 public Transformer newTransformer(Source source)
772 throws TransformerConfigurationException
776 Templates tmpl=newTemplates( source );
777 /* this can happen if an ErrorListener is present and it doesn't
778 throw any exception in fatalError.
779 The spec says: "a Transformer must use this interface
780 instead of throwing an exception" - the newTemplates() does
781 that, and returns null.
783 if( tmpl==null ) return null;
784 Transformer transformer = tmpl.newTransformer();
785 transformer.setURIResolver(m_uriResolver);
788 catch( TransformerConfigurationException ex )
790 if( m_errorListener != null )
794 m_errorListener.fatalError( ex );
795 return null; // TODO: but the API promises to never return null...
797 catch( TransformerConfigurationException ex1 )
801 catch( TransformerException ex1 )
803 throw new TransformerConfigurationException( ex1 );
811 * Create a new Transformer object that performs a copy
812 * of the source to the result.
814 * @return A Transformer object capable of
815 * being used for transformation purposes in a single thread.
817 * @throws TransformerConfigurationException May throw this during
818 * the parse when it is constructing the
819 * Templates object and it fails.
821 public Transformer newTransformer() throws TransformerConfigurationException
823 return new TransformerIdentityImpl(m_isSecureProcessing);
827 * Process the source into a Templates object, which is likely
828 * a compiled representation of the source. This Templates object
829 * may then be used concurrently across multiple threads. Creating
830 * a Templates object allows the TransformerFactory to do detailed
831 * performance optimization of transformation instructions, without
832 * penalizing runtime transformation.
834 * @param source An object that holds a URL, input stream, etc.
835 * @return A Templates object capable of being used for transformation purposes.
837 * @throws TransformerConfigurationException May throw this during the parse when it
838 * is constructing the Templates object and fails.
840 public Templates newTemplates(Source source)
841 throws TransformerConfigurationException
844 String baseID = source.getSystemId();
846 if (null != baseID) {
847 baseID = SystemIDResolver.getAbsoluteURI(baseID);
851 if (source instanceof DOMSource)
853 DOMSource dsource = (DOMSource) source;
854 Node node = dsource.getNode();
857 return processFromNode(node, baseID);
860 String messageStr = XSLMessages.createMessage(
861 XSLTErrorResources.ER_ILLEGAL_DOMSOURCE_INPUT, null);
863 throw new IllegalArgumentException(messageStr);
867 TemplatesHandler builder = newTemplatesHandler();
868 builder.setSystemId(baseID);
872 InputSource isource = SAXSource.sourceToInputSource(source);
873 isource.setSystemId(baseID);
874 XMLReader reader = null;
876 if (source instanceof SAXSource)
877 reader = ((SAXSource) source).getXMLReader();
882 // Use JAXP1.1 ( if possible )
885 javax.xml.parsers.SAXParserFactory factory =
886 javax.xml.parsers.SAXParserFactory.newInstance();
888 factory.setNamespaceAware(true);
890 if (m_isSecureProcessing)
894 factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
896 catch (org.xml.sax.SAXException se) {}
899 javax.xml.parsers.SAXParser jaxpParser = factory.newSAXParser();
901 reader = jaxpParser.getXMLReader();
903 catch (javax.xml.parsers.ParserConfigurationException ex)
905 throw new org.xml.sax.SAXException(ex);
907 catch (javax.xml.parsers.FactoryConfigurationError ex1)
909 throw new org.xml.sax.SAXException(ex1.toString());
911 catch (NoSuchMethodError ex2){}
912 catch (AbstractMethodError ame){}
916 reader = XMLReaderFactory.createXMLReader();
918 // If you set the namespaces to true, we'll end up getting double
919 // xmlns attributes. Needs to be fixed. -sb
920 // reader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
921 reader.setContentHandler(builder);
922 reader.parse(isource);
924 catch (org.xml.sax.SAXException se)
926 if (m_errorListener != null)
930 m_errorListener.fatalError(new TransformerException(se));
932 catch (TransformerConfigurationException ex1)
936 catch (TransformerException ex1)
938 throw new TransformerConfigurationException(ex1);
943 throw new TransformerConfigurationException(se.getMessage(), se);
948 if (m_errorListener != null)
952 m_errorListener.fatalError(new TransformerException(e));
955 catch (TransformerConfigurationException ex1)
959 catch (TransformerException ex1)
961 throw new TransformerConfigurationException(ex1);
966 throw new TransformerConfigurationException(e.getMessage(), e);
970 return builder.getTemplates();
974 * The object that implements the URIResolver interface,
977 URIResolver m_uriResolver;
980 * Set an object that will be used to resolve URIs used in
981 * xsl:import, etc. This will be used as the default for the
983 * @param resolver An object that implements the URIResolver interface,
986 public void setURIResolver(URIResolver resolver)
988 m_uriResolver = resolver;
992 * Get the object that will be used to resolve URIs used in
993 * xsl:import, etc. This will be used as the default for the
996 * @return The URIResolver that was set with setURIResolver.
998 public URIResolver getURIResolver()
1000 return m_uriResolver;
1003 /** The error listener. */
1004 private ErrorListener m_errorListener = new org.apache.xml.utils.DefaultErrorHandler(false);
1007 * Get the error listener in effect for the TransformerFactory.
1009 * @return A non-null reference to an error listener.
1011 public ErrorListener getErrorListener()
1013 return m_errorListener;
1017 * Set an error listener for the TransformerFactory.
1019 * @param listener Must be a non-null reference to an ErrorListener.
1021 * @throws IllegalArgumentException if the listener argument is null.
1023 public void setErrorListener(ErrorListener listener)
1024 throws IllegalArgumentException
1027 if (null == listener)
1028 throw new IllegalArgumentException(XSLMessages.createMessage(XSLTErrorResources.ER_ERRORLISTENER, null));
1029 // "ErrorListener");
1031 m_errorListener = listener;
1035 * Return the state of the secure processing feature.
1037 * @return state of the secure processing feature.
1039 public boolean isSecureProcessing()
1041 return m_isSecureProcessing;