jon         01/03/11 20:45:02

  Added:       test/anakia .cvsignore
               test/anakia/compare index.html
               test/anakia/xdocs index.xml
               test/anakia/xdocs/stylesheets project.xml site.vsl
  Log:
  testing ground for anakia
  
  Revision  Changes    Path
  1.1                  jakarta-velocity/test/anakia/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  results
  
  
  
  1.1                  jakarta-velocity/test/anakia/compare/index.html
  
  Index: index.html
  ===================================================================
  <!-- Content Stylesheet for Site -->
  
          
  <!-- start the processing -->
      <!-- ====================================================================== -->
      <!-- Main Page Section -->
      <!-- ====================================================================== -->
      <html>
          <head>
              <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
  
                          
  <!--
                                      
              
              
                          
  -->
  
  
                          <meta name="author" value="Jon S. Stevens">
              <meta name="email" value="[EMAIL PROTECTED]">
  
              <title>The Jakarta Project</title>
          </head>
  
          <body bgcolor="#ffffff" text="#000000" link="#525D76">        
              <table border="1">
                  <tr>
                  <td>
                      
              <strong>Home</strong>
          <ul>
                      <li>    <a href="./index.html">Front Page</a>
  </li>
                  </ul>
              <strong>About</strong>
          <ul>
                      <li>    <a href="./about/index.html">About</a>
  </li>
                  </ul>
                      </td>
                  <td>
                  
                                                                                       
   <p>
  This is an example template that gets processed.
  </p>
                                                                                       
           <img src="./images/velocity.gif" width="329" height="105" align="">
                                                                                       
           <table border="1">
  <tr>
      <td>
          It even has a table in it!
      </td>
  </tr>
  </table>
                                                                                       
           <h3>And an h3 tag</h3>
                                                                                       
                                               <p> here is another section </p>
                                                                                       
                                               <p><a href="./about/index.html">A link 
to a sub page</a></p>
                                                                              </td>
                  </tr>
              </table>
          </body>
      </html>
  <!-- end the processing -->
  
  
  
  
  
  
  
  
  1.1                  jakarta-velocity/test/anakia/xdocs/index.xml
  
  Index: index.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  
  <document>
  
    <properties>
      <author email="[EMAIL PROTECTED]">Jon S. Stevens</author>
      <title>The Jakarta Project</title>
    </properties>
  
  <body>
  
    <section name="Section 1">
  
  <p>
  This is an example template that gets processed.
  </p>
  
  <img src="/images/velocity.gif" width="329" height="105"/>
  
  <table border="1">
  <tr>
      <td>
          It even has a table in it!
      </td>
  </tr>
  </table>
  
  <h3>And an h3 tag</h3>
  
    </section>
  
  
      <section name="Section 2">
  
      <p> here is another section </p>
      
      </section>
  
      <section name="section 3">
      
      <p><a href="./about/index.html">A link to a sub page</a></p>
  
      </section>
  
  </body>
  </document>
  
  
  1.1                  jakarta-velocity/test/anakia/xdocs/stylesheets/project.xml
  
  Index: project.xml
  ===================================================================
  <?xml version="1.0" encoding="ISO-8859-1"?>
  <project name="Jakarta Site"
          href="http://jakarta.apache.org/">
  
      <title>Jakarta Site</title>
  
      <body>
          <menu name="Home">
              <item name="Front Page"            href="/index.html"/>
          </menu>
      
          <menu name="About">
              <item name="About"                 href="/about/index.html"/>
          </menu>
      </body>
  </project>
  
  
  
  1.1                  jakarta-velocity/test/anakia/xdocs/stylesheets/site.vsl
  
  Index: site.vsl
  ===================================================================
  <!-- Content Stylesheet for Site -->
  
      ## Defined variables
      #set ($bodybg = "#ffffff")
      #set ($bodyfg = "#000000")
      #set ($bodylink = "#525D76")
      #set ($bannerbg = "#525D76")
      #set ($bannerfg = "#ffffff")
      #set ($tablethbg = "#039acc")
      #set ($tabletdbg = "#a0ddf0")
      
  <!-- start the processing -->
  #document()
  <!-- end the processing -->
  
  ## This is where the macro's live
  
  #macro ( makeProject )
      ##set ($menus = $project.getChild("body").getChildren("menu"))
      #set ($menus = $xpath.applyTo("body/menu", $project))
  
      #foreach ( $menu in $menus )
          <strong>$menu.getAttributeValue("name")</strong>
          <ul>
          #foreach ( $item in $menu.getChildren() )
              #set ($name = $item.getAttributeValue("name"))
              <li>#projectanchor($name $item.getAttributeValue("href"))</li>
          #end
          </ul>
      #end
  #end
  
  #macro ( image $value )
  #if ($value.getAttributeValue("width"))
  #set ($width=$value.getAttributeValue("width"))
  #end
  #if ($value.getAttributeValue("height"))
  #set ($height=$value.getAttributeValue("height"))
  #end
  #if ($value.getAttributeValue("align"))
  #set ($align=$value.getAttributeValue("align"))
  #end
  <img src="$relativePath$value.getAttributeValue("src")" width="$!width" 
height="$!height" align="$!align">
  #end
  
  #macro ( projectanchor $name $value )
      <a href="$relativePath$value">$name</a>
  #end
  #macro ( metaauthor $author $email )
              <meta name="author" value="$author">
              <meta name="email" value="$email">
  #end
  
  #macro (document)
      <!-- ====================================================================== -->
      <!-- Main Page Section -->
      <!-- ====================================================================== -->
      <html>
          <head>
              <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
  
              ##set ($au = $root.getChild("properties").getChild("author").getText())
              ##set ($em = 
$root.getChild("properties").getChild("author").getAttributeValue("email"))
  
  <!--
              ## For some reason, we can't .getText() and .getValue() directly in the
              ## set directive, but rather have to wait a moment, and do it in the
              ## metaauthor directive.
  
              #set ($au = $xpath.applyTo("properties/author", $root).get(0))
              #set ($em = $xpath.applyTo("properties/author/@email", $root).get(0))
  
              ## This should work, but doesn't
  
              ##set ($au = $xpath.applyTo("properties/author", $root).get(0).getText())
              ##set ($em = $xpath.applyTo("properties/author/@email", 
$root).get(0).getValue())
  
  -->
  
  
              #metaauthor ( $au.getText() $em.getValue() )
  
              <title>$root.getChild("properties").getChild("title").getText()</title>
          </head>
  
          <body bgcolor="$bodybg" text="$bodyfg" link="$bodylink">        
              <table border="1">
                  <tr>
                  <td>
                  #makeProject()
                  </td>
                  <td>
                  ##set ($allSections = $root.getChild("body").getChildren("section"))
                  #set ($allSections = $xpath.applyTo("body/section", $root))
  
                  #foreach ( $section in $allSections )
                      #foreach ( $item in $section.getChildren() )                
                          #if ($item.getName().equals("img"))
                              #image ($item)
                          #else
                              $xmlout.outputString($item)
                          #end
                      #end
                  #end
                  </td>
                  </tr>
              </table>
          </body>
      </html>
  #end
  
  
  

Reply via email to