XDoc Customization

notes

  • DVSL got axed, now they're using JSL
  • can this be done more dynamically?
  • can I call other .jsl files from the site.jsl?
  • can I somehow dynamically extend the site.jsl without having to manually edit it?

J:SET var name's must be Java styled
 <j:set var="altText"><x:expr select="@alt-text"/></j:set>
the j:set tag var names MUST NOT contain hyphen's. it won't work. make sure they are java style var names... as above.

ie DO NOT USE 'alt-text' as a var name

USE 'altText' as a var name


USE PARAGRAPH TAGES IN XDOC SECTIONS



in the XDOCS... you must use a <P> tag if you want text to show up.

any plain text under a SECTION tag will be ingored unless it's wrapped by another tag.

todo

  • write user group about extending to add template functions.. IE image, diagram, etc
  • need to port generic XML source transform tag
  • learn more about jelly
  • figure out how to:
    • call a jsl template by name... to avoid copy/pasting
    • use jelly's XML:IF properly



      I couldn't get it to return true at all..

      I'd like to do this:

            <x:if select="@outline">
              <j:set var="borderColor">#666666</j:set>
            </x:if>
      
      but it doesn't work.

      Instead I must do this:

            <j:set var="doOutline"><x:expr select="@outline"/></j:set>
            <j:if test="${doOutline != ''}">
              <j:set var="borderColor">#666666</j:set>
            </j:if>
      

notes

Copy the text below to the bottom of the file: MAVEN_HOME\plugins\maven-xdoc-plugin-1.3-SNAPSHOT\plugin-resources\site.jsl




<!-- U5eR  CUSTOM JSL TEMPLATES  -->


<!-- D I A G R A M -->


  <jsl:template match="diagram" trim="false">

<!-- relativePath=${relativePath}  -->
<!-- home=${home} -->
<!-- pom.name=${pom.name} -->

    <j:set var="borderColor">#FFFFFF</j:set>
    <j:set var="doOutline"><x:expr select="@outline"/></j:set>
      <j:if test="${doOutline != ''}">
        <j:set var="borderColor">#666666</j:set>
      </j:if>

      <table cellspacing="0" cellpadding="0" border="0">
        <tr>
          <td bgcolor="${borderColor}" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
          <td bgcolor="${borderColor}"           height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
          <td bgcolor="${borderColor}" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
        </tr>
        <tr>
          <td bgcolor="${borderColor}" width="1">
            <img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/>
          </td>
          <td bgcolor="#ffffff" height="1">

<!--  PRINT IMAGE TEMPLATE-  ONCE I FIGGER OUT HOW TO CALL A TEMPLATE...  THIS SHOULD BE EXTRACTED  -->
     
      <j:set var="comment"><x:expr select="@comment"/></j:set>
      <j:if test="${comment != ''}">
        <x:comment>${comment}</x:comment>
      </j:if>

      <j:set var="file"><x:expr select="@file"/></j:set>
      <j:set var="altText"><x:expr select="@alt-text"/></j:set>

      <j:set var="link"><x:expr select="@link"/></j:set>
      <j:if test="${link != ''}">
        <a href="${link}">
          <img src="${relativePath}/images/${file}" alt="${altText}" border="0"/>
        </a>
      </j:if>

      <j:if test="${link == ''}">
        <img src="${relativePath}/images/${file}" alt="${alt-text}" border="0"/>
      </j:if>

<!--  END PRINT IMAGE TEMPLATE -->          

          </td>
          <td bgcolor="${borderColor}" width="1">
            <img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/>
          </td>
        </tr>
        <tr>
            <td bgcolor="${borderColor}" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
            <td bgcolor="${borderColor}"           height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
            <td bgcolor="${borderColor}" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
        </tr>
    <j:set var="caption"><x:expr select="@caption"/></j:set>
      <j:if test="${caption != ''}">
          <tr>
            <td bgcolor="${borderColor}" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
            <td bgcolor="#ffffff" align="center"   height="1"><center><font size="-1"><i>${caption}</i></font></center></td>
            <td bgcolor="${borderColor}" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
          </tr>
          <tr>
            <td bgcolor="${borderColor}" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
            <td bgcolor="${borderColor}"           height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
            <td bgcolor="${borderColor}" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
          </tr>
      </j:if>
      </table>
  
</jsl:template>

<!-- I M A G E -->


  <jsl:template match="image" trim="false">

<!--  PRINT IMAGE TEMPLATE-  ONCE I FIGGER OUT HOW TO CALL A TEMPLATE...  THIS SHOULD BE EXTRACTED  -->
     
      <j:set var="comment"><x:expr select="@comment"/></j:set>
      <j:if test="${comment != ''}">
        <x:comment>${comment}</x:comment>
      </j:if>

      <j:set var="file"><x:expr select="@file"/></j:set>
      <j:set var="altText"><x:expr select="@alt-text"/></j:set>

      <j:set var="link"><x:expr select="@link"/></j:set>
      <j:if test="${link != ''}">
        <a href="${link}">
          <img src="${relativePath}/images/${file}" alt="${altText}" border="0"/>
        </a>
      </j:if>

      <j:if test="${link == ''}">
        <img src="${relativePath}/images/${file}" alt="${alt-text}" border="0"/>
      </j:if>

<!--  END PRINT IMAGE TEMPLATE -->          
  
</jsl:template>



More Stuff to Port to JSL


#match("*")

<!-- node.name() == $node.name() -->

#if ($node.name() == "source")
$context.applyTemplates("source");
#elseif ($node.name() == "image")
$context.applyTemplates("image");
#else
<$node.name()>
  $node.value()
$context.applyTemplates()
</$node.name()>#end
#end


#macro (printXML)
<link rel="stylesheet" type="text/css" href="xml-display.css"/>
#printChildren()
#end


#macro (printChildren)
printChildren: node.name=$node.name()

  #foreach( $child in $node.children() )
  test
    <div align="left" class="xml-display">
      <ul>
        #if ($child.children().size()>0 )
          #printTree()
        #elseif ($child.value == "")
          #printEmptyLeaf()
        #else
          #printLeaf()
        #end
      </ul>
    </div>
  #end

#end

#macro (printTree)
    PrintTree: $child.name()
#end

#macro (printEmptyLeaf)
    printEmptyLeaf: $child.name()
#end

#macro (printLeaf)
    printLeaf: $child.name()
#end