You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cf...@apache.org on 2012/05/29 17:35:15 UTC
svn commit: r1343781 [2/17] - in /incubator/flex/trunk/modules: ./
thirdparty/velocity/ thirdparty/velocity/build/
thirdparty/velocity/build/lib/ thirdparty/velocity/build/xsl/
thirdparty/velocity/src/java/org/apache/velocity/anakia/
thirdparty/velocit...
Added: incubator/flex/trunk/modules/thirdparty/velocity/build/testcases.xml
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/build/testcases.xml?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/build/testcases.xml (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/build/testcases.xml Tue May 29 15:35:01 2012
@@ -0,0 +1,386 @@
+<?xml version="1.0"?>
+
+<!-- Testcases for Velocity -->
+<project name="main" default="test-all">
+
+ <property name="build.dir" value="../bin"/>
+ <property name="build.dest" value="${build.dir}/classes"/>
+ <property name="ant.home" value="."/>
+ <property name="test.home" value="../test"/>
+ <property name="junit.jar" value="lib/junit-3.7.jar"/>
+
+ <!-- JUnit Testbed properties -->
+ <property name="velocity.test.runner" value="junit.textui.TestRunner"/>
+
+ <!-- Turns on/off overall failure if one test fails -->
+ <property name="testbed.failonerror" value="true"/>
+
+ <!-- Build classpath -->
+ <path id="classpath">
+ <fileset dir="./lib">
+ <include name="**/*.jar"/>
+ </fileset>
+ <pathelement location="${build.dest}"/>
+ </path>
+
+ <!-- =================================================================== -->
+ <!-- JUnit Test Cases -->
+ <!-- =================================================================== -->
+ <target name="test-clean">
+ <!--
+ Hack to prevent Ant from complaining about missing directories.
+ This is fixed in Ant >1.3, but we are using Ant 1.3 now.
+ -->
+ <mkdir dir="${test.home}/anakia/results"/>
+ <mkdir dir="${test.home}/configuration/results"/>
+ <mkdir dir="${test.home}/cpload/results"/>
+ <mkdir dir="${test.home}/multi/results"/>
+ <mkdir dir="${test.home}/multiloader/results"/>
+ <mkdir dir="${test.home}/templates/results"/>
+ <mkdir dir="${test.home}/texen/results"/>
+ <!--
+ Delete the results directories
+ -->
+ <delete dir="${test.home}/anakia/results" quiet="true"/>
+ <delete dir="${test.home}/configuration/results" quiet="true"/>
+ <delete dir="${test.home}/cpload/results" quiet="true"/>
+ <delete dir="${test.home}/multi/results" quiet="true"/>
+ <delete dir="${test.home}/multiloader/results" quiet="true"/>
+ <delete dir="${test.home}/templates/results" quiet="true"/>
+ <delete dir="${test.home}/texen/results" quiet="true"/>
+ </target>
+
+ <target name="test-all" depends="
+ test-template,
+ test-velocityapp,
+ test-introspect,
+ test-introspect2,
+ test-classloaderchange,
+ test-inlinevmscope,
+ test-multi,
+ test-cpload,
+ test-contextsafety,
+ test-configuration,
+ test-commonsextprop,
+ test-externallogger,
+ test-methodinvocationexception,
+ test-multiloader,
+ test-encoding,
+ test-eventhandling,
+ test-velocimacro,
+ test-anakia,
+ test-texen,
+ test-texen-classpath,
+ test-misc,
+ test-servlet,
+ test-parser
+ "/>
+
+ <target name="test-template">
+ <echo message="Running Template tests..."/>
+
+ <java classname="${velocity.test.runner}" fork="yes"
+ failonerror="${testbed.failonerror}">
+ <arg value="org.apache.velocity.test.TemplateTestCase"/>
+ <classpath refid="classpath"/>
+ </java>
+ </target>
+
+ <target name="test-eventhandling">
+ <echo message="Running Event Handler tests..."/>
+
+ <java classname="${velocity.test.runner}" fork="yes" failonerror="${testbed.failonerror}">
+ <arg value="org.apache.velocity.test.EventHandlingTestCase"/>
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="test-encoding">
+ <echo message="Running Template encoding test..."/>
+
+ <java classname="${velocity.test.runner}" fork="yes" failonerror="${testbed.failonerror}">
+ <arg value="org.apache.velocity.test.EncodingTestCase"/>
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="test-velocityapp">
+ <echo message="Running app.Velocity tests..."/>
+
+ <java classname="${velocity.test.runner}" fork="yes" failonerror="${testbed.failonerror}">
+ <arg value="org.apache.velocity.test.VelocityAppTestCase"/>
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="test-introspect">
+ <echo message="Running Introspector tests..."/>
+
+ <java classname="${velocity.test.runner}" fork="yes" failonerror="${testbed.failonerror}">
+ <arg value="org.apache.velocity.test.IntrospectorTestCase"/>
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="test-introspect2">
+ <echo message="Running Introspector2 tests..."/>
+
+ <java classname="${velocity.test.runner}" fork="yes" failonerror="${testbed.failonerror}">
+ <arg value="org.apache.velocity.test.IntrospectorTestCase2"/>
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="test-classloaderchange">
+ <java classname="${velocity.test.runner}" fork="yes" failonerror="${testbed.failonerror}" >
+ <arg value="org.apache.velocity.test.ClassloaderChangeTest"/>
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="test-inlinevmscope">
+ <echo message="Running Inline VM Scope tests..."/>
+
+ <java classname="${velocity.test.runner}" fork="yes" failonerror="${testbed.failonerror}" >
+ <arg value="org.apache.velocity.test.InlineScopeVMTestCase"/>
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="test-multi">
+ <echo message="Running Multiple File Resource Path tests..."/>
+
+ <java classname="${velocity.test.runner}" fork="yes" failonerror="${testbed.failonerror}">
+ <arg value="org.apache.velocity.test.MultipleFileResourcePathTest"/>
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="test-cpload">
+ <echo message="Running Classpath Resource tests..."/>
+
+ <java classname="${velocity.test.runner}" fork="yes" failonerror="${testbed.failonerror}">
+ <arg value="org.apache.velocity.test.ClasspathResourceTest"/>
+ <classpath>
+ <path refid="classpath"/>
+ <pathelement location="../test/cpload/test1.jar"/>
+ <pathelement location="../test/cpload/test2.jar"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="test-contextsafety">
+ <echo message="Running Context Safety tests..."/>
+
+ <java classname="${velocity.test.runner}" fork="yes" failonerror="${testbed.failonerror}">
+ <arg value="org.apache.velocity.test.ContextSafetyTestCase"/>
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="test-anakia">
+ <echo message="Running Anakia tests..."/>
+
+ <taskdef name="anakia" classname="org.apache.velocity.anakia.AnakiaTask">
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+ </taskdef>
+ <anakia basedir="../test/anakia/xdocs" destdir="../test/anakia/results"
+ extension=".html" style="./site.vsl"
+ projectFile="./stylesheets/project.xml"
+ excludes="**/stylesheets/**"
+ includes="**/*.xml"
+ templatePath="../test/anakia/xdocs/stylesheets"
+ lastModifiedCheck="false">
+ </anakia>
+
+ <java classname="${velocity.test.runner}" fork="yes" failonerror="${testbed.failonerror}" >
+ <arg value="org.apache.velocity.test.AnakiaTestCase"/>
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="test-configuration">
+ <java classname="${velocity.test.runner}" fork="yes" failonerror="${testbed.failonerror}" >
+ <arg value="org.apache.velocity.test.ConfigurationTestCase"/>
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="test-commonsextprop">
+ <java classname="${velocity.test.runner}" fork="yes" failonerror="${testbed.failonerror}" >
+ <arg value="org.apache.velocity.test.CommonsExtPropTestCase"/>
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="test-externallogger">
+ <echo message="Running external logger tests..."/>
+
+ <java classname="${velocity.test.runner}" fork="yes" failonerror="${testbed.failonerror}">
+ <arg value="org.apache.velocity.test.ExternalLoggerTest"/>
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+ </java>
+ </target>
+
+
+ <target name="test-methodinvocationexception">
+ <echo message="Running MethodInvocationException tests..."/>
+
+ <java classname="${velocity.test.runner}" fork="yes" failonerror="${testbed.failonerror}">
+ <arg value="org.apache.velocity.test.MethodInvocationExceptionTest"/>
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="test-misc">
+ <echo message="Running misc tests..."/>
+
+ <java classname="${velocity.test.runner}" fork="yes" failonerror="${testbed.failonerror}">
+ <arg value="org.apache.velocity.test.MiscTestCase"/>
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="test-parser">
+ <echo message="Running special parser tests..."/>
+
+ <java classname="${velocity.test.runner}" fork="yes" failonerror="${testbed.failonerror}">
+ <arg value="org.apache.velocity.test.ParserTestCase"/>
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="test-servlet">
+ <echo message="Running VelocityServlet tests..."/>
+
+ <java classname="${velocity.test.runner}" fork="yes" failonerror="${testbed.failonerror}">
+ <arg value="org.apache.velocity.test.VelocityServletTest"/>
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+ </java>
+ </target>
+
+ <!-- ================================================================ -->
+ <!-- T E X E N T E S T -->
+ <!-- ================================================================ -->
+ <!-- Generate turbine service code via Texen -->
+ <!-- ================================================================ -->
+
+ <target name="test-texen">
+
+ <taskdef name="texen" classname="org.apache.velocity.texen.ant.TexenTask">
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+ </taskdef>
+
+ <texen
+ contextProperties="../test/texen/service.props,../test/texen/additional.props"
+ controlTemplate="Control.vm"
+ outputDirectory="../test/texen/results"
+ templatePath="../test/texen/templates"
+ outputFile="report"
+ />
+
+ <java classname="${velocity.test.runner}" fork="yes" failonerror="${testbed.failonerror}">
+ <arg value="org.apache.velocity.test.TexenTestCase"/>
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+ </java>
+
+ </target>
+
+ <!-- ================================================================ -->
+ <!-- T E X E N C L A S S P A T H -->
+ <!-- ================================================================ -->
+ <!-- Generate turbine service code via Texen with all the templates -->
+ <!-- and ancillary files in a JAR. -->
+ <!-- ================================================================ -->
+
+ <target name="test-texen-classpath">
+
+ <taskdef name="texen" classname="org.apache.velocity.texen.ant.TexenTask"
+ reverseloader="true">
+ <classpath>
+ <pathelement location="../test/texen-classpath/test.jar"/>
+ <path refid="classpath"/>
+ </classpath>
+ </taskdef>
+
+ <texen
+ useClassPath="true"
+ contextProperties="service.props"
+ controlTemplate="Control.vm"
+ outputDirectory="../test/texen-classpath/results"
+ outputFile="report"
+ />
+
+ <java classname="${velocity.test.runner}" fork="yes" failonerror="${testbed.failonerror}">
+ <arg value="org.apache.velocity.test.TexenClasspathTestCase"/>
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+ </java>
+
+ </target>
+
+ <target name="test-multiloader">
+ <echo message="Running MultiLoader tests..."/>
+
+ <java classname="${velocity.test.runner}" fork="yes" failonerror="${testbed.failonerror}">
+ <arg value="org.apache.velocity.test.MultiLoaderTestCase"/>
+ <classpath>
+ <path refid="classpath"/>
+ <pathelement location="../test/multiloader/test1.jar"/>
+ </classpath>
+ </java>
+ </target>
+
+ <target name="test-velocimacro">
+ <echo message="Running Velocimacro tests..."/>
+ <java classname="${velocity.test.runner}" fork="yes" failonerror="${testbed.failonerror}">
+ <arg value="org.apache.velocity.test.VelocimacroTestCase"/>
+ <classpath>
+ <path refid="classpath"/>
+ </classpath>
+ </java>
+ </target>
+
+</project>
+
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/build/testcases.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/build/xsl/xml2pdf.xsl
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/build/xsl/xml2pdf.xsl?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/build/xsl/xml2pdf.xsl (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/build/xsl/xml2pdf.xsl Tue May 29 15:35:01 2012
@@ -0,0 +1,415 @@
+<?xml version="1.0"?>
+
+<!-- XSLT stylesheet to convert the Fop documentation collected in one xml file into a fo file
+ for use in FOP
+
+TBD: - The faq doesn't show in the content
+ - check why margin-bottom on the page with properties is too large
+ - check why keep-next not only doesn't work, but leads to repeating already printed lines
+ - make lines containing only code look nicer (smaller line height)
+ - replace bullets in ordered lists with numbers
+ - correct the hack replacing nbsp with '-'
+ - handle the links correctly which have been external in the html doc and are now internal
+
+-->
+
+<xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format">
+
+<xsl:template match ="/">
+ <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+
+ <!-- defines page layout -->
+
+ <fo:layout-master-set>
+
+ <fo:simple-page-master master-name="first"
+ page-height="29.7cm"
+ page-width="21cm"
+ margin-top="1.5cm"
+ margin-bottom="2cm"
+ margin-left="2.5cm"
+ margin-right="2.5cm">
+
+ <fo:region-body margin-top="3cm"/>
+ <fo:region-before extent="1.5cm"/>
+ <fo:region-after extent="1.5cm"/>
+ </fo:simple-page-master>
+
+ <fo:simple-page-master master-name="rest"
+ page-height="29.7cm"
+ page-width="21cm"
+ margin-top="1.5cm"
+ margin-bottom="2cm"
+ margin-left="2.5cm"
+ margin-right="2.5cm">
+
+ <fo:region-body margin-top="2.5cm"/>
+ <fo:region-before extent="1.5cm"/>
+ <fo:region-after extent="1.5cm"/>
+ </fo:simple-page-master>
+
+ <fo:page-sequence-master master-name="all">
+ <fo:single-page-master-reference master-name="first"/>
+ <fo:repeatable-page-master-reference master-name="rest"/>
+ </fo:page-sequence-master>
+
+ </fo:layout-master-set>
+
+ <fo:page-sequence master-name="all">
+ <fo:static-content flow-name="xsl-region-before">
+ <fo:block text-align="end"
+ font-size="10pt"
+ font-family="serif"
+ line-height="14pt" >
+
+ Velocity User's Guide - pg
+
+ <fo:page-number/>
+ </fo:block>
+ </fo:static-content>
+
+ <fo:flow flow-name="xsl-region-body">
+
+ <fo:block font-size="18pt"
+ font-family="sans-serif"
+ line-height="24pt"
+ space-after.optimum="15pt"
+ background-color="blue"
+ color="white"
+ text-align="center">
+ Velocity
+ </fo:block>
+
+
+ <!-- generates table of contents and puts it into a table -->
+
+ <fo:block font-size="14pt"
+ font-family="sans-serif"
+ line-height="18pt"
+ space-after.optimum="10pt"
+ font-weight="bold"
+ start-indent="15pt">
+ Content
+ </fo:block>
+
+ <fo:table>
+ <fo:table-column column-width="1cm"/>
+ <fo:table-column column-width="15cm"/>
+ <fo:table-body font-size="12pt"
+ line-height="16pt"
+ font-family="sans-serif">
+
+ <xsl:for-each select="//document">
+ <fo:table-row>
+ <fo:table-cell/>
+ <fo:table-cell>
+ <fo:block text-align="start" >
+ <xsl:value-of select="header/title"/>
+ </fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ <xsl:call-template name="content">
+ <xsl:with-param name="doc" select="body"/>
+ </xsl:call-template>
+ </xsl:for-each>
+ </fo:table-body>
+ </fo:table>
+ <xsl:apply-templates select="documentation"/>
+ </fo:flow>
+ </fo:page-sequence>
+ </fo:root>
+</xsl:template>
+
+<!-- s1 -->
+<xsl:template match ="s1">
+ <fo:block font-size="18pt"
+ font-family="sans-serif"
+ line-height="24pt"
+ space-before.optimum="15pt"
+ space-after.optimum="15pt"
+ background-color="blue"
+ color="white"
+ text-align="center">
+
+ <xsl:attribute name="id">
+ <xsl:value-of select="translate(.,' ),-.(','____')"/>
+ </xsl:attribute>
+
+ <xsl:value-of select="@title"/>
+ </fo:block>
+ <xsl:apply-templates/>
+</xsl:template>
+
+<!-- s2 -->
+<xsl:template match ="s2">
+ <fo:block font-size="16pt"
+ font-family="sans-serif"
+ line-height="20pt"
+ space-before.optimum="15pt"
+ space-after.optimum="12pt"
+ text-align="center"
+ padding-top="3pt">
+
+ <xsl:value-of select="@title"/>
+
+ </fo:block>
+ <xsl:apply-templates/>
+</xsl:template>
+
+<!-- s3 -->
+<xsl:template match ="s3">
+ <fo:block font-size="14pt"
+ font-family="sans-serif"
+ line-height="18pt"
+ space-before.optimum="10pt"
+ space-after.optimum="9pt"
+ text-align="center"
+ padding-top="3pt">
+
+ <xsl:value-of select="@title"/>
+
+ </fo:block>
+ <xsl:apply-templates/>
+</xsl:template>
+
+<!-- p [not(code)] -->
+<xsl:template match ="p">
+ <fo:block font-size="11pt"
+ font-family="sans-serif"
+ line-height="13pt"
+ space-after.optimum="3pt"
+ space-before.optimum="3pt"
+ text-align="justify">
+
+ <xsl:apply-templates/>
+
+ </fo:block>
+</xsl:template>
+
+<!-- p + code
+<xsl:template match ="p[code]">
+ <fo:block font-size="11pt"
+ font-family="sans-serif"
+ line-height="11pt"
+ space-after.optimum="0pt"
+ space-before.optimum="0pt"
+ text-align="start">
+
+ <xsl:apply-templates/>
+
+ </fo:block>
+</xsl:template>
+-->
+
+<!-- faqs -->
+<xsl:template match ="faqs">
+ <fo:block font-size="18pt"
+ font-family="sans-serif"
+ line-height="24pt"
+ space-before.optimum="15pt"
+ space-after.optimum="15pt"
+ background-color="blue"
+ color="white"
+ text-align="center">
+
+ <xsl:attribute name="id">
+ <xsl:value-of select="translate(.,' ),-.(','____')"/>
+ </xsl:attribute>
+
+ <xsl:value-of select="@title"/>
+
+ </fo:block>
+ <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match ="strong">
+ <fo:block font-size="12pt"
+ font-family="sans-serif"
+ line-height="14pt"
+ space-after.optimum="3pt"
+ space-before.optimum="3pt"
+ text-align="start"
+ font-weight="bold">
+
+ <xsl:apply-templates/>
+
+ </fo:block>
+</xsl:template>
+
+<!-- faq -->
+<xsl:template match ="faq">
+ <xsl:apply-templates/>
+</xsl:template>
+
+<!-- q in faq -->
+<xsl:template match ="q">
+ <fo:block font-size="11pt"
+ font-family="sans-serif"
+ line-height="13pt"
+ space-after.optimum="3pt"
+ space-before.optimum="3pt"
+ text-align="justify">
+
+ <xsl:apply-templates/>
+
+ </fo:block>
+</xsl:template>
+
+<!-- a in faq -->
+<xsl:template match ="a">
+ <xsl:apply-templates/>
+</xsl:template>
+
+
+<!-- jump (links) -->
+<xsl:template match ="*/jump">
+ <fo:simple-link color="blue" external-destination="{@href}">
+ <xsl:apply-templates/>
+ </fo:simple-link>
+</xsl:template>
+
+
+<!-- code
+<xsl:template match ="*/code">
+ <fo:inline font-size="10pt"
+ font-family="Courier">
+ <xsl:apply-templates/>
+ </fo:inline>
+</xsl:template>
+-->
+
+<xsl:template match ="*/source">
+ <fo:inline font-size="10pt"
+ font-family="Courier"
+ white-space-treatment="preserve">
+ <xsl:apply-templates/>
+ </fo:inline>
+</xsl:template>
+
+<!-- p + source -->
+<xsl:template match ="p[source]">
+ <fo:block font-size="11pt"
+ font-family="sans-serif"
+ line-height="12pt"
+ space-after.optimum="0pt"
+ space-before.optimum="0pt"
+ text-align="start">
+ <xsl:apply-templates/>
+ </fo:block>
+</xsl:template>
+
+
+
+<!-- ul (unordered list) -->
+<xsl:template match ="ul">
+ <fo:list-block start-indent="1cm"
+ provisional-distance-between-starts="12pt"
+ font-family="sans-serif"
+ font-size="11pt"
+ line-height="11pt">
+ <xsl:apply-templates/>
+ </fo:list-block>
+</xsl:template>
+
+
+<!-- ol (ordered list) -->
+<xsl:template match ="ol">
+ <fo:list-block start-indent="1cm"
+ provisional-distance-between-starts="12pt"
+ font-family="sans-serif"
+ font-size="11pt"
+ line-height="11pt">
+ <xsl:apply-templates/>
+ </fo:list-block>
+</xsl:template>
+
+
+<!-- li (list item) in unordered list -->
+<xsl:template match ="ul/li">
+ <fo:list-item>
+ <fo:list-item-label>
+ <fo:block><fo:inline font-family="Symbol">·</fo:inline></fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body>
+ <fo:block space-after.optimum="4pt"
+ text-align="justify"
+ padding-top="3pt">
+ <xsl:apply-templates/>
+ </fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+</xsl:template>
+
+
+<!-- li (list item) in ordered list -->
+<xsl:template match ="ol/li">
+ <fo:list-item>
+ <fo:list-item-label>
+ <fo:block>
+ <xsl:number level="multiple" count="li" format="1"/>)
+ </fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body>
+ <fo:block space-after.optimum="4pt"
+ text-align="justify"
+ padding-top="3pt">
+ <xsl:apply-templates/>
+ </fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+</xsl:template>
+
+<xsl:template match="table">
+ <fo:table>
+ <xsl:for-each select="tr[1]/td">
+ <fo:table-column column-width="1.7in"/>
+ </xsl:for-each>
+ <fo:table-body font-size="10pt"
+ line-height="14pt"
+ font-family="sans-serif"
+ background-color="#a0ddf0">
+
+ <xsl:for-each select="tr">
+ <fo:table-row>
+ <xsl:for-each select="td">
+ <fo:table-cell>
+ <fo:block text-align="start" >
+ <xsl:value-of select="."/>
+ </fo:block>
+ </fo:table-cell>
+ </xsl:for-each>
+ </fo:table-row>
+ </xsl:for-each>
+ </fo:table-body>
+ </fo:table>
+</xsl:template>
+
+<xsl:template name="content">
+ <xsl:param name="doc"/>
+ <xsl:param name="prefix">...</xsl:param>
+ <xsl:for-each select="$doc/s1">
+ <fo:table-row>
+ <fo:table-cell/>
+ <fo:table-cell>
+ <fo:block text-align="start" font-size="10pt">
+ <fo:simple-link color="blue">
+ <xsl:attribute name="internal-destination">
+ <xsl:value-of select="translate(.,' ),-.(','____')"/>
+ </xsl:attribute>
+ <xsl:value-of select="$prefix"/>
+ <xsl:value-of select="@title"/>
+ </fo:simple-link>
+ </fo:block>
+ </fo:table-cell>
+ </fo:table-row>
+ <xsl:call-template name="content">
+ <xsl:with-param name="doc" select="."/>
+ <xsl:with-param name="prefix" select="concat($prefix,'...')"/>
+ </xsl:call-template>
+ </xsl:for-each>
+</xsl:template>
+<!-- end body -->
+
+</xsl:stylesheet>
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/build/xsl/xml2pdf.xsl
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/build/xsl/xml2xml.xsl
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/build/xsl/xml2xml.xsl?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/build/xsl/xml2xml.xsl (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/build/xsl/xml2xml.xsl Tue May 29 15:35:01 2012
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+<xsl:template match ="/">
+ <documentation>
+ <xsl:copy-of select="document('../../xdocs/index.xml')"/>
+ <xsl:copy-of select="document('../../xdocs/getting-started.xml')"/>
+ <xsl:copy-of select="document('../../xdocs/install.xml')"/>
+ <xsl:copy-of select="document('../../xdocs/design.xml')"/>
+ <xsl:copy-of select="document('../../xdocs/contributors.xml')"/>
+ <xsl:copy-of select="document('../../xdocs/code-standards.xml')"/>
+ <xsl:copy-of select="document('../../xdocs/license.xml')"/>
+ <xsl:copy-of select="document('../../xdocs/todo.xml')"/>
+ <xsl:copy-of select="document('../../xdocs/user-guide.xml')"/>
+ <xsl:copy-of select="document('../../xdocs/developer-guide.xml')"/>
+ </documentation>
+</xsl:template>
+
+</xsl:stylesheet>
+
+
+
+
+
+
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/build/xsl/xml2xml.xsl
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/AnakiaElement.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/AnakiaElement.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/AnakiaElement.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/AnakiaElement.java Tue May 29 15:35:01 2012
@@ -0,0 +1,246 @@
+package org.apache.velocity.anakia;
+
+/*
+ * Copyright 2001,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.jdom.Element;
+import org.jdom.Namespace;
+import org.jdom.output.XMLOutputter;
+import java.util.List;
+
+/**
+ * A JDOM {@link Element} that is tailored for Anakia needs. It has
+ * {@link #selectNodes(String)} method as well as a {@link #toString()} that
+ * outputs the XML serialized form of the element. This way it acts in much the
+ * same way as a single-element {@link NodeList} would.
+ *
+ * @author <a href="mailto:szegedia@freemail.hu">Attila Szegedi</a>
+ * @version $Id: AnakiaElement.java,v 1.3.4.1 2004/03/03 23:22:03 geirm Exp $
+ */
+public class AnakiaElement extends Element
+{
+ private static final XMLOutputter DEFAULT_OUTPUTTER = new XMLOutputter();
+
+ /**
+ * <p>
+ * This will create a new <code>AnakiaElement</code>
+ * with the supplied (local) name, and define
+ * the <code>{@link Namespace}</code> to be used.
+ * If the provided namespace is null, the element will have
+ * no namespace.
+ * </p>
+ *
+ * @param name <code>String</code> name of element.
+ * @namespace <code>Namespace</code> to put element in.
+ */
+ public AnakiaElement(String name, Namespace namespace)
+ {
+ super(name, namespace);
+ }
+
+ /**
+ * <p>
+ * This will create an <code>AnakiaElement</code> in no
+ * <code>{@link Namespace}</code>.
+ * </p>
+ *
+ * @param name <code>String</code> name of element.
+ */
+ public AnakiaElement(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * <p>
+ * This will create a new <code>AnakiaElement</code> with
+ * the supplied (local) name, and specifies the URI
+ * of the <code>{@link Namespace}</code> the <code>Element</code>
+ * should be in, resulting it being unprefixed (in the default
+ * namespace).
+ * </p>
+ *
+ * @param name <code>String</code> name of element.
+ * @param uri <code>String</code> URI for <code>Namespace</code> element
+ * should be in.
+ */
+ public AnakiaElement(String name, String uri)
+ {
+ super(name, uri);
+ }
+
+ /**
+ * <p>
+ * This will create a new <code>AnakiaElement</code> with
+ * the supplied (local) name, and specifies the prefix and URI
+ * of the <code>{@link Namespace}</code> the <code>Element</code>
+ * should be in.
+ * </p>
+ *
+ * @param name <code>String</code> name of element.
+ * @param uri <code>String</code> URI for <code>Namespace</code> element
+ * should be in.
+ */
+ public AnakiaElement(String name, String prefix, String uri)
+ {
+ super(name, prefix, uri);
+ }
+
+ /**
+ * Applies an XPath expression to this element and returns the resulting
+ * node list. In order for this method to work, your application must have
+ * access to <a href="http://code.werken.com">werken.xpath</a> library
+ * classes. The implementation does cache the parsed format of XPath
+ * expressions in a weak hash map, keyed by the string representation of
+ * the XPath expression. As the string object passed as the argument is
+ * usually kept in the parsed template, this ensures that each XPath
+ * expression is parsed only once during the lifetime of the template that
+ * first invoked it.
+ * @param xpathExpression the XPath expression you wish to apply
+ * @return a NodeList representing the nodes that are the result of
+ * application of the XPath to the current element. It can be empty.
+ */
+ public NodeList selectNodes(String xpathExpression)
+ {
+ return new NodeList(XPathCache.getXPath(xpathExpression).applyTo(this), false);
+ }
+
+ /**
+ * Returns the XML serialized form of this element, as produced by the default
+ * {@link XMLOutputter}.
+ */
+ public String toString()
+ {
+ return DEFAULT_OUTPUTTER.outputString(this);
+ }
+
+ /**
+ * <p>
+ * This returns the full content of the element as a NodeList which
+ * may contain objects of type <code>String</code>, <code>Element</code>,
+ * <code>Comment</code>, <code>ProcessingInstruction</code>,
+ * <code>CDATA</code>, and <code>EntityRef</code>.
+ * The List returned is "live" in document order and modifications
+ * to it affect the element's actual contents. Whitespace content is
+ * returned in its entirety.
+ * </p>
+ *
+ * @return a <code>List</code> containing the mixed content of the
+ * element: may contain <code>String</code>,
+ * <code>{@link Element}</code>, <code>{@link Comment}</code>,
+ * <code>{@link ProcessingInstruction}</code>,
+ * <code>{@link CDATA}</code>, and
+ * <code>{@link EntityRef}</code> objects.
+ */
+ public List getContent()
+ {
+ return new NodeList(super.getContent(), false);
+ }
+
+ /**
+ * <p>
+ * This returns a <code>NodeList</code> of all the child elements
+ * nested directly (one level deep) within this element, as
+ * <code>Element</code> objects. If this target element has no nested
+ * elements, an empty List is returned. The returned list is "live"
+ * in document order and changes to it affect the element's actual
+ * contents.
+ * </p>
+ * <p>
+ * This performs no recursion, so elements nested two levels
+ * deep would have to be obtained with:
+ * <pre>
+ * <code>
+ * Iterator itr = currentElement.getChildren().iterator();
+ * while (itr.hasNext()) {
+ * Element oneLevelDeep = (Element)nestedElements.next();
+ * List twoLevelsDeep = oneLevelDeep.getChildren();
+ * // Do something with these children
+ * }
+ * </code>
+ * </pre>
+ * </p>
+ *
+ * @return list of child <code>Element</code> objects for this element
+ */
+ public List getChildren()
+ {
+ return new NodeList(super.getChildren(), false);
+ }
+
+ /**
+ * <p>
+ * This returns a <code>NodeList</code> of all the child elements
+ * nested directly (one level deep) within this element with the given
+ * local name and belonging to no namespace, returned as
+ * <code>Element</code> objects. If this target element has no nested
+ * elements with the given name outside a namespace, an empty List
+ * is returned. The returned list is "live" in document order
+ * and changes to it affect the element's actual contents.
+ * </p>
+ * <p>
+ * Please see the notes for <code>{@link #getChildren}</code>
+ * for a code example.
+ * </p>
+ *
+ * @param name local name for the children to match
+ * @return all matching child elements
+ */
+ public List getChildren(String name)
+ {
+ return new NodeList(super.getChildren(name));
+ }
+
+ /**
+ * <p>
+ * This returns a <code>NodeList</code> of all the child elements
+ * nested directly (one level deep) within this element with the given
+ * local name and belonging to the given Namespace, returned as
+ * <code>Element</code> objects. If this target element has no nested
+ * elements with the given name in the given Namespace, an empty List
+ * is returned. The returned list is "live" in document order
+ * and changes to it affect the element's actual contents.
+ * </p>
+ * <p>
+ * Please see the notes for <code>{@link #getChildren}</code>
+ * for a code example.
+ * </p>
+ *
+ * @param name local name for the children to match
+ * @param ns <code>Namespace</code> to search within
+ * @return all matching child elements
+ */
+ public List getChildren(String name, Namespace ns)
+ {
+ return new NodeList(super.getChildren(name, ns));
+ }
+
+ /**
+ * <p>
+ * This returns the complete set of attributes for this element, as a
+ * <code>NodeList</code> of <code>Attribute</code> objects in no particular
+ * order, or an empty list if there are none.
+ * The returned list is "live" and changes to it affect the
+ * element's actual attributes.
+ * </p>
+ *
+ * @return attributes for the element
+ */
+ public List getAttributes()
+ {
+ return new NodeList(super.getAttributes());
+ }
+}
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/AnakiaElement.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/AnakiaJDOMFactory.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/AnakiaJDOMFactory.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/AnakiaJDOMFactory.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/AnakiaJDOMFactory.java Tue May 29 15:35:01 2012
@@ -0,0 +1,55 @@
+package org.apache.velocity.anakia;
+
+/*
+ * Copyright 2001,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.jdom.Element;
+import org.jdom.Namespace;
+import org.jdom.input.DefaultJDOMFactory;
+
+/**
+ * A customized JDOMFactory for Anakia that produces {@link AnakiaElement}
+ * instances instead of ordinary JDOM {@link Element} instances.
+ *
+ * @author <a href="mailto:szegedia@freemail.hu">Attila Szegedi</a>
+ * @version $Id: AnakiaJDOMFactory.java,v 1.2.8.1 2004/03/03 23:22:04 geirm Exp $
+ */
+public class AnakiaJDOMFactory extends DefaultJDOMFactory
+{
+ public AnakiaJDOMFactory()
+ {
+ }
+
+ public Element element(String name, Namespace namespace)
+ {
+ return new AnakiaElement(name, namespace);
+ }
+
+ public Element element(String name)
+ {
+ return new AnakiaElement(name);
+ }
+
+ public Element element(String name, String uri)
+ {
+ return new AnakiaElement(name, uri);
+ }
+
+ public Element element(String name, String prefix, String uri)
+ {
+ return new AnakiaElement(name, prefix, uri);
+ }
+}
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/AnakiaJDOMFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/AnakiaTask.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/AnakiaTask.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/AnakiaTask.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/AnakiaTask.java Tue May 29 15:35:01 2012
@@ -0,0 +1,470 @@
+package org.apache.velocity.anakia;
+
+/*
+ * Copyright 2001,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+
+import java.util.StringTokenizer;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.MatchingTask;
+
+import org.xml.sax.SAXParseException;
+
+import org.jdom.Document;
+import org.jdom.JDOMException;
+import org.jdom.input.SAXBuilder;
+
+import org.apache.velocity.Template;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.RuntimeConstants;
+import org.apache.velocity.util.StringUtils;
+
+import org.apache.velocity.VelocityContext;
+
+/**
+ * The purpose of this Ant Task is to allow you to use
+ * Velocity as an XML transformation tool like XSLT is.
+ * So, instead of using XSLT, you will be able to use this
+ * class instead to do your transformations. It works very
+ * similar in concept to Ant's <style> task.
+ * <p>
+ * You can find more documentation about this class on the
+ * Velocity
+ * <a href="http://jakarta.apache.org/velocity/anakia.html">Website</a>.
+ *
+ * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
+ * @author <a href="mailto:szegedia@freemail.hu">Attila Szegedi</a>
+ * @version $Id: AnakiaTask.java,v 1.34.4.1 2004/03/03 23:22:04 geirm Exp $
+ */
+public class AnakiaTask extends MatchingTask
+{
+ /** <code>{@link SAXBuilder}</code> instance to use */
+ private SAXBuilder builder;
+
+ /** the destination directory */
+ private File destDir = null;
+
+ /** the base directory */
+ private File baseDir = null;
+
+ /** the style= attribute */
+ private String style = null;
+
+ /** the File to the style file */
+ private File styleFile = null;
+
+ /** last modified of the style sheet */
+ private long styleSheetLastModified = 0;
+
+ /** the projectFile= attribute */
+ private String projectAttribute = null;
+
+ /** the File for the project.xml file */
+ private File projectFile = null;
+
+ /** last modified of the project file if it exists */
+ private long projectFileLastModified = 0;
+
+ /** check the last modified date on files. defaults to true */
+ private boolean lastModifiedCheck = true;
+
+ /** the default output extension is .html */
+ private String extension = ".html";
+
+ /** the template path */
+ private String templatePath = null;
+
+ /** the file to get the velocity properties file */
+ private File velocityPropertiesFile = null;
+
+ /** the VelocityEngine instance to use */
+ private VelocityEngine ve = new VelocityEngine();
+
+ /**
+ * Constructor creates the SAXBuilder.
+ */
+ public AnakiaTask()
+ {
+ builder = new SAXBuilder();
+ builder.setFactory(new AnakiaJDOMFactory());
+ }
+
+ /**
+ * Set the base directory.
+ */
+ public void setBasedir(File dir)
+ {
+ baseDir = dir;
+ }
+
+ /**
+ * Set the destination directory into which the VSL result
+ * files should be copied to
+ * @param dirName the name of the destination directory
+ */
+ public void setDestdir(File dir)
+ {
+ destDir = dir;
+ }
+
+ /**
+ * Allow people to set the default output file extension
+ */
+ public void setExtension(String extension)
+ {
+ this.extension = extension;
+ }
+
+ /**
+ * Allow people to set the path to the .vsl file
+ */
+ public void setStyle(String style)
+ {
+ this.style = style;
+ }
+
+ /**
+ * Allow people to set the path to the project.xml file
+ */
+ public void setProjectFile(String projectAttribute)
+ {
+ this.projectAttribute = projectAttribute;
+ }
+
+ /**
+ * Set the path to the templates.
+ * The way it works is this:
+ * If you have a Velocity.properties file defined, this method
+ * will <strong>override</strong> whatever is set in the
+ * Velocity.properties file. This allows one to not have to define
+ * a Velocity.properties file, therefore using Velocity's defaults
+ * only.
+ */
+
+ public void setTemplatePath(File templatePath)
+ {
+ try
+ {
+ this.templatePath = templatePath.getCanonicalPath();
+ }
+ catch (java.io.IOException ioe)
+ {
+ throw new BuildException(ioe);
+ }
+ }
+
+ /**
+ * Allow people to set the path to the velocity.properties file
+ * This file is found relative to the path where the JVM was run.
+ * For example, if build.sh was executed in the ./build directory,
+ * then the path would be relative to this directory.
+ * This is optional based on the setting of setTemplatePath().
+ */
+ public void setVelocityPropertiesFile(File velocityPropertiesFile)
+ {
+ this.velocityPropertiesFile = velocityPropertiesFile;
+ }
+
+ /**
+ * Turn on/off last modified checking. by default, it is on.
+ */
+ public void setLastModifiedCheck(String lastmod)
+ {
+ if (lastmod.equalsIgnoreCase("false") || lastmod.equalsIgnoreCase("no")
+ || lastmod.equalsIgnoreCase("off"))
+ {
+ this.lastModifiedCheck = false;
+ }
+ }
+
+ /**
+ * Main body of the application
+ */
+ public void execute () throws BuildException
+ {
+ DirectoryScanner scanner;
+ String[] list;
+ String[] dirs;
+
+ if (baseDir == null)
+ {
+ baseDir = project.resolveFile(".");
+ }
+ if (destDir == null )
+ {
+ String msg = "destdir attribute must be set!";
+ throw new BuildException(msg);
+ }
+ if (style == null)
+ {
+ throw new BuildException("style attribute must be set!");
+ }
+
+ if (velocityPropertiesFile == null)
+ {
+ velocityPropertiesFile = new File("velocity.properties");
+ }
+
+ /*
+ * If the props file doesn't exist AND a templatePath hasn't
+ * been defined, then throw the exception.
+ */
+ if ( !velocityPropertiesFile.exists() && templatePath == null )
+ {
+ throw new BuildException ("No template path and could not " +
+ "locate velocity.properties file: " +
+ velocityPropertiesFile.getAbsolutePath());
+ }
+
+ log("Transforming into: " + destDir.getAbsolutePath(), Project.MSG_INFO);
+
+ // projectFile relative to baseDir
+ if (projectAttribute != null && projectAttribute.length() > 0)
+ {
+ projectFile = new File(baseDir, projectAttribute);
+ if (projectFile.exists())
+ {
+ projectFileLastModified = projectFile.lastModified();
+ }
+ else
+ {
+ log ("Project file is defined, but could not be located: " +
+ projectFile.getAbsolutePath(), Project.MSG_INFO );
+ projectFile = null;
+ }
+ }
+
+ Document projectDocument = null;
+ try
+ {
+ if ( velocityPropertiesFile.exists() )
+ {
+ ve.init(velocityPropertiesFile.getAbsolutePath());
+ }
+ else if (templatePath != null && templatePath.length() > 0)
+ {
+ ve.setProperty( RuntimeConstants.FILE_RESOURCE_LOADER_PATH,
+ templatePath);
+ ve.init();
+ }
+
+ // get the last modification of the VSL stylesheet
+ styleSheetLastModified = ve.getTemplate( style ).getLastModified();
+
+ // Build the Project file document
+ if (projectFile != null)
+ {
+ projectDocument = builder.build(projectFile);
+ }
+ }
+ catch (Exception e)
+ {
+ log("Error: " + e.toString(), Project.MSG_INFO);
+ throw new BuildException(e);
+ }
+
+ // find the files/directories
+ scanner = getDirectoryScanner(baseDir);
+
+ // get a list of files to work on
+ list = scanner.getIncludedFiles();
+ for (int i = 0;i < list.length; ++i)
+ {
+ process( baseDir, list[i], destDir, projectDocument );
+ }
+ }
+
+ /**
+ * Process an XML file using Velocity
+ */
+ private void process(File baseDir, String xmlFile, File destDir,
+ Document projectDocument)
+ throws BuildException
+ {
+ File outFile=null;
+ File inFile=null;
+ Writer writer = null;
+ try
+ {
+ // the current input file relative to the baseDir
+ inFile = new File(baseDir,xmlFile);
+ // the output file relative to basedir
+ outFile = new File(destDir,
+ xmlFile.substring(0,
+ xmlFile.lastIndexOf('.')) + extension);
+
+ // only process files that have changed
+ if (lastModifiedCheck == false ||
+ (inFile.lastModified() > outFile.lastModified() ||
+ styleSheetLastModified > outFile.lastModified() ||
+ projectFileLastModified > outFile.lastModified()))
+ {
+ ensureDirectoryFor( outFile );
+
+ //-- command line status
+ log("Input: " + xmlFile, Project.MSG_INFO );
+
+ // Build the JDOM Document
+ Document root = builder.build(inFile);
+
+ // Shove things into the Context
+ VelocityContext context = new VelocityContext();
+
+ /*
+ * get the property TEMPLATE_ENCODING
+ * we know it's a string...
+ */
+ String encoding = (String) ve.getProperty( RuntimeConstants.OUTPUT_ENCODING );
+ if (encoding == null || encoding.length() == 0
+ || encoding.equals("8859-1") || encoding.equals("8859_1"))
+ {
+ encoding = "ISO-8859-1";
+ }
+
+ OutputWrapper ow = new OutputWrapper();
+ ow.setEncoding (encoding);
+
+ context.put ("root", root.getRootElement());
+ context.put ("xmlout", ow );
+ context.put ("relativePath", getRelativePath(xmlFile));
+ context.put ("treeWalk", new TreeWalker());
+ context.put ("xpath", new XPathTool() );
+ context.put ("escape", new Escape() );
+ context.put ("date", new java.util.Date() );
+
+ // only put this into the context if it exists.
+ if (projectDocument != null)
+ {
+ context.put ("project", projectDocument.getRootElement());
+ }
+
+ // Process the VSL template with the context and write out
+ // the result as the outFile.
+ writer = new BufferedWriter(new OutputStreamWriter(
+ new FileOutputStream(outFile),
+ encoding));
+ // get the template to process
+ Template template = ve.getTemplate(style);
+ template.merge(context, writer);
+
+ log("Output: " + outFile, Project.MSG_INFO );
+ }
+ }
+ catch (JDOMException e)
+ {
+ if (outFile != null ) outFile.delete();
+ if (e.getCause() != null)
+ {
+ Throwable rootCause = e.getCause();
+ if (rootCause instanceof SAXParseException)
+ {
+ System.out.println("");
+ System.out.println("Error: " + rootCause.getMessage());
+ System.out.println(
+ " Line: " +
+ ((SAXParseException)rootCause).getLineNumber() +
+ " Column: " +
+ ((SAXParseException)rootCause).getColumnNumber());
+ System.out.println("");
+ }
+ else
+ {
+ rootCause.printStackTrace();
+ }
+ }
+ else
+ {
+ e.printStackTrace();
+ }
+// log("Failed to process " + inFile, Project.MSG_INFO);
+ }
+ catch (Throwable e)
+ {
+// log("Failed to process " + inFile, Project.MSG_INFO);
+ if (outFile != null)
+ {
+ outFile.delete();
+ }
+ e.printStackTrace();
+ }
+ finally
+ {
+ if (writer != null)
+ {
+ try
+ {
+ writer.flush();
+ writer.close();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ }
+ }
+
+ /**
+ * Hacky method to figure out the relative path
+ * that we are currently in. This is good for getting
+ * the relative path for images and anchor's.
+ */
+ private String getRelativePath(String file)
+ {
+ if (file == null || file.length()==0)
+ return "";
+ StringTokenizer st = new StringTokenizer(file, "/\\");
+ // needs to be -1 cause ST returns 1 even if there are no matches. huh?
+ int slashCount = st.countTokens() - 1;
+ StringBuffer sb = new StringBuffer();
+ for (int i=0;i<slashCount ;i++ )
+ {
+ sb.append ("../");
+ }
+
+ if (sb.toString().length() > 0)
+ {
+ return StringUtils.chop(sb.toString(), 1);
+ }
+ else
+ {
+ return ".";
+ }
+ }
+
+ /**
+ * create directories as needed
+ */
+ private void ensureDirectoryFor( File targetFile ) throws BuildException
+ {
+ File directory = new File( targetFile.getParent() );
+ if (!directory.exists())
+ {
+ if (!directory.mkdirs())
+ {
+ throw new BuildException("Unable to create directory: "
+ + directory.getAbsolutePath() );
+ }
+ }
+ }
+}
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/AnakiaTask.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/Escape.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/Escape.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/Escape.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/Escape.java Tue May 29 15:35:01 2012
@@ -0,0 +1,80 @@
+package org.apache.velocity.anakia;
+
+/*
+ * Copyright 2001,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * This class is for escaping CDATA sections. The code was
+ * "borrowed" from the JDOM code. I also added in escaping
+ * of the " -> &quot; character.
+ *
+ * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
+ * @version $Id: Escape.java,v 1.4.14.1 2004/03/03 23:22:04 geirm Exp $
+ */
+public class Escape
+{
+ /**
+ * Empty constructor
+ */
+ public Escape()
+ {
+ // left blank on purpose
+ }
+
+ /**
+ * Do the escaping.
+ */
+ public static final String getText(String st)
+ {
+ StringBuffer buff = new StringBuffer();
+ char[] block = st.toCharArray();
+ String stEntity = null;
+ int i, last;
+
+ for (i=0, last=0; i < block.length; i++)
+ {
+ switch(block[i])
+ {
+ case '<' :
+ stEntity = "<";
+ break;
+ case '>' :
+ stEntity = ">";
+ break;
+ case '&' :
+ stEntity = "&";
+ break;
+ case '"' :
+ stEntity = """;
+ break;
+ default :
+ /* no-op */ ;
+ }
+ if (stEntity != null)
+ {
+ buff.append(block, last, i - last);
+ buff.append(stEntity);
+ stEntity = null;
+ last = i + 1;
+ }
+ }
+ if(last < block.length)
+ {
+ buff.append(block, last, i - last);
+ }
+ return buff.toString();
+ }
+}
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/Escape.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/NodeList.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/NodeList.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/NodeList.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/NodeList.java Tue May 29 15:35:01 2012
@@ -0,0 +1,413 @@
+package org.apache.velocity.anakia;
+
+/*
+ * Copyright 2001,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Writer;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.*;
+import org.jdom.*;
+import org.jdom.output.*;
+
+/**
+ * Provides a class for wrapping a list of JDOM objects primarily for use in template
+ * engines and other kinds of text transformation tools.
+ * It has a {@link #toString()} method that will output the XML serialized form of the
+ * nodes it contains - again focusing on template engine usage, as well as the
+ * {@link #selectNodes(String)} method that helps selecting a different set of nodes
+ * starting from the nodes in this list. The class also implements the {@link java.util.List}
+ * interface by simply delegating calls to the contained list (the {@link #subList(int, int)}
+ * method is implemented by delegating to the contained list and wrapping the returned
+ * sublist into a <code>NodeList</code>).
+ *
+ * @author <a href="mailto:szegedia@freemail.hu">Attila Szegedi</a>
+ * @version $Id: NodeList.java,v 1.2.4.1 2004/03/03 23:22:04 geirm Exp $
+ */
+public class NodeList implements List, Cloneable
+{
+ private static final AttributeXMLOutputter DEFAULT_OUTPUTTER =
+ new AttributeXMLOutputter();
+
+ /** The contained nodes */
+ private List nodes;
+
+ /**
+ * Creates an empty node list.
+ */
+ public NodeList()
+ {
+ nodes = new ArrayList();
+ }
+
+ /**
+ * Creates a node list that holds a single {@link Document} node.
+ */
+ public NodeList(Document document)
+ {
+ this((Object)document);
+ }
+
+ /**
+ * Creates a node list that holds a single {@link Element} node.
+ */
+ public NodeList(Element element)
+ {
+ this((Object)element);
+ }
+
+ private NodeList(Object object)
+ {
+ if(object == null)
+ {
+ throw new IllegalArgumentException(
+ "Cannot construct NodeList with null.");
+ }
+ nodes = new ArrayList(1);
+ nodes.add(object);
+ }
+
+ /**
+ * Creates a node list that holds a list of nodes.
+ * @param nodes the list of nodes this template should hold. The created
+ * template will copy the passed nodes list, so changes to the passed list
+ * will not affect the model.
+ */
+ public NodeList(List nodes)
+ {
+ this(nodes, true);
+ }
+
+ /**
+ * Creates a node list that holds a list of nodes.
+ * @param nodes the list of nodes this template should hold.
+ * @param copy if true, the created template will copy the passed nodes
+ * list, so changes to the passed list will not affect the model. If false,
+ * the model will reference the passed list and will sense changes in it,
+ * altough no operations on the list will be synchronized.
+ */
+ public NodeList(List nodes, boolean copy)
+ {
+ if(nodes == null)
+ {
+ throw new IllegalArgumentException(
+ "Cannot initialize NodeList with null list");
+ }
+ this.nodes = copy ? new ArrayList(nodes) : nodes;
+ }
+
+ /**
+ * Retrieves the underlying list used to store the nodes. Note however, that
+ * you can fully use the underlying list through the <code>List</code> interface
+ * of this class itself. You would probably access the underlying list only for
+ * synchronization purposes.
+ */
+ public List getList()
+ {
+ return nodes;
+ }
+
+ /**
+ * This method returns the string resulting from concatenation of string
+ * representations of its nodes. Each node is rendered using its XML
+ * serialization format. This greatly simplifies creating XML-transformation
+ * templates, as to output a node contained in variable x as XML fragment,
+ * you simply write ${x} in the template (or whatever your template engine
+ * uses as its expression syntax).
+ */
+ public String toString()
+ {
+ if(nodes.isEmpty())
+ {
+ return "";
+ }
+
+ StringWriter sw = new StringWriter(nodes.size() * 128);
+ try
+ {
+ for(Iterator i = nodes.iterator(); i.hasNext();)
+ {
+ Object node = i.next();
+ if(node instanceof Element)
+ {
+ DEFAULT_OUTPUTTER.output((Element)node, sw);
+ }
+ else if(node instanceof Attribute)
+ {
+ DEFAULT_OUTPUTTER.output((Attribute)node, sw);
+ }
+ else if(node instanceof Text)
+ {
+ DEFAULT_OUTPUTTER.output((Text)node, sw);
+ }
+ else if(node instanceof Document)
+ {
+ DEFAULT_OUTPUTTER.output((Document)node, sw);
+ }
+ else if(node instanceof ProcessingInstruction)
+ {
+ DEFAULT_OUTPUTTER.output((ProcessingInstruction)node, sw);
+ }
+ else if(node instanceof Comment)
+ {
+ DEFAULT_OUTPUTTER.output((Comment)node, sw);
+ }
+ else if(node instanceof CDATA)
+ {
+ DEFAULT_OUTPUTTER.output((CDATA)node, sw);
+ }
+ else if(node instanceof DocType)
+ {
+ DEFAULT_OUTPUTTER.output((DocType)node, sw);
+ }
+ else if(node instanceof EntityRef)
+ {
+ DEFAULT_OUTPUTTER.output((EntityRef)node, sw);
+ }
+ else
+ {
+ throw new IllegalArgumentException(
+ "Cannot process a " +
+ (node == null
+ ? "null node"
+ : "node of class " + node.getClass().getName()));
+ }
+ }
+ }
+ catch(IOException e)
+ {
+ // Cannot happen as we work with a StringWriter in memory
+ throw new Error();
+ }
+ return sw.toString();
+ }
+
+ /**
+ * Returns a NodeList that contains the same nodes as this node list.
+ * @throws CloneNotSupportedException if the contained list's class does
+ * not have an accessible no-arg constructor.
+ */
+ public Object clone()
+ throws CloneNotSupportedException
+ {
+ NodeList clonedList = (NodeList)super.clone();
+ clonedList.cloneNodes();
+ return clonedList;
+ }
+
+ private void cloneNodes()
+ throws CloneNotSupportedException
+ {
+ Class listClass = nodes.getClass();
+ try
+ {
+ List clonedNodes = (List)listClass.newInstance();
+ clonedNodes.addAll(nodes);
+ nodes = clonedNodes;
+ }
+ catch(IllegalAccessException e)
+ {
+ throw new CloneNotSupportedException("Cannot clone NodeList since"
+ + " there is no accessible no-arg constructor on class "
+ + listClass.getName());
+ }
+ catch(InstantiationException e)
+ {
+ // Cannot happen as listClass represents a concrete, non-primitive,
+ // non-array, non-void class - there's an instance of it in "nodes"
+ // which proves these assumptions.
+ throw new Error();
+ }
+ }
+
+ /**
+ * Returns the hash code of the contained list.
+ */
+ public int hashCode()
+ {
+ return nodes.hashCode();
+ }
+
+ /**
+ * Tests for equality with another object.
+ * @param o the object to test for equality
+ * @return true if the other object is also a NodeList and their contained
+ * {@link List} objects evaluate as equals.
+ */
+ public boolean equals(Object o)
+ {
+ return o instanceof NodeList
+ ? ((NodeList)o).nodes.equals(nodes)
+ : false;
+ }
+
+ /**
+ * Applies an XPath expression to the node list and returns the resulting
+ * node list. In order for this method to work, your application must have
+ * access to <a href="http://code.werken.com">werken.xpath</a> library
+ * classes. The implementation does cache the parsed format of XPath
+ * expressions in a weak hash map, keyed by the string representation of
+ * the XPath expression. As the string object passed as the argument is
+ * usually kept in the parsed template, this ensures that each XPath
+ * expression is parsed only once during the lifetime of the template that
+ * first invoked it.
+ * @param xpathExpression the XPath expression you wish to apply
+ * @return a NodeList representing the nodes that are the result of
+ * application of the XPath to the current node list. It can be empty.
+ */
+ public NodeList selectNodes(String xpathString)
+ {
+ return new NodeList(XPathCache.getXPath(xpathString).applyTo(nodes), false);
+ }
+
+// List methods implemented hereafter
+
+ public boolean add(Object o)
+ {
+ return nodes.add(o);
+ }
+
+ public void add(int index, Object o)
+ {
+ nodes.add(index, o);
+ }
+
+ public boolean addAll(Collection c)
+ {
+ return nodes.addAll(c);
+ }
+
+ public boolean addAll(int index, Collection c)
+ {
+ return nodes.addAll(index, c);
+ }
+
+ public void clear()
+ {
+ nodes.clear();
+ }
+
+ public boolean contains(Object o)
+ {
+ return nodes.contains(o);
+ }
+
+ public boolean containsAll(Collection c)
+ {
+ return nodes.containsAll(c);
+ }
+
+ public Object get(int index)
+ {
+ return nodes.get(index);
+ }
+
+ public int indexOf(Object o)
+ {
+ return nodes.indexOf(o);
+ }
+
+ public boolean isEmpty()
+ {
+ return nodes.isEmpty();
+ }
+
+ public Iterator iterator()
+ {
+ return nodes.iterator();
+ }
+
+ public int lastIndexOf(Object o)
+ {
+ return nodes.lastIndexOf(o);
+ }
+
+ public ListIterator listIterator()
+ {
+ return nodes.listIterator();
+ }
+
+ public ListIterator listIterator(int index)
+ {
+ return nodes.listIterator(index);
+ }
+
+ public Object remove(int index)
+ {
+ return nodes.remove(index);
+ }
+
+ public boolean remove(Object o)
+ {
+ return nodes.remove(o);
+ }
+
+ public boolean removeAll(Collection c)
+ {
+ return nodes.removeAll(c);
+ }
+
+ public boolean retainAll(Collection c)
+ {
+ return nodes.retainAll(c);
+ }
+
+ public Object set(int index, Object o)
+ {
+ return nodes.set(index, o);
+ }
+
+ public int size()
+ {
+ return nodes.size();
+ }
+
+ public List subList(int fromIndex, int toIndex)
+ {
+ return new NodeList(nodes.subList(fromIndex, toIndex));
+ }
+
+ public Object[] toArray()
+ {
+ return nodes.toArray();
+ }
+
+ public Object[] toArray(Object[] a)
+ {
+ return nodes.toArray(a);
+ }
+
+ /**
+ * A special subclass of XMLOutputter that will be used to output
+ * Attribute nodes. As a subclass of XMLOutputter it can use its protected
+ * method escapeAttributeEntities() to serialize the attribute
+ * appropriately.
+ */
+ private static final class AttributeXMLOutputter extends XMLOutputter
+ {
+ public void output(Attribute attribute, Writer out)
+ throws IOException
+ {
+ out.write(" ");
+ out.write(attribute.getQualifiedName());
+ out.write("=");
+
+ out.write("\"");
+ out.write(escapeAttributeEntities(attribute.getValue()));
+ out.write("\"");
+ }
+ }
+}
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/NodeList.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/OutputWrapper.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/OutputWrapper.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/OutputWrapper.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/OutputWrapper.java Tue May 29 15:35:01 2012
@@ -0,0 +1,68 @@
+package org.apache.velocity.anakia;
+
+/*
+ * Copyright 2001,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+import java.io.StringWriter;
+
+import org.jdom.Element;
+import org.jdom.output.XMLOutputter;
+
+/**
+ * This class extends XMLOutputter in order to provide
+ * a way to walk an Element tree into a String.
+ *
+ * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
+ * @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a>
+ * @version $Id: OutputWrapper.java,v 1.6.4.1 2004/03/03 23:22:04 geirm Exp $
+ */
+public class OutputWrapper extends XMLOutputter
+{
+ /**
+ * Empty constructor
+ */
+ public OutputWrapper()
+ {
+ }
+
+ /**
+ * This method walks an Element tree into a String. The cool
+ * thing about it is that it will strip off the first Element.
+ * For example, if you have:
+ * <p>
+ * <td> foo <strong>bar</strong> ack </td>
+ * </p>
+ * It will output
+ * <p>
+ * foo <strong>bar</strong> ack </td>
+ * </p>
+ */
+ public String outputString(Element element, boolean strip)
+ {
+ StringWriter buff = new StringWriter();
+ String name = element.getName();
+
+ try
+ {
+ outputElementContent(element, buff);
+ }
+ catch (IOException e)
+ {
+ }
+ return buff.toString();
+ }
+}
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/OutputWrapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/TreeWalker.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/TreeWalker.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/TreeWalker.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/TreeWalker.java Tue May 29 15:35:01 2012
@@ -0,0 +1,74 @@
+package org.apache.velocity.anakia;
+
+/*
+ * Copyright 2001,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.jdom.Element;
+
+/**
+ * This class allows you to walk a tree of JDOM Element objects.
+ * It first walks the tree itself starting at the Element passed
+ * into allElements() and stores each node of the tree
+ * in a Vector which allElements() returns as a result of its
+ * execution. You can then use a #foreach in Velocity to walk
+ * over the Vector and visit each Element node. However, you can
+ * achieve the same effect by calling <code>element.selectNodes("//*")</code>.
+ *
+ * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
+ * @author <a href="mailto:szegedia@freemail.hu">Attila Szegedi</a>
+ * @version $Id: TreeWalker.java,v 1.6.4.1 2004/03/03 23:22:04 geirm Exp $
+ */
+public class TreeWalker
+{
+ /**
+ * Empty constructor
+ */
+ public TreeWalker()
+ {
+ // Left blank
+ }
+
+ /**
+ * Creates a new Vector and walks the Element tree.
+ *
+ * @param Element the starting Element node
+ * @return Vector a vector of Element nodes
+ */
+ public NodeList allElements(Element e)
+ {
+ ArrayList theElements = new ArrayList();
+ treeWalk (e, theElements);
+ return new NodeList(theElements, false);
+ }
+
+ /**
+ * A recursive method to walk the Element tree.
+ * @param Element the current Element
+ */
+ private final void treeWalk(Element e, Collection theElements )
+ {
+ for (Iterator i=e.getChildren().iterator(); i.hasNext(); )
+ {
+ Element child = (Element)i.next();
+ theElements.add(child);
+ treeWalk(child, theElements);
+ }
+ }
+}
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/TreeWalker.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/XPathCache.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/XPathCache.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/XPathCache.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/XPathCache.java Tue May 29 15:35:01 2012
@@ -0,0 +1,61 @@
+package org.apache.velocity.anakia;
+
+/*
+ * Copyright 2001,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import com.werken.xpath.XPath;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+/**
+ * Provides a cache for XPath expressions. Used by {@link NodeList} and
+ * {@link AnakiaElement} to minimize XPath parsing in their
+ * <code>selectNodes()</code> methods.
+ *
+ * @author <a href="mailto:szegedia@freemail.hu">Attila Szegedi</a>
+ * @version $Id: XPathCache.java,v 1.1.10.1 2004/03/03 23:22:04 geirm Exp $
+ */
+class XPathCache
+{
+ // Cache of already parsed XPath expressions, keyed by String representations
+ // of the expression as passed to getXPath().
+ private static final Map XPATH_CACHE = new WeakHashMap();
+
+ private XPathCache()
+ {
+ }
+
+ /**
+ * Returns an XPath object representing the requested XPath expression.
+ * A cached object is returned if it already exists for the requested expression.
+ * @param xpathString the XPath expression to parse
+ * @return the XPath object that represents the parsed XPath expression.
+ */
+ static XPath getXPath(String xpathString)
+ {
+ XPath xpath = null;
+ synchronized(XPATH_CACHE)
+ {
+ xpath = (XPath)XPATH_CACHE.get(xpathString);
+ if(xpath == null)
+ {
+ xpath = new XPath(xpathString);
+ XPATH_CACHE.put(xpathString, xpath);
+ }
+ }
+ return xpath;
+ }
+}
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/XPathCache.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/XPathTool.java
URL: http://svn.apache.org/viewvc/incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/XPathTool.java?rev=1343781&view=auto
==============================================================================
--- incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/XPathTool.java (added)
+++ incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/XPathTool.java Tue May 29 15:35:01 2012
@@ -0,0 +1,128 @@
+package org.apache.velocity.anakia;
+
+/*
+ * Copyright 2001,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+
+import org.jdom.Document;
+import org.jdom.Element;
+
+/**
+ * This class adds an entrypoint into XPath functionality,
+ * for Anakia.
+ * <p>
+ * All methods take a string XPath specification, along with
+ * a context, and produces a resulting java.util.List.
+ * <p>
+ * The W3C XPath Specification (http://www.w3.org/TR/xpath) refers
+ * to NodeSets repeatedly, but this implementation simply uses
+ * java.util.List to hold all Nodes. A 'Node' is any object in
+ * a JDOM object tree, such as an org.jdom.Element, org.jdom.Document,
+ * or org.jdom.Attribute.
+ * <p>
+ * To use it in Velocity, do this:
+ * <p>
+ * <pre>
+ * #set $authors = $xpath.applyTo("document/author", $root)
+ * #foreach ($author in $authors)
+ * $author.getValue()
+ * #end
+ * #set $chapterTitles = $xpath.applyTo("document/chapter/@title", $root)
+ * #foreach ($title in $chapterTitles)
+ * $title.getValue()
+ * #end
+ * </pre>
+ * <p>
+ * In newer Anakia builds, this class is obsoleted in favor of calling
+ * <code>selectNodes()</code> on the element directly:
+ * <pre>
+ * #set $authors = $root.selectNodes("document/author")
+ * #foreach ($author in $authors)
+ * $author.getValue()
+ * #end
+ * #set $chapterTitles = $root.selectNodes("document/chapter/@title")
+ * #foreach ($title in $chapterTitles)
+ * $title.getValue()
+ * #end
+ * </pre>
+ * <p>
+ *
+ * @author <a href="mailto:bob@werken.com">bob mcwhirter</a>
+ * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
+ * @author <a href="mailto:szegedia@freemail.hu">Attila Szegedi</a>
+ * @version $Id: XPathTool.java,v 1.13.4.1 2004/03/03 23:22:04 geirm Exp $
+ */
+public class XPathTool
+{
+ /**
+ * Constructor does nothing, as this is mostly
+ * just objectified static methods
+ */
+ public XPathTool()
+ {
+ // RuntimeSingleton.info("XPathTool::XPathTool()");
+ // intentionally left blank
+ }
+
+ /**
+ * Apply an XPath to a JDOM Document
+ *
+ * @param xpathSpec The XPath to apply
+ * @param doc The Document context
+ *
+ * @return A list of selected nodes
+ */
+ public NodeList applyTo(String xpathSpec,
+ Document doc)
+ {
+ //RuntimeSingleton.info("XPathTool::applyTo(String, Document)");
+ return new NodeList(XPathCache.getXPath(xpathSpec).applyTo( doc ), false);
+ }
+
+ /**
+ * Apply an XPath to a JDOM Element
+ *
+ * @param xpathSpec The XPath to apply
+ * @param doc The Element context
+ *
+ * @return A list of selected nodes
+ */
+ public NodeList applyTo(String xpathSpec,
+ Element elem)
+ {
+ //RuntimeSingleton.info("XPathTool::applyTo(String, Element)");
+ return new NodeList(XPathCache.getXPath(xpathSpec).applyTo( elem ), false);
+ }
+
+ /**
+ * Apply an XPath to a nodeset
+ *
+ * @param xpathSpec The XPath to apply
+ * @param doc The nodeset context
+ *
+ * @return A list of selected nodes
+ */
+ public NodeList applyTo(String xpathSpec,
+ List nodeSet)
+ {
+ //RuntimeSingleton.info("XPathTool::applyTo(String, List)");
+ return new NodeList(XPathCache.getXPath(xpathSpec).applyTo( nodeSet ), false);
+ }
+}
+
+
+
Propchange: incubator/flex/trunk/modules/thirdparty/velocity/src/java/org/apache/velocity/anakia/XPathTool.java
------------------------------------------------------------------------------
svn:eol-style = native