ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [SUBMIT] Enhancement style task(supporting Processing Instruction)
Date Thu, 01 Jan 1970 00:00:00 GMT
Hi folks,
    I recently made some additions to the built-in style task to have the capability to use
the Processing Instruction(PI)
embeded in the xml source file to locate the stylesheet for the transformation. I feel that
it's more convenient than using style attribute, especially
when there are a lot of xml files to transform and each one has it's a unique stylesheet(stylesheets).
    I hope this functionality can be integrated into the next version of style task. 
    Soure file is attached to this email. Hope this helps.
Shengmeng Liu
Process a set of documents via XSLT 
This is useful for building views of XML based documentation, or in generating code.

Added features:
 * Now support using the Processing Instruction(PI) embeded in the xml source file to locate
the stylesheet
 * Now support using nested Fileset elements to specify all the xml source to be transformed
Library Dependencies:
   1)JAXP compliant parser (such as xerces.jar or the one that comes with Ant)
   2)An XSL transformer (Xalan only)
   3)JDOM package (

2)Parameters: (updated)

Attribute		Description 									Required 

basedir 		where to find the source XML file, default is the project's basedir. 		No (deprecated),
use nested fileset instead
style			name of the stylesheet to use - given relative to the basedir attribute		No, it has
became optional, if not specified,
			of this task as well.   							task will try to use Processing instructions
													to locate the stylesheet to use
3)Parameters specified as nested elements:


FileSets are used to select xml files to transform. 
use nested fileset, instead of the implicit fileset generated from attributes.
Note: either fileset or basedir is specified not both.


<!-- define task styleX, the revised version of style with support of in-file PI -->
  <taskdef name="styleX" classname=""/>
  (1)Single file:
	<styleX  in="xml\auto\stocks.xml" 
  (2)Batch mode:
  	<styleX  basedir="xml\auto" 
      		<param name="date" expression="'07-01-2000'"/>
	This will transform all files(recursively) under xml\auto\ that end with *.xml to xml\auto-result
with the same
	directory structure, using processing instruction whose media type is wap, in the xml source
file to locate the
	stylesheet for styling. 
	This will also replace an xsl:param definition<xsl:param name="date"></xsl:param>
with the text value 07-01-2000 
 	<styleX  destdir="xml\auto-result"
       		 <param name="date" expression="'07-01-2000'"/>
       		 <fileset dir="xml\auto">
        		<include name="**/*.xml"/>
       	This replaces basedir with nested fileset to specify the source xml files

View raw message