maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Ewins <>
Subject Report registration was Re: How to skip changelog step in site:generate?
Date Mon, 23 Dec 2002 10:59:04 GMT wrote:
> Brian Ewins <> wrote on 19/12/2002 04:01:04 AM:
>>To get this to work, I was hoping to be able to define a jelly tag that 
>>would do the work of writing the descriptors. I reckoned I'd implement 
>>this by merging descriptors directly into maven-reports.xml, like so:
> So this would be a report:display-all type of tag, yeah?

No, more like a 'display-one'. See the code below.

>>However obviously I don't know enough jelly - how would I wrap this up 
>>in a jelly 'define:tag' tag? And how do I emit properly escaped xml for 
>>the description? Any ideas?
> The register tag would have to store the entries in the jelly context, and 
> the display-all tag would have to simply write them out.
> Does this help, or do you need more info on define:tag itself?

A little more help - I've written the code (which is probably best
merged into something like the xdoc plugin, though the copying of
maven-reports.xml would need changed). Problem areas are marked inline, 
sample tag usage shown at the end.

    <goal name="report"
          description="Set up jelly tag for registering reports"

    <!-- NB prereq of init-dvsl-tag means maven.gen.doc is set -->
    <goal name="report:init"
          description="Set up jelly tags for reporting."
      <mkdir dir="${}"/>

      <!-- create empty report index if none exists -->
      <copy file="${plugin.dir}/templates/maven-reports.xml"

      <define:taglib uri="report">
        <define:tag name="register">
	<!-- FIXME: Why is null here? -->
	<j:set var=""

	<!-- I have to use a filescanner so that toURL will work -->
	<fileScanner var="docFiles">
	  <fileset dir="${}">
	    <include name="maven-reports.xml" />
	<j:forEach var="file" items="${docFiles.iterator()}">

            <!-- read the current index in -->
            <!-- FIXME: all the trim=false's here arent enough
              to get the output xml to behave. There is a bug
              in prettyprint dealing with mixed content. See
              examples at end -->
	  <x:parse var="doc" xml="${file.toURL()}" trim="false"/>

            <!-- write new index out -->
	  <j:file name="${file.absolutePath}" prettyPrint="true">
	    <jsl:stylesheet select="$doc">
	      <!-- Insert report description -->
	      <jsl:template match="table">
		<jsl:copy trim="false">

		  <!-- reports are (obviously) unique by location -->
                      select='tr[not(td/a/@href = $reportLocation)]'
                       <a href="${reportLocation}">
		    <td><define:invokeBody trim="false"/></td>
	      <!-- next two templates are not quite the
                     identity transform. (comments, PIs not
                     preserved). I tried to just re-prefixing
                     the xsl version, but it might not have worked
                     at the time because of other problems. I'll
                     look at this again
	      <jsl:template match="*" trim="false">
		<jsl:copy trim="false">
		  <jsl:applyTemplates trim="false"/>
	      <!-- ? this looks odd. -->
	      <jsl:template match="@*"/>	
	<!-- todo: should log at this point -->
	<echo>Registered report: ${reportTitle}</echo>

Sample usage:
      <attainGoal name="report:init"/>
      <!-- test: bar and baz should appear, not foo. -->
      <report:register reportLocation="rep1.html"
		     reportTitle="Report 1a">Foo</report:register>
      <report:register reportLocation="rep1.html"
		     reportTitle="Report 1b">Bar <a>test</a> spacing</report:register>
      <report:register reportLocation="rep2.html"
		     reportTitle="Report 2">Baz <a>test</a> spacing</report:register>

The xml output doesn't space correctly because of what is certainly a
bug in the 'prettyPrint' option of the jelly:core 'file' tag (and may
well have been fixed; my copy of b8 is a couple of weeks old). Turning
on and off prettyprinting removes space after tags in mixed content:
'Baz <a>test</a> spacing' becomes 'Baz <a>test</a>spacing'. Turning
'some space' into 'no space' isn't what a prettyprinter should do,
especially when I've marked every single node with 'trim=false'!

Anyway as you can see, I didn't 'store the entries in the jelly context'
- merging them on disk was something I understood well enough in xsl,
and I have no idea how to put anything into 'the context' as there's not
much documentation to go on. When in doubt I just tried whatever I could
find samples code for.

A register/display-all design would have been faster, but as I only know
how to get jelly to use global-but-immutable properties or
mutable-but-local vars I can't see how to implement that.

This might explain why I can't figure out whats wrong in the first
'FIXME' above, where is null :). jelly:define:tag would
make a lot of sense if it was defining a closure, but I'm not sure
what's in scope at all. How do I get hold of from in there?

Cheers, and all the best for Christmas and New Year,


View raw message