You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by jo...@apache.org on 2005/07/24 23:08:45 UTC
cvs commit: xml-xalan/java/src/org/apache/xalan/processor TransformerFactoryImpl.java
johng 2005/07/24 14:08:45
Modified: java/src/org/apache/xalan/processor
TransformerFactoryImpl.java
Log:
PR: XALANJ-2113
Obtained from:
Submitted by: John Gentilin
Reviewed by: Henry Zongaro
CVS: ----------------------------------------------------------------------
CVS: PR: XALANJ-2113
CVS: clean up exception handling
Revision Changes Path
1.63 +102 -44 xml-xalan/java/src/org/apache/xalan/processor/TransformerFactoryImpl.java
Index: TransformerFactoryImpl.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/processor/TransformerFactoryImpl.java,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- TransformerFactoryImpl.java 7 Jun 2005 15:35:52 -0000 1.62
+++ TransformerFactoryImpl.java 24 Jul 2005 21:08:45 -0000 1.63
@@ -126,6 +126,10 @@
{
m_errorListener.fatalError(new TransformerException(se));
}
+ catch (TransformerConfigurationException ex)
+ {
+ throw ex;
+ }
catch (TransformerException ex)
{
throw new TransformerConfigurationException(ex);
@@ -134,12 +138,14 @@
return null;
}
else
+ {
// Should remove this later... but right now diagnostics from
// TransformerConfigurationException are not good.
// se.printStackTrace();
- throw new TransformerConfigurationException(XSLMessages.createMessage(XSLTErrorResources.ER_PROCESSFROMNODE_FAILED, null), se); //"processFromNode failed",
- //se);
+ throw new TransformerConfigurationException(XSLMessages.createMessage(XSLTErrorResources.ER_PROCESSFROMNODE_FAILED, null), se);
+ //"processFromNode failed", se);
+ }
}
catch (TransformerConfigurationException tce)
{
@@ -159,6 +165,10 @@
{
m_errorListener.fatalError(new TransformerException(e));
}
+ catch (TransformerConfigurationException ex)
+ {
+ throw ex;
+ }
catch (TransformerException ex)
{
throw new TransformerConfigurationException(ex);
@@ -167,12 +177,13 @@
return null;
}
else
-
+ {
// Should remove this later... but right now diagnostics from
// TransformerConfigurationException are not good.
// se.printStackTrace();
throw new TransformerConfigurationException(XSLMessages.createMessage(XSLTErrorResources.ER_PROCESSFROMNODE_FAILED, null), e); //"processFromNode failed",
//e);
+ }
}
}
@@ -386,25 +397,27 @@
*/
public void setFeature(String name, boolean value)
throws TransformerConfigurationException {
-
- // feature name cannot be null
- if (name == null) {
- throw new NullPointerException(
- XSLMessages.createMessage(
- XSLTErrorResources.ER_SET_FEATURE_NULL_NAME, null));
- }
-
- // secure processing?
- if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
- m_isSecureProcessing = value;
- }
- // This implementation does not support the setting of a feature other than
- // the secure processing feature.
- else
- throw new TransformerConfigurationException(
- XSLMessages.createMessage(
- XSLTErrorResources.ER_UNSUPPORTED_FEATURE,
- new Object[] {name}));
+
+ // feature name cannot be null
+ if (name == null) {
+ throw new NullPointerException(
+ XSLMessages.createMessage(
+ XSLTErrorResources.ER_SET_FEATURE_NULL_NAME, null));
+ }
+
+ // secure processing?
+ if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
+ m_isSecureProcessing = value;
+ }
+ // This implementation does not support the setting of a feature other than
+ // the secure processing feature.
+ else
+ {
+ throw new TransformerConfigurationException(
+ XSLMessages.createMessage(
+ XSLTErrorResources.ER_UNSUPPORTED_FEATURE,
+ new Object[] {name}));
+ }
}
/**
@@ -422,10 +435,11 @@
public boolean getFeature(String name) {
// feature name cannot be null
- if (name == null) {
- throw new NullPointerException(
+ if (name == null)
+ {
+ throw new NullPointerException(
XSLMessages.createMessage(
- XSLTErrorResources.ER_GET_FEATURE_NULL_NAME, null));
+ XSLTErrorResources.ER_GET_FEATURE_NULL_NAME, null));
}
// Try first with identity comparison, which
@@ -622,15 +636,26 @@
public XMLFilter newXMLFilter(Templates templates)
throws TransformerConfigurationException
{
- try {
+ try
+ {
return new TrAXFilter(templates);
- } catch( TransformerConfigurationException ex ) {
- if( m_errorListener != null) {
- try {
+ }
+ catch( TransformerConfigurationException ex )
+ {
+ if( m_errorListener != null)
+ {
+ try
+ {
m_errorListener.fatalError( ex );
return null;
- } catch( TransformerException ex1 ) {
- new TransformerConfigurationException(ex1);
+ }
+ catch( TransformerConfigurationException ex1 )
+ {
+ throw ex1;
+ }
+ catch( TransformerException ex1 )
+ {
+ throw new TransformerConfigurationException(ex1);
}
}
throw ex;
@@ -678,15 +703,26 @@
(TransformerHandler) transformer.getInputContentHandler(true);
return th;
- } catch( TransformerConfigurationException ex ) {
- if( m_errorListener != null ) {
- try {
+ }
+ catch( TransformerConfigurationException ex )
+ {
+ if( m_errorListener != null )
+ {
+ try
+ {
m_errorListener.fatalError( ex );
return null;
- } catch (TransformerException ex1 ) {
- ex=new TransformerConfigurationException(ex1);
+ }
+ catch (TransformerConfigurationException ex1 )
+ {
+ throw ex1;
+ }
+ catch (TransformerException ex1 )
+ {
+ throw new TransformerConfigurationException(ex1);
}
}
+
throw ex;
}
@@ -733,7 +769,8 @@
public Transformer newTransformer(Source source)
throws TransformerConfigurationException
{
- try {
+ try
+ {
Templates tmpl=newTemplates( source );
/* this can happen if an ErrorListener is present and it doesn't
throw any exception in fatalError.
@@ -745,13 +782,23 @@
Transformer transformer = tmpl.newTransformer();
transformer.setURIResolver(m_uriResolver);
return transformer;
- } catch( TransformerConfigurationException ex ) {
- if( m_errorListener != null ) {
- try {
+ }
+ catch( TransformerConfigurationException ex )
+ {
+ if( m_errorListener != null )
+ {
+ try
+ {
m_errorListener.fatalError( ex );
return null;
- } catch( TransformerException ex1 ) {
- ex=new TransformerConfigurationException( ex1 );
+ }
+ catch( TransformerConfigurationException ex1 )
+ {
+ throw ex1;
+ }
+ catch( TransformerException ex1 )
+ {
+ throw new TransformerConfigurationException( ex1 );
}
}
throw ex;
@@ -880,13 +927,19 @@
{
m_errorListener.fatalError(new TransformerException(se));
}
+ catch (TransformerConfigurationException ex1)
+ {
+ throw ex1;
+ }
catch (TransformerException ex1)
{
throw new TransformerConfigurationException(ex1);
}
}
else
+ {
throw new TransformerConfigurationException(se.getMessage(), se);
+ }
}
catch (Exception e)
{
@@ -895,16 +948,21 @@
try
{
m_errorListener.fatalError(new TransformerException(e));
-
return null;
}
+ catch (TransformerConfigurationException ex1)
+ {
+ throw ex1;
+ }
catch (TransformerException ex1)
{
throw new TransformerConfigurationException(ex1);
}
}
else
+ {
throw new TransformerConfigurationException(e.getMessage(), e);
+ }
}
return builder.getTemplates();
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org