From de6f7cfbc468cdf9a26c86be0aa0d68a5ce25f38 Mon Sep 17 00:00:00 2001 From: Peter Donald Date: Sun, 17 Jun 2001 00:28:56 +0000 Subject: [PATCH] Added in basic XSL templated builder. Currently uses template with same name as build file except the extension is xsl instead. PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269193 13f79535-47bb-0310-9956-ffa450edef68 --- .../components/builder/XSLProjectBuilder.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/XSLProjectBuilder.java diff --git a/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/XSLProjectBuilder.java b/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/XSLProjectBuilder.java new file mode 100644 index 000000000..8ea0c5615 --- /dev/null +++ b/proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/XSLProjectBuilder.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) The Apache Software Foundation. All rights reserved. + * + * This software is published under the terms of the Apache Software License + * version 1.1, a copy of which has been included with this distribution in + * the LICENSE file. + */ +package org.apache.myrmidon.components.builder; + +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.sax.SAXResult; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; +import org.apache.avalon.framework.configuration.SAXConfigurationHandler; +import org.apache.avalon.excalibur.io.FileUtil; + +/** + * Default implementation to construct project from a build file. + * + * @author Peter Donald + */ +public class XSLProjectBuilder + extends DefaultProjectBuilder +{ + protected void process( final String sourceID, + final SAXConfigurationHandler handler ) + throws Exception + { + final String xslSheet = FileUtil.removeExtension( sourceID ) + ".xsl"; + + // Create a transform factory instance. + final TransformerFactory factory = TransformerFactory.newInstance(); + + // Create a transformer for the stylesheet. + final Transformer transformer = factory.newTransformer( new StreamSource( xslSheet ) ); + + final SAXResult result = new SAXResult( handler ); + + //Make a debug option for this + //transformer.transform( new StreamSource( sourceID ), new StreamResult( System.out ) ); + + transformer.transform( new StreamSource( sourceID ), result ); + } +}