Browse Source

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
master
Peter Donald 24 years ago
parent
commit
de6f7cfbc4
1 changed files with 45 additions and 0 deletions
  1. +45
    -0
      proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/XSLProjectBuilder.java

+ 45
- 0
proposal/myrmidon/src/java/org/apache/myrmidon/components/builder/XSLProjectBuilder.java View File

@@ -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 <a href="mailto:donaldp@apache.org">Peter Donald</a>
*/
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 );
}
}

Loading…
Cancel
Save