Difference between revisions of "ODFXSLTRunnerTask"

From Apache OpenOffice Wiki
Jump to: navigation, search
(New page: == Apply XSLT stylesheets to ODF documents with Ant == '''ODFXSLTRunnerTask''' is a task definition for [http://ant.apache.org/ Ant] which allows to apply XSLT stylesheets to ODF documents...)
 
(Background Information)
 
(12 intermediate revisions by the same user not shown)
Line 8: Line 8:
 
A binary release of '''odfxsltrunnertask.jar''' is [http://odftoolkit.openoffice.org/files/documents/254/4289/odfxsltrunnertask.jar available here].
 
A binary release of '''odfxsltrunnertask.jar''' is [http://odftoolkit.openoffice.org/files/documents/254/4289/odfxsltrunnertask.jar available here].
  
Building and running '''odfxsltrunner.jar''' requires additional jar files. Please see [[#Requirements Requirements]] for details.
+
Building and running '''odfxsltrunner.jar''' requires additional jar files. Please see [[#Requirements|Requirements]] for details.
  
 
== Usage ==
 
== Usage ==
Line 17: Line 17:
 
           classpath="''<path>''/odfxsltrunnertak.jar:''<path>''/odfxsltrunner.jar"/>
 
           classpath="''<path>''/odfxsltrunnertak.jar:''<path>''/odfxsltrunner.jar"/>
  
You can use this task definition on the top level (that is as a child element of the <tt><project></tt> or locally within a single <tt><target></tt> element. It defines a new task <tt><odfxslt></tt> which allows to process ODF documents with XSLT stylesheets.
+
You can use this task definition on the top level (that is as a child element of the <tt><project></tt> element or locally within a single <tt><target></tt> element. It defines a new task <tt><odfxslt></tt> which allows to process ODF documents with XSLT stylesheets.
  
 
The new task supports the use of nested <tt><param></tt> elements which have the same meaning as the <tt><param></tt> child elements of the <tt><xslt></tt> [http://ant.apache.org/manual/CoreTasks/style.html task].
 
The new task supports the use of nested <tt><param></tt> elements which have the same meaning as the <tt><param></tt> child elements of the <tt><xslt></tt> [http://ant.apache.org/manual/CoreTasks/style.html task].
Line 25: Line 25:
 
<table border="border">
 
<table border="border">
 
<tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 
<tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
<tr><td>in</td><td>specifies an ODF document to which the stylesheet is applied.</td><td>Yes, unless infile has been specified</td>
+
<tr><td valign="top">in</td><td>specifies an ODF document to which the stylesheet is applied.</td><td valign="top">Yes, unless infile has been specified</td>
<tr><td>infile</td><td>specifies a plain XML document to which the stylesheet is applied.</td><td>Yes, unless in has been specified</td>
+
<tr><td valign="top">infile</td><td>specifies a plain XML document to which the stylesheet is applied.</td><td valign="top">Yes, unless in has been specified</td>
<tr><td>out</td><td>specifies an ODF document to which the result of the transformation is stored.
+
<tr><td valign="top">out</td><td>specifies an ODF document to which the result of the transformation is stored.<br>
Unless template has been specified, the package specified by in is copied to out, and the stream specified by path is replaced with the result of the transformation</td><td>Yes, unless outfile has been specified</td>
+
Unless template has been specified, the package specified by in is copied to out, and the stream specified by path is replaced with the result of the transformation.</td><td valign="top">Yes, unless outfile has been specified</td>
<tr><td>outfile</td><td>specifies a plain XML document which the result of the transformation is stored.</td><td>Yes, unless out has been specified</td>
+
<tr><td valign="top">outfile</td><td>specifies a plain XML document to which the result of the transformation is stored.</td><td valign="top">Yes, unless out has been specified</td>
<tr><td>path</td><td>Specifies the stream within the ODF packages specified by in and out which is the source or target of the transformation.</td><td>No</td>
+
<tr><td valign="top">path</td><td>Specifies the stream within the ODF packages specified by in and out, which is the source or target of the transformation.</td><td valign="top">No</td>
<tr><td>template</td><td>Specifies that the specified stream within out is replaced with the result of the transformation without copying the package specified by in. The specified out package must exist.</td><td>No:  Default is "content.xml"</td>
+
<tr><td valign="top">template</td><td>Specifies that the specified stream within the out ODF package is replaced with the result of the transformation, without previously copying the package specified by in. The specified out package must exist.</td><td valign="top">No:  Default is "content.xml"</td>
<tr><td>force</td><td>Specifies that the target file shall be recreated, even if is are newer than the source file or the stylesheet.</td><td>No: Default is false</td>
+
<tr><td valign="top">force</td><td>Specifies that the target file shall be recreated, even if it is newer than the source file or the stylesheet.</td><td valign="top">No: Default is false</td>
 
</table>
 
</table>
  
Line 45: Line 45:
 
<table border="border">
 
<table border="border">
 
<tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
 
<tr><th>Attribute</th><th>Description</th><th>Required</th></tr>
<tr><td>name</td><td>name of the paramter.</td><td>Yes</td>
+
<tr><td valign="top">name</td><td>name of the paramter.</td><td valign="top">Yes</td>
<tr><td>expression</td><td>value of the paramter.
+
<tr><td valign="top">expression</td><td>value of the paramter.
 
'''Note:''' All parameter values are passed as string values to the XSLT paramters specified by <tt><xslt:param></tt> elements within the stylesheet.
 
'''Note:''' All parameter values are passed as string values to the XSLT paramters specified by <tt><xslt:param></tt> elements within the stylesheet.
</td><td>Yes</td>
+
</td><td valign="top">Yes</td>
 +
</table>
  
 
'''Note:''' The paramters <tt>if</tt> and <tt>unless</tt> which are supported by the <tt><xslt></tt> task are (not yet) supported.
 
'''Note:''' The paramters <tt>if</tt> and <tt>unless</tt> which are supported by the <tt><xslt></tt> task are (not yet) supported.
Line 54: Line 55:
 
== Requirements ==
 
== Requirements ==
  
'''odfxsltrunner''' requires [http://java.sun.com/javase/downloads/index.jsp J2RE 5], or a later version of Java. It further requires [http://odftoolkit.openoffice.org/servlets/ProjectDocumentList?folderID=759&expandFolder=759&folderID=771 ODFDOM] (at least version  v0.6.1). The ODFDOM jar file must be either located in folder called '''lib''' next to the '''odfxsltrunner.jar''' file, or it must be in the '''classpath'''.  
+
'''odfxsltrunnertask''' requires [http://java.sun.com/javase/downloads/index.jsp J2RE 5], or a later version of Java.  
  
'''Note:''' [[ODFDOM]] v0.6.1  requires [http://xml.apache.org/dist/xerces-j/ Apache's xerces]. The jar file '''xercesImpl.jar''' also must exist in a folder '''lib''' next to '''odfxsltrunner.jar''' file, or it must be in the '''classpath'''.
+
It further requires [[ODFXSLTRunner]] and [http://odftoolkit.openoffice.org/servlets/ProjectDocumentList?folderID=759&expandFolder=759&folderID=771 ODFDOM] (at least version  v0.6.1).
 +
 
 +
'''Note:''' When building '''odfxsltrunertask''', the '''odfxsltrunner''' project has be checked out, too. It is build automatically.
 +
 
 +
In the Ant task definition, the '''classpth''' attribute must include the '''odfxsltrunnertask.jar''' and '''odfxsltrunner.jar''' files. The  ODFDOM jar file is found automatically if it is located in a folder called '''lib''' next to the '''odfxsltrunner.jar''' file.
 +
 
 +
'''Note:''' [[ODFDOM]] v0.6.1  requires [http://xml.apache.org/dist/xerces-j/ Apache's xerces]. The jar file '''xercesImpl.jar''' also must exist in a folder '''lib''' next to '''odfxsltrunner.jar''' file.
  
 
== Background Information ==
 
== Background Information ==
 +
 +
[http://blogs.sun.com/GullFOSS/entry/applying_xslt_stylesheets_to_odf Applying XSLT stylesheets to ODF documents with Ant]
  
 
[[Category:ODF]]
 
[[Category:ODF]]
 
[[Category:ODFToolkit]]
 
[[Category:ODFToolkit]]
 +
[[Category:ODFToolkitTool]]
 
[[Category:Effort]]
 
[[Category:Effort]]
 
[[Category:XSLT]]
 
[[Category:XSLT]]
 
[[Category:Ant]]
 
[[Category:Ant]]

Latest revision as of 14:35, 31 July 2008

Apply XSLT stylesheets to ODF documents with Ant

ODFXSLTRunnerTask is a task definition for Ant which allows to apply XSLT stylesheets to ODF documents similar to Ant's build-in <xslt> task.

Getting and building ODFXSLTRunnerTask

odfxsltrunnertask is build by a NetBeans project. After you have checked out the sources, you can open the project in NetBeans and build odfxsltrunnertask.

A binary release of odfxsltrunnertask.jar is available here.

Building and running odfxsltrunner.jar requires additional jar files. Please see Requirements for details.

Usage

To use odfxsltrunner.jar with Ant, you have to include the following task definition into your buildfile, where <path> has to be replaced with the path where you have stored the odfxsltrunnertask.jar and odfxsltrunner.jar files:

<taskdef name="odfxslt" classname="odfxsltrunnertask.ODFXSLTRunnerTask"
         classpath="<path>/odfxsltrunnertak.jar:<path>/odfxsltrunner.jar"/>

You can use this task definition on the top level (that is as a child element of the <project> element or locally within a single <target> element. It defines a new task <odfxslt> which allows to process ODF documents with XSLT stylesheets.

The new task supports the use of nested <param> elements which have the same meaning as the <param> child elements of the <xslt> task.

Parameters

AttributeDescriptionRequired
inspecifies an ODF document to which the stylesheet is applied.Yes, unless infile has been specified
infilespecifies a plain XML document to which the stylesheet is applied.Yes, unless in has been specified
outspecifies an ODF document to which the result of the transformation is stored.
Unless template has been specified, the package specified by in is copied to out, and the stream specified by path is replaced with the result of the transformation.
Yes, unless outfile has been specified
outfilespecifies a plain XML document to which the result of the transformation is stored.Yes, unless out has been specified
pathSpecifies the stream within the ODF packages specified by in and out, which is the source or target of the transformation.No
templateSpecifies that the specified stream within the out ODF package is replaced with the result of the transformation, without previously copying the package specified by in. The specified out package must exist.No: Default is "content.xml"
forceSpecifies that the target file shall be recreated, even if it is newer than the source file or the stylesheet.No: Default is false

Parameters specified as nested elements

Param

Param specifies a parameter that is passed as XSLT parameter to the XSL stylesheet.

Parameters

AttributeDescriptionRequired
namename of the paramter.Yes
expressionvalue of the paramter.

Note: All parameter values are passed as string values to the XSLT paramters specified by <xslt:param> elements within the stylesheet.

Yes

Note: The paramters if and unless which are supported by the <xslt> task are (not yet) supported.

Requirements

odfxsltrunnertask requires J2RE 5, or a later version of Java.

It further requires ODFXSLTRunner and ODFDOM (at least version v0.6.1).

Note: When building odfxsltrunertask, the odfxsltrunner project has be checked out, too. It is build automatically.

In the Ant task definition, the classpth attribute must include the odfxsltrunnertask.jar and odfxsltrunner.jar files. The ODFDOM jar file is found automatically if it is located in a folder called lib next to the odfxsltrunner.jar file.

Note: ODFDOM v0.6.1 requires Apache's xerces. The jar file xercesImpl.jar also must exist in a folder lib next to odfxsltrunner.jar file.

Background Information

Applying XSLT stylesheets to ODF documents with Ant

Personal tools