Ejen Logo
 
 Project
                         
News
Old News
Download
Developer site
Browse CVS
License (GPL)
 
 Documentation
                         
Introduction
Requirements
Installation
Documentation
 
 Links
                         
Xerces2-j
Xalan-j
Ant
Antlr
JBoss
 
 Contact
                         
Author
 
 
 Warning
                         
Ejen documentation for 1.1 distribution is not fully completed. Ejen node documentation is available here. For extensions and specialized XMLReaders/DocumentBuilders, you will need to look at the various examples and to download the source release.
 
Current documentation is included in the binary distribution.

 
 Ejen task
                         
Ejen is implemended for now as an Ant task. However, because it is not integrated to built-in or optional tasks distributed with Ant, you must define the task prior to use it:
build.xml
<?xml version="1.0" encoding="UTF-8"?>

<project name="build" default="build">

  <taskdef name="ejen" classname="org.ejen.ant.Ejen"/>

  <target name="build">
    <ejen>
      ...
    </ejen>
  </target>

</project>

Here, "taskdef" node defines the org.ejen.ant.Ejen class as an ant task that will be used between <ejen>...</ejen> nodes in the build file.

 
 A very basic example
                         
Suppose you want to generate several letters with the same content (except the name of the person to whom the letter will be send). This example is available in examples (see ejen-***/examples/simples/letters).
 
First, we need obviously a source XML file with all person names:
persons.xml
<?xml version="1.0" encoding="iso-8859-1"?>

<persons>
  <name>John Smith</name>
  <name>Bonnie Parker</name>
  <name>Clide Barrow</name>
  ...
</persons>

Then, because we don't need any filter in this very basic example, we simply write the following template:
letter.xsl
<?xml version="1.0" encoding="iso-8859-1"?>

<xsl:stylesheet
  version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output method="text" encoding="iso-8859-1"/>

  <xsl:template match="name">
Dear <xsl:value-of select="."/>,
  Obviously, you are reading a meaningless letter.
Best regards.
  </xsl:template>

</xsl:stylesheet>

Finally, we set up the Ant build file generation process:
generate.xml
<?xml version="1.0" encoding="UTF-8"?>

<project name="letters" default="letters">
  <taskdef name="ejen" classname="org.ejen.ant.Ejen"/>
  <target name="letters">

    <ejen>
      <source uri="persons.xml"/>
      <foreach select="/persons/name">
        <template uri="letter.xsl" save="{.}.txt"/>
      </foreach>
    </ejen>

  </target>
</project>

If we run this example, we will get text files named "John Smith.txt", "Bonnie Parker.txt", "Clide Barrow.txt", ... For example, the "John Smith.txt" file will look like:
John Smith.txt
Dear John Smith,
  Obviously, you are reading a meaningless letter.
Best regards.

This example only shows two features of Ejen: you can apply an XSL stylesheet not only to the entire XML tree in memory (loaded by the "source" node), but also, by iteration ("foreach" node), to a set of sub-nodes of this tree ; you may use AVTs (Attribute Value Template) in order to specify dynamically an Ejen node attribute ("save" attribute of the "template" node).

 
 Ejen sources compilation
                         
You must install ejen-src-***.zip AND ejen-bin-***.zip archives. It seems strange to need the binaries in order to compile the sources... But you must do it, because the sources compilation needs jar archives that only come with the binary distribution.
 
You may compile the Ejen sources by the mean of the ./build (Unix) or build.bat (Windows) command (in the ejen-*** directory)

 

SourceForge.net Logo