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
**************************************************************************************
    
1)Description:
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 (www.jdom.org)

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:

fileset

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.

4)Examples:

<!-- define task styleX, the revised version of style with support of in-file PI -->
  <taskdef name="styleX" classname="org.apache.tools.ant.taskdefs.XSLTProcessX"/>
  
  
 
  (1)Single file:
        <styleX  in="xml\auto\stocks.xml" 
                 out="xml\auto-result\stocks.html"
                 style="xml\stocks.xsl"
                
                 includes="**/*.xml"
                 />
  (2)Batch mode:
        <styleX  basedir="xml\auto" 
                 destdir="xml\auto-result"
                
                 media="wap"
                 includes="**/*.xml"
                >
                <param name="date" expression="'07-01-2000'"/>
        </styleX>
        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"
                 
                 media="wap"
                 >
                 <param name="date" expression="'07-01-2000'"/>
                 <fileset dir="xml\auto">
                        <include name="**/*.xml"/>
                 </fileset>
        </styleX>
        This replaces basedir with nested fileset to specify the source xml files

Attachment: XSLTProcessX.java
Description: Binary data

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to