Changeset 25472

Show
Ignore:
Timestamp:
24.04.2012 20:30:19 (7 years ago)
Author:
ak19
Message:

1. ApplyXSLT takes an additional parameter: the Greenstone major version number, or sets this to 2 if none is provided. This is then passed onto the XSLT files. 2. generate-html.sh/bat will pass any commandline parameters on to ApplyXSLT.java. 3. Simplified the generate-html.bat file with a for loop to avoid code duplication. 4. The MajorVersion? element will now be processed by processing/common.xsl: anything in a MajorVersion? element whose number matches the Greenstone major version number specified to generate-html.sh/bat (or ApplyXSLT.java) will be output to html, if the MajorVersion? number does not match, it won't be output.

Location:
documentation/trunk/tutorials
Files:
10 modified

Legend:

Unmodified
Added
Removed
  • documentation/trunk/tutorials/generate-html.bat

    r20953 r25472  
    11@echo off 
    22 
     3:: Usage: generate-html.bat [<gs-major-version-number] 
     4:: The optional parameter major version number, which can be 2 or 3, will be assumed to be (Greenstone) "2" if none is provided 
    35if not "%GSDLHOME%" == "" goto generate 
    46 
    57echo You must run 'setup' in the top level folder of your Greenstone installation before running this script 
     8echo Usage: $0 [gs-major-version-number=2] 
    69goto exit 
    710 
    8 :generate: 
    9 mkdir html 
    10 cd html 
    11 :generate: 
    12 mkdir en 
    13 mkdir fr 
    14 mkdir ru 
    15 mkdir es 
    16 cd .. 
     11setlocal 
    1712 
    1813set top_dir=%CD% 
     
    2015set processing_dir=%CD%\processing 
    2116set output_dir=%CD%\html 
     17:generate: 
     18if not exist "%output_dir" mkdir %output_dir% 
    2219cd .. 
    2320cd shared 
     
    2522cd %output_dir% 
    2623 
     24 
     25set CLASSPATH=%shared_dir%;%GSDLHOME%\gli;%GSDLHOME%\gli\classes;%GSDLHOME%\perllib;%shared_dir%\xalan.jar 
     26 
    2727echo "processing top level index" 
    2828 
    29 java -cp "%shared_dir%;%GSDLHOME%\gli;%GSDLHOME%\gli\classes;%GSDLHOME%\perllib;%shared_dir%\xalan.jar" -DGSDLHOME="%GSDLHOME%" ApplyXSLT "" "%processing_dir%\xml-to-top-index.xsl"  "%source_dir%\tutorial_en.xml" > "%output_dir%\index.html" 
     29java -cp "%CLASSPATH%" -DGSDLHOME="%GSDLHOME%" ApplyXSLT "en" "%processing_dir%\xml-to-top-index.xsl"  "%source_dir%\tutorial_en.xml" %* > "%output_dir%\index.html" 
    3030 
    3131echo "generating wiki index page" 
    32 java -cp "%shared_dir%;%GSDLHOME%\gli;%GSDLHOME%\gli\classes;%GSDLHOME%\perllib;%shared_dir%\xalan.jar" -DGSDLHOME="%GSDLHOME%" ApplyXSLT "" "%processing_dir%\xml-to-wiki-index.xsl" "%source_dir%\tutorial_en.xml" > "%output_dir%\wiki-index.txt" 
     32java -cp "%CLASSPATH%" -DGSDLHOME="%GSDLHOME%" ApplyXSLT "en" "%processing_dir%\xml-to-wiki-index.xsl" "%source_dir%\tutorial_en.xml" %* > "%output_dir%\wiki-index.txt" 
    3333 
    34 echo "procesing english version" 
    3534 
    36 cd %output_dir%\en 
    37 java -cp "%shared_dir%;%GSDLHOME%\gli;%GSDLHOME%\gli\classes;%GSDLHOME%\perllib;%shared_dir%\xalan.jar" -DGSDLHOME="%GSDLHOME%" ApplyXSLT en "%processing_dir%\xml-to-index.xsl" "%source_dir%\tutorial_en.xml" > "index.html" 
    38 java -cp "%shared_dir%;%GSDLHOME%\gli;%GSDLHOME%\gli\classes;%GSDLHOME%\perllib;%shared_dir%\xalan.jar" -DGSDLHOME="%GSDLHOME%" ApplyXSLT en "%processing_dir%\xml-to-one-html.xsl" "%source_dir%\tutorial_en.xml" > "all_tutorials.html" 
    39 java -cp "%shared_dir%;%GSDLHOME%\gli;%GSDLHOME%\gli\classes;%GSDLHOME%\perllib;%shared_dir%\xalan.jar" -DGSDLHOME="%GSDLHOME%" ApplyXSLT en "%processing_dir%\xml-to-many-html.xsl" "%source_dir%\tutorial_en.xml" | perl -S "%GSDLHOME%\gli\help\splithelpdocument.pl" 
     35for %%G IN (en,fr,ru,es) do ( 
     36if not exist "html\%%G" mkdir html\%%G 
     37 
     38echo "procesing %%G version" 
     39cd %output_dir%\%%G 
     40java -cp "%CLASSPATH%" -DGSDLHOME="%GSDLHOME%" ApplyXSLT %%G "%processing_dir%\xml-to-index.xsl" "%source_dir%\tutorial_%%G.xml" %* > "index.html" 
     41java -cp "%CLASSPATH%" -DGSDLHOME="%GSDLHOME%" ApplyXSLT %%G "%processing_dir%\xml-to-one-html.xsl" "%source_dir%\tutorial_%%G.xml" %* > "all_tutorials.html" 
     42java -cp "%CLASSPATH%" -DGSDLHOME="%GSDLHOME%" ApplyXSLT %%G "%processing_dir%\xml-to-many-html.xsl" "%source_dir%\tutorial_%%G.xml" %* | perl -S "%GSDLHOME%\gli\help\splithelpdocument.pl" 
    4043cd .. 
     44) 
    4145 
    42 echo "procesing french version" 
    43 cd %output_dir%\fr 
    44 java -cp "%shared_dir%;%GSDLHOME%\gli;%GSDLHOME%\gli\classes;%GSDLHOME%\perllib;%shared_dir%\xalan.jar" -DGSDLHOME="%GSDLHOME%" ApplyXSLT fr "%processing_dir%\xml-to-index.xsl" "%source_dir%\tutorial_fr.xml" > index.html 
    45 java -cp "%shared_dir%;%GSDLHOME%\gli;%GSDLHOME%\gli\classes;%GSDLHOME%\perllib;%shared_dir%\xalan.jar" -DGSDLHOME="%GSDLHOME%" ApplyXSLT fr "%processing_dir%\xml-to-one-html.xsl" "%source_dir%\tutorial_fr.xml" > all_tutorials.html 
    46 java -cp "%shared_dir%;%GSDLHOME%\gli;%GSDLHOME%\gli\classes;%GSDLHOME%\perllib;%shared_dir%\xalan.jar" -DGSDLHOME="%GSDLHOME%" ApplyXSLT fr "%processing_dir%\xml-to-many-html.xsl" "%source_dir%\tutorial_fr.xml" | perl -S "%GSDLHOME%\gli\help\splithelpdocument.pl" 
    47 cd .. 
    48  
    49 echo "procesing spanish version" 
    50 cd %output_dir%\es 
    51 java -cp "%shared_dir%;%GSDLHOME%\gli;%GSDLHOME%\gli\classes;%GSDLHOME%\perllib;%shared_dir%\xalan.jar" -DGSDLHOME="%GSDLHOME%" ApplyXSLT es "%processing_dir%\xml-to-index.xsl" "%source_dir%\tutorial_es.xml" > index.html 
    52 java -cp "%shared_dir%;%GSDLHOME%\gli;%GSDLHOME%\gli\classes;%GSDLHOME%\perllib;%shared_dir%\xalan.jar" -DGSDLHOME="%GSDLHOME%" ApplyXSLT es "%processing_dir%\xml-to-one-html.xsl" "%source_dir%\tutorial_es.xml" > all_tutorials.html 
    53 java -cp "%shared_dir%;%GSDLHOME%\gli;%GSDLHOME%\gli\classes;%GSDLHOME%\perllib;%shared_dir%\xalan.jar" -DGSDLHOME="%GSDLHOME%" ApplyXSLT es "%processing_dir%\xml-to-many-html.xsl" "%source_dir%\tutorial_es.xml" | perl -S "%GSDLHOME%\gli\help\splithelpdocument.pl" 
    54 cd .. 
    55  
    56 echo "procesing russian version" 
    57 cd %output_dir%\ru 
    58 java -cp "%shared_dir%;%GSDLHOME%\gli;%GSDLHOME%\gli\classes;%GSDLHOME%\perllib;%shared_dir%\xalan.jar" -DGSDLHOME="%GSDLHOME%" ApplyXSLT ru "%processing_dir%\xml-to-index.xsl" "%source_dir%\tutorial_ru.xml" > index.html 
    59 java -cp "%shared_dir%;%GSDLHOME%\gli;%GSDLHOME%\gli\classes;%GSDLHOME%\perllib;%shared_dir%\xalan.jar" -DGSDLHOME="%GSDLHOME%" ApplyXSLT ru "%processing_dir%\xml-to-one-html.xsl" "%source_dir%\tutorial_ru.xml" > all_tutorials.html 
    60 java -cp "%shared_dir%;%GSDLHOME%\gli;%GSDLHOME%\gli\classes;%GSDLHOME%\perllib;%shared_dir%\xalan.jar" -DGSDLHOME="%GSDLHOME%" ApplyXSLT ru "%processing_dir%\xml-to-many-html.xsl" "%source_dir%\tutorial_ru.xml" | perl -S "%GSDLHOME%\gli\help\splithelpdocument.pl" 
    61  
    62 cd .. 
     46endlocal 
    6347 
    6448:exit: 
  • documentation/trunk/tutorials/generate-html.sh

    r24145 r25472  
    11#!/bin/bash 
    22 
     3# Usage: ./generate-html.sh [<gs-major-version-number] 
     4# The optional parameter major version number, which can be 2 or 3, will be assumed to be (Greenstone) "2" if none is provided 
    35if [ "$GSDLHOME" == "" ]; then 
    46    echo "You must run 'source setup.bash' in the top level folder of your Greenstone installation before running this script" 
     7    echo "Usage: $0 [gs-major-version-number=2]" 
    58    exit 
    69fi 
     10 
     11#ApplyXSLT.java will take care of setting the default of the major Greenstone version if none is provided 
     12#if [ "$1" != "" ]; then 
     13#    $major_version="2" 
     14#fi 
    715 
    816top_dir=`pwd` 
     
    1422export CLASSPATH=$shared_dir:$GSDLHOME/gli:$GSDLHOME/gli/classes:$GSDLHOME/perllib:$shared_dir/xalan.jar 
    1523 
    16 mkdir $output_dir 
     24if [ ! -d $output_dir ]; then 
     25    mkdir $output_dir 
     26fi 
    1727 
    1828langs="en fr es ru" 
    1929 
     30# http://tadek.pietraszek.org/blog/2006/01/05/messing-up-with-command-line-arguments-in-bash/ 
     31# is on the difference between $@ and $* and when to add quotes around them 
     32 
    2033echo "processing top level index" 
    21 java -DGSDLHOME=$GSDLHOME ApplyXSLT en $processing_dir/xml-to-top-index.xsl  $source_dir/tutorial_en.xml > $output_dir/index.html 
     34java -DGSDLHOME=$GSDLHOME ApplyXSLT "en" $processing_dir/xml-to-top-index.xsl  $source_dir/tutorial_en.xml "$@" > $output_dir/index.html 
    2235 
    2336echo "generating wiki index page" 
    24 java -DGSDLHOME=$GSDLHOME ApplyXSLT en $processing_dir/xml-to-wiki-index.xsl $source_dir/tutorial_en.xml > $output_dir/wiki-index.txt 
     37java -DGSDLHOME=$GSDLHOME ApplyXSLT "en" $processing_dir/xml-to-wiki-index.xsl $source_dir/tutorial_en.xml "$@" > $output_dir/wiki-index.txt 
    2538 
    2639for l in $langs; do 
    2740    echo "Processing $l version" 
    28     mkdir $output_dir/$l 
     41    if [ ! -d $output_dir/$l ]; then 
     42    mkdir $output_dir/$l 
     43    fi 
    2944    cd $output_dir/$l 
    30     java -DGSDLHOME=$GSDLHOME ApplyXSLT $l $processing_dir/xml-to-index.xsl $source_dir/tutorial_$l.xml > index.html 
    31     java -DGSDLHOME=$GSDLHOME ApplyXSLT $l $processing_dir/xml-to-one-html.xsl $source_dir/tutorial_$l.xml > all_tutorials.html 
    32     java -DGSDLHOME=$GSDLHOME ApplyXSLT $l $processing_dir/xml-to-many-html.xsl $source_dir/tutorial_$l.xml | perl -S $GSDLHOME/gli/help/splithelpdocument.pl 
     45    java -DGSDLHOME=$GSDLHOME ApplyXSLT $l $processing_dir/xml-to-index.xsl $source_dir/tutorial_$l.xml "$@" > index.html 
     46    java -DGSDLHOME=$GSDLHOME ApplyXSLT $l $processing_dir/xml-to-one-html.xsl $source_dir/tutorial_$l.xml "$@" > all_tutorials.html 
     47    java -DGSDLHOME=$GSDLHOME ApplyXSLT $l $processing_dir/xml-to-many-html.xsl $source_dir/tutorial_$l.xml "$@" | perl -S $GSDLHOME/gli/help/splithelpdocument.pl 
    3348    cd $top_dir 
    3449done 
  • documentation/trunk/tutorials/processing/common.xsl

    r13638 r25472  
    55  exclude-result-prefixes="dict"> 
    66 
     7  <!--The following strips newlines introduced by elements, in particular introduced around the MajorVersion template match 
     8      See http://stackoverflow.com/questions/3265244/removing-blank-lines-in-xslt 
     9      and http://msdn.microsoft.com/en-us/library/ms256107.aspx --> 
     10  <xsl:strip-space elements="*"/> 
     11   
    712  <xsl:variable name="diction" select="dict:new('en')"/> 
    813 
     
    160165  </xsl:template> 
    161166 
     167  <!-- Do not process any elements marked with MajorVersion and whose version does not  
     168       specifically match the requested greenstone major version (2 or 3) --> 
     169  <!--To avoid multiple lines of whitespace around output, use  
     170     <xsl:for-each select="node()"><xsl:apply-templates/></xsl:for-each> 
     171     This outputs the contents on its own separate line.  
     172     To avoid thinking about unnecessary newlines and to avoid omitting any sub-xml items  
     173     that need to be processed, we can instead have the following at the top of the file: 
     174     <xsl:strip-space elements="*"/> --> 
     175  <xsl:template match="MajorVersion">  
     176    <xsl:if test="$gs-major-version=@number"> 
     177      <xsl:apply-templates/>       
     178    </xsl:if> 
     179  </xsl:template> 
     180 
    162181  <xsl:template name="SampleFiles"> 
    163182    <xsl:param name="mode">web</xsl:param> 
  • documentation/trunk/tutorials/processing/xml-to-index.xsl

    r17494 r25472  
    44 
    55  <xsl:output method="html"/> 
     6  <xsl:param name="gs-major-version"/> 
    67  <xsl:include href="common.xsl"/> 
    78 
  • documentation/trunk/tutorials/processing/xml-to-many-html.xsl

    r17494 r25472  
    33  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    44 
     5  <xsl:param name="gs-major-version"/> 
    56  <xsl:include href="common.xsl"/> 
    67 
  • documentation/trunk/tutorials/processing/xml-to-one-html.xsl

    r17494 r25472  
    33  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    44 
     5  <xsl:param name="gs-major-version"/> 
    56  <xsl:include href="common.xsl"/> 
    67  <xsl:output method="html"/> 
  • documentation/trunk/tutorials/processing/xml-to-one-workshop.xsl

    r17494 r25472  
    44  xmlns:xalan="http://xml.apache.org/xalan"> 
    55 
     6  <xsl:param name="gs-major-version"/> 
    67  <xsl:include href="common.xsl"/> 
    78 
  • documentation/trunk/tutorials/processing/xml-to-top-index.xsl

    r13638 r25472  
    33  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    44 
     5  <xsl:param name="gs-major-version"/> 
    56  <xsl:include href="common.xsl"/> 
    67 
  • documentation/trunk/tutorials/processing/xml-to-wiki-index.xsl

    r13638 r25472  
    33  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    44 
     5  <xsl:param name="gs-major-version"/> 
    56  <xsl:include href="common.xsl"/> 
    67 
  • documentation/trunk/tutorials/processing/xml-to-workshop.xsl

    r13638 r25472  
    44  xmlns:xalan="http://xml.apache.org/xalan"> 
    55 
     6  <xsl:param name="gs-major-version"/> 
    67  <xsl:include href="common.xsl"/> 
    78