From a0c1be104d8f7ddca6eeb6687404db4b6d373483 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Wed, 26 Nov 2008 09:34:16 +0000 Subject: [PATCH] add an option to suppress processor warnings. PR 18897. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@720775 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 5 ++++ docs/manual/CoreTasks/style.html | 8 ++++++ .../tools/ant/taskdefs/XSLTProcess.java | 25 +++++++++++++++++++ .../ant/taskdefs/optional/TraXLiaison.java | 9 ++++++- 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/WHATSNEW b/WHATSNEW index b3c3263c5..578dfde19 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -555,6 +555,11 @@ Other changes: * now fails early if a specified stylesheet doesn't exist. Bugzilla Report 34525. + * now has an option to supress transformer warnings. This + option only has an effect for processors that support this feature; + the "trax" processor included with Ant does support it. + Bugzilla Report 18897. + Changes from Ant 1.7.0 TO Ant 1.7.1 ============================================= diff --git a/docs/manual/CoreTasks/style.html b/docs/manual/CoreTasks/style.html index f7961a353..36b56e8e3 100644 --- a/docs/manual/CoreTasks/style.html +++ b/docs/manual/CoreTasks/style.html @@ -222,6 +222,14 @@ element which is used to perform Entity and URI resolution.

Since Ant 1.7. No + + supressWarnings + Whether processor warnings shall be suppressed. + This option requires support by the processor, it is supported by + the trax processor bundled with Ant. + Since Ant 1.8.0. + No, default is false. +

Parameters specified as nested elements

diff --git a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java index bfb059abc..eb1d4b446 100644 --- a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java +++ b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java @@ -169,6 +169,13 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { */ public static final String PROCESSOR_TRAX = "trax"; + /** + * whether to suppress warnings. + * + * @since Ant 1.8.0 + */ + private boolean suppressWarnings = false; + /** * Creates a new XSLTProcess Task. */ @@ -513,6 +520,24 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger { this.fileDirParameter = fileDirParameter; } + /** + * Whether to suppress warning messages of the processor. + * + * @since Ant 1.8.0 + */ + public void setSuppressWarnings(boolean b) { + suppressWarnings = b; + } + + /** + * Whether to suppress warning messages of the processor. + * + * @since Ant 1.8.0 + */ + public boolean getSuppressWarnings() { + return suppressWarnings; + } + /** * Load processor here instead of in setProcessor - this will be * called from within execute, so we have access to the latest diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java b/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java index 9ee7d0907..b0ef4cd03 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java @@ -122,6 +122,9 @@ public class TraXLiaison implements XSLTLiaison3, ErrorListener, XSLTLoggerAware /** factory attributes */ private Vector attributes = new Vector(); + /** whether to suppress warnings */ + private boolean suppressWarnings = false; + /** * Constructor for TraXLiaison. * @throws Exception never @@ -497,7 +500,9 @@ public class TraXLiaison implements XSLTLiaison3, ErrorListener, XSLTLoggerAware * @param e the exception to log. */ public void warning(TransformerException e) { - logError(e, "Warning"); + if (!suppressWarnings) { + logError(e, "Warning"); + } } private void logError(TransformerException e, String type) { @@ -588,5 +593,7 @@ public class TraXLiaison implements XSLTLiaison3, ErrorListener, XSLTLoggerAware = (XSLTProcess.OutputProperty) props.nextElement(); setOutputProperty(prop.getName(), prop.getValue()); } + + suppressWarnings = xsltTask.getSuppressWarnings(); } }