Return-Path: Delivered-To: apmail-ant-notifications-archive@locus.apache.org Received: (qmail 21536 invoked from network); 3 Dec 2008 12:02:54 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Dec 2008 12:02:54 -0000 Received: (qmail 39159 invoked by uid 500); 3 Dec 2008 12:03:05 -0000 Delivered-To: apmail-ant-notifications-archive@ant.apache.org Received: (qmail 39140 invoked by uid 500); 3 Dec 2008 12:03:05 -0000 Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ant.apache.org Delivered-To: mailing list notifications@ant.apache.org Received: (qmail 39131 invoked by uid 99); 3 Dec 2008 12:03:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Dec 2008 04:03:05 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Dec 2008 12:01:45 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id CAD37238889E; Wed, 3 Dec 2008 04:02:32 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r722849 - in /ant/core/trunk: ./ lib/ src/main/org/apache/tools/ant/taskdefs/ src/main/org/apache/tools/ant/taskdefs/optional/ src/tests/antunit/taskdefs/ Date: Wed, 03 Dec 2008 12:02:31 -0000 To: notifications@ant.apache.org From: bodewig@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081203120232.CAD37238889E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bodewig Date: Wed Dec 3 04:02:30 2008 New Revision: 722849 URL: http://svn.apache.org/viewvc?rev=722849&view=rev Log: Add support for Xalan2 Traces. PR 36670. Added: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/XSLTTraceSupport.java (with props) ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Xalan2TraceSupport.java (with props) Modified: ant/core/trunk/build.xml ant/core/trunk/lib/libraries.properties ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java ant/core/trunk/src/tests/antunit/taskdefs/xslt-test.xml Modified: ant/core/trunk/build.xml URL: http://svn.apache.org/viewvc/ant/core/trunk/build.xml?rev=722849&r1=722848&r2=722849&view=diff ============================================================================== --- ant/core/trunk/build.xml (original) +++ ant/core/trunk/build.xml Wed Dec 3 04:02:30 2008 @@ -170,21 +170,6 @@ =================================================================== --> - - - - - - - - - - - - - - - @@ -204,6 +189,7 @@ + @@ -300,6 +286,11 @@ + + + + + @@ -356,8 +347,6 @@ =================================================================== --> - - @@ -386,6 +375,9 @@ + @@ -445,14 +437,6 @@ - - - - - - - - @@ -521,11 +505,6 @@ classname="com.jcraft.jsch.Session" classpathref="classpath"/> - - - - - @@ -579,8 +558,6 @@ - - @@ -606,6 +583,10 @@ + + + @@ -704,7 +685,6 @@ - @@ -783,6 +763,7 @@ + @@ -823,6 +804,7 @@ + @@ -1755,15 +1737,6 @@ - - - - - @@ -1873,7 +1846,7 @@ + > Modified: ant/core/trunk/lib/libraries.properties URL: http://svn.apache.org/viewvc/ant/core/trunk/lib/libraries.properties?rev=722849&r1=722848&r2=722849&view=diff ============================================================================== --- ant/core/trunk/lib/libraries.properties (original) +++ ant/core/trunk/lib/libraries.properties Wed Dec 3 04:02:30 2008 @@ -59,7 +59,7 @@ #xmlParserAPIs.version=${xerces.version} #xmlParserAPIs.version=2.6.1 xml-apis.version=2.0.2 -xalan.version=2.7.0 +xalan.version=2.7.1 xml-resolver.version=1.2 mail.version=1.4 #paired Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java?rev=722849&r1=722848&r2=722849&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java Wed Dec 3 04:02:30 2008 @@ -210,6 +210,13 @@ new CommandlineJava.SysProperties(); /** + * Trace configuration for Xalan2. + * + * @since Ant 1.8.0 + */ + private TraceConfiguration traceConfiguration; + + /** * Creates a new XSLTProcess Task. */ public XSLTProcess() { @@ -632,6 +639,33 @@ } /** + * Enables Xalan2 traces and uses the given configuration. + * + *

Note that this element doesn't have any effect with a + * processor other than trax or if the Transformer is not Xalan2's + * transformer implementation.

+ * + * @since Ant 1.8.0 + */ + public TraceConfiguration createTrace() { + if (traceConfiguration != null) { + throw new BuildException("can't have more than one trace" + + " configuration"); + } + traceConfiguration = new TraceConfiguration(); + return traceConfiguration; + } + + /** + * Configuration for Xalan2 traces. + * + * @since Ant 1.8.0 + */ + public TraceConfiguration getTraceConfiguration() { + return traceConfiguration; + } + + /** * Load processor here instead of in setProcessor - this will be * called from within execute, so we have access to the latest * classpath. @@ -1358,4 +1392,100 @@ } } + /** + * Configuration for Xalan2 traces. + * + * @since Ant 1.8.0 + */ + public final class TraceConfiguration { + private boolean elements, extension, generation, selection, templates; + + /** + * Set to true if the listener is to print events that occur + * as each node is 'executed' in the stylesheet. + */ + public void setElements(boolean b) { + elements = b; + } + + /** + * True if the listener is to print events that occur as each + * node is 'executed' in the stylesheet. + */ + public boolean getElements() { + return elements; + } + + /** + * Set to true if the listener is to print information after + * each extension event. + */ + public void setExtension(boolean b) { + extension = b; + } + + /** + * True if the listener is to print information after each + * extension event. + */ + public boolean getExtension() { + return extension; + } + + /** + * Set to true if the listener is to print information after + * each result-tree generation event. + */ + public void setGeneration(boolean b) { + generation = b; + } + + /** + * True if the listener is to print information after each + * result-tree generation event. + */ + public boolean getGeneration() { + return generation; + } + + /** + * Set to true if the listener is to print information after + * each selection event. + */ + public void setSelection(boolean b) { + selection = b; + } + + /** + * True if the listener is to print information after each + * selection event. + */ + public boolean getSelection() { + return selection; + } + + /** + * Set to true if the listener is to print an event whenever a + * template is invoked. + */ + public void setTemplates(boolean b) { + templates = b; + } + + /** + * True if the listener is to print an event whenever a + * template is invoked. + */ + public boolean getTemplates() { + return templates; + } + + /** + * The stream to write traces to. + */ + public java.io.OutputStream getOutputStream() { + return new LogOutputStream(XSLTProcess.this); + } + } + } Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java?rev=722849&r1=722848&r2=722849&view=diff ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java (original) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java Wed Dec 3 04:02:30 2008 @@ -125,6 +125,9 @@ /** whether to suppress warnings */ private boolean suppressWarnings = false; + /** optional trace configuration. */ + private XSLTProcess.TraceConfiguration traceConfiguration = null; + /** * Constructor for TraXLiaison. * @throws Exception never @@ -324,6 +327,37 @@ final String[] pair = (String[]) outputProperties.elementAt(i); transformer.setOutputProperty(pair[0], pair[1]); } + + if (traceConfiguration != null) { + if ("org.apache.xalan.transformer.TransformerImpl" + .equals(transformer.getClass().getName())) { + try { + Class traceSupport = + Class.forName("org.apache.tools.ant.taskdefs.optional." + + "Xalan2TraceSupport", true, + Thread.currentThread() + .getContextClassLoader()); + XSLTTraceSupport ts = + (XSLTTraceSupport) traceSupport.newInstance(); + ts.configureTrace(transformer, traceConfiguration); + } catch (Exception e) { + String msg = "Failed to enable tracing because of " + e; + if (project != null) { + project.log(msg, Project.MSG_WARN); + } else { + System.err.println(msg); + } + } + } else { + String msg = "Not enabling trace support for transformer" + + " implementation" + transformer.getClass().getName(); + if (project != null) { + project.log(msg, Project.MSG_WARN); + } else { + System.err.println(msg); + } + } + } } /** @@ -583,5 +617,7 @@ } suppressWarnings = xsltTask.getSuppressWarnings(); + + traceConfiguration = xsltTask.getTraceConfiguration(); } } Added: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/XSLTTraceSupport.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/XSLTTraceSupport.java?rev=722849&view=auto ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/XSLTTraceSupport.java (added) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/XSLTTraceSupport.java Wed Dec 3 04:02:30 2008 @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.tools.ant.taskdefs.optional; + +import org.apache.tools.ant.taskdefs.XSLTProcess; +import javax.xml.transform.Transformer; + +/** + * Sets up trace support for a given transformer. + * + * @since Ant 1.8.0 + */ +public interface XSLTTraceSupport { + void configureTrace(Transformer t, XSLTProcess.TraceConfiguration conf); +} Propchange: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/XSLTTraceSupport.java ------------------------------------------------------------------------------ svn:eol-style = native Added: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Xalan2TraceSupport.java URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Xalan2TraceSupport.java?rev=722849&view=auto ============================================================================== --- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Xalan2TraceSupport.java (added) +++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Xalan2TraceSupport.java Wed Dec 3 04:02:30 2008 @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.tools.ant.taskdefs.optional; + +import java.io.PrintWriter; +import java.util.TooManyListenersException; +import javax.xml.transform.Transformer; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.taskdefs.XSLTProcess; +import org.apache.xalan.trace.PrintTraceListener; +import org.apache.xalan.transformer.TransformerImpl; + +/** + * Sets up trace support for a given transformer. + * + * @since Ant 1.8.0 + */ +public class Xalan2TraceSupport implements XSLTTraceSupport { + public void configureTrace(Transformer t, + XSLTProcess.TraceConfiguration conf) { + if (t instanceof TransformerImpl && conf != null) { + PrintWriter w = new PrintWriter(conf.getOutputStream(), false); + PrintTraceListener tl = new PrintTraceListener(w); + tl.m_traceElements = conf.getElements(); + tl.m_traceExtension = conf.getExtension(); + tl.m_traceGeneration = conf.getGeneration(); + tl.m_traceSelection = conf.getSelection(); + tl.m_traceTemplates = conf.getTemplates(); + try { + ((TransformerImpl) t).getTraceManager().addTraceListener(tl); + } catch (TooManyListenersException tml) { + throw new BuildException(tml); + } + } + } +} Propchange: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/Xalan2TraceSupport.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: ant/core/trunk/src/tests/antunit/taskdefs/xslt-test.xml URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/xslt-test.xml?rev=722849&r1=722848&r2=722849&view=diff ============================================================================== --- ant/core/trunk/src/tests/antunit/taskdefs/xslt-test.xml (original) +++ ant/core/trunk/src/tests/antunit/taskdefs/xslt-test.xml Wed Dec 3 04:02:30 2008 @@ -146,4 +146,28 @@
+ + + + + + + + + + + + + + + + + + +