Skip to Main Content
Ant: The Definitive Guide, 2nd Edition
book

Ant: The Definitive Guide, 2nd Edition

by Steve Holzner
April 2005
Intermediate to advanced content levelIntermediate to advanced
336 pages
7h 20m
English
O'Reilly Media, Inc.
Content preview from Ant: The Definitive Guide, 2nd Edition

Transforming XML Using XSLT

The xslt task, also called the style task (the two names are interchangeable in Ant), can process a set of documents via XSLT. This is handy for building nicely formatted views of XML-based documentation in other formats like HTML, or for generating code. How do you use this task to perform XSLT transformations? Example 9-5 shows a build file that puts it to work, transforming style.xml into style.html, using style.xsl.

Example 9-5. Using the xslt/style task ch09/xslt/build.xml

<?xml version="1.0" encoding="UTF-8" ?> 

<project default="main" > 

    <target name="main"> 
        <xslt basedir="." destdir="." extension=".html" includes="style.xml" 
            style="style.xsl"/>
    </target> 

</project>

Here's style.xml, the XML document to transform, which holds data about three U.S. states:

<?xml version="1.0" encoding ="UTF-8"?> <states> <state> <name>California</name> <population units="people">33871648</population><!--2000 census--> <capital>Sacramento</capital> <bird>Quail</bird> <flower>Golden Poppy</flower> <area units="square miles">155959</area> </state> <state> <name>Massachusetts</name> <population units="people">6349097</population><!--2000 census--> <capital>Boston</capital> <bird>Chickadee</bird> <flower>Mayflower</flower> <area units="square miles">7840</area> </state> <state> <name>New York</name> <population units="people">18976457</population><!--2000 census--> <capital>Albany</capital> <bird>Bluebird</bird> <flower>Rose</flower> <area units="square miles">47214</area> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Ant: The Definitive Guide

Ant: The Definitive Guide

Eric M. Burke, Jesse Tilly
Tomcat: The Definitive Guide, 2nd Edition

Tomcat: The Definitive Guide, 2nd Edition

Jason Brittain, Ian F. Darwin
Ant in Action

Ant in Action

Erik Hatcher, Steve Loughran
CMake Cookbook

CMake Cookbook

Radovan Bast, Roberto Di Remigio

Publisher Resources

ISBN: 0596006098Supplemental ContentErrata Page