logo
- Jérôme Nègre's piece of web -


Description

This plug-in allows one to apply XSL sheets to specific files inside a given source directory. Its first goal was to make easier the creation of an homogeneous web site, but it can be used for other things, such as producing SVG graphics, PHP pages, RTF documents...

Main features:

  • Support for several XSL sheets
  • Auto-build on file save
  • Precise error and warning report inside the "Task" view
  • XSL parameters are automagically set to the current date, url from the page to any another, and so on
  • Automatic directory listing
  • Integrated help inside Eclipse
  • Wizards to get you started
  • Works with Eclipse 2.1 and 3.0

To have a more precise idea of what you can do with this plug-in, read the following paragraph "Your First Project With Stylo Plume".

Feedback on this plug-in is wanted, please tell me what you like/dislike.

Your First Project With Stylo Plume

First, create a new simple project (do not use one of Stylo Plume's wizards). Inside that project, create three folders (directories): "src", "src/images" and "template". Now right click on the project, and select Stylo Plume > Use With Stylo Plume. An error message should appear in the task list saying that the project was not built: this is because there is no XSL sheet yet.

So, our next task will be to create such a beast. Create a new file "style.xsl" inside the folder "template", and edit it to look like this:

<?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="xml" indent="no" 
    doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
    doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>

  <!-- Parameters (set by StyloPlume) -->
  <xsl:param name="projectDir" select="'unknown/'"/>
  <xsl:param name="lastUpdate" select="'unknown'"/>
  <xsl:param name="imagePath" select="'unknown/'"/>

  <!-- Templates -->
	
  <xsl:template match="/sp_page">
    <html>
      <head>
        <title><xsl:value-of select="@title"/></title>
      </head>
      <body>
        <p align="center">
          <img alt="logo">
            <xsl:attribute name="src" >
              <xsl:value-of select = "concat($imagePath,'logo.png')" />
            </xsl:attribute>
          </img>
        </p>
        <div style="background-color:#EAEAEA;">
          <xsl:apply-templates/>
        </div>
        <xsl:apply-templates select="document(concat($projectDir,'template/footer.xml'))"/>
      </body>
    </html>
  </xsl:template>
	
  <xsl:template match="sp_lastupdate">
    <xsl:value-of select="$lastUpdate"/>
 </xsl:template>
	
  <xsl:template match="*">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>
	
  <xsl:template match="text()">
    <xsl:value-of select="."/>
  </xsl:template>

</xsl:stylesheet>

Now that we have an XSL sheet, the project can be setup. Right click on the project, and select Properties: a new category, "Stylo Plume", should be available. Edit the template file to "template/style.xsl". You should also create two parameters: lastUpdate (type=date, format="en-US MMMM d, yyyy") and imagePath(type=url to, format="images/"). ProjectDir is always set by StyloPlume, you needn't specify it. Once the dialog is closed, a new folder, "bin", is created.

This XSL sheet refers to two other documents: logo.png inside "src/images", and footer.xml inside "template". Put any PNG picture inside "src/images", and rename it logo.png. Footer.xml is an XML file, and should look something like this:

<?xml version="1.0" encoding="iso-8859-1"?>
<div style="text-align:center;">
  Last update: <sp_lastupdate/>
</div>

Now, you can write your first page with Stylo Plume. Create a new file inside "src", and name it mypage.html.spf. The file transformed by Stylo Plume will be mypage.html inside "bin". The content of mypage.html.spf uses the templates defined by style.xsl:

<?xml version="1.0" encoding="iso-8859-1"?>
<sp_page title="My Page">
  <p>
    Hello World!
  </p>
</sp_page>

Now have a look inside the folder "bin": all files whose extension is spf have been transformed, while others have just been copied. Open bin/mypage.html with your favorite browser, you should see a page with your logo at the top, the traditional "Hello World!", and the time of the last compilation.

You can have as many folders as you want inside "src", Stylo Plume will always give to your XSL sheet the correct path to the image dir.

Your Second Project With Stylo Plume
If you don't feel like doing all this by hand, just use one of the wizards available to create a working project.
Change Log
0.1.13
  • Fixed bugs when creating projects not using the default location
0.1.12
  • Better error report for jdk 1.4 (of course, it has to differ from jdk 1.3...)
0.1.11
  • Bug fixes (more to come)
0.1.10
  • Incremental builder (does not check dependency yet)
  • Minor speed improvements
0.1.9
  • Wizards to create simple XHTML projects
  • Automatic directory listing (user request)
  • Bug fixes
0.1.8
  • Stupid bug fix, discovered 10 minutes after the last release :-(
0.1.7
  • Wizard to create empty projects
  • Warnings are reported in the Tasks List
0.1.6
  • Support of several XSL sheets
  • Bug fixes
0.1.5
  • Precise error report for XSL sheets
0.1.4
  • Critical bug fix
0.1.3
  • Dialog to pick directories (experimental)
  • Support of <xsl:import> and <xsl:include>
0.1.2
  • Save settings in a file instead of Eclipse's registry (useful for CVS)
  • Automatic rebuild after a setting modification (i.e. changing the source folder, the name of the XSL sheet, aso)
0.1.1
  • Ability to specify new parameters
  • Use of locale for dates
  • Integrated help inside Eclipse (very small for the time being)
  • Better error report
0.1.0
  • First public release
Todo List (in no special order)
  • Better dependency finder
  • The "SP" icon should appear as soon as the nature is set, not after a restart of Eclipse (cosmetic)
  • Some kind of XSL debugger/tracer (user request)
  • Check if folders are ok (for instance the source folder can't be a child of the bin folder)
Download
Use the update manager and create a bookmark to http://www.jnegre.org/updates/site.xml.
Thanks
Many thanks to Eli Lopian, Laurent Fourrier, Lars Høidahl and Victor Volle for their valuable feedback and suggestions.
Contact
You can mail me at [plugin at jnegre dot org] in french or english for any comment/request/problem.
Spelling or grammatical mistake? Let me know, mail me at [webmaster at jnegre dot org], thanks!
Last modified: Jan. 26, 2005 at 19:11:08 CET
Valid XHTML 1.0! - Valid CSS!