Next in thread → Next in month →

Re: [docbook-apps] How to generate PHP code in a XSL customizationlayer

From
Roberto Gianassi <>
Date
2005-03-08T19:23:56+00:00
ID
Thread
Re: [docbook-apps] How to generate PHP code in a XSL customizationlayer
Kai Hagemeister wrote:

I don't understand the problem.Could you give a better explanation.
  

  

Kai
  

  

  

I'll try. I wrote some docbook website sources using the lang
attribute. I did this because I want to have a site in English and
Italian. An example of code is:

<section>

  <variablelist>

    <varlistentry>

      <term>

        <para lang="it">10 marzo 2005</para>

        <para lang="en">10th of March, 2005</para>

      </term>

      <listitem>

        <para lang="it">

          Prima versione del mio sito web finalmente
online!</para>

        <para lang="en">

          First version of my web site finally online!</para>

      </listitem>

    </varlistentry>

  </variablelist>

</section>

I use xsltproc and Ant to process the files. The first Ant task I
execute is:

    <target name="profile" depends="doc-prepare">

        <apply executable="xsltproc" dest="${dir.build.2.doc}"
failonerror="true">

            <arg value="--output"/>

            <targetfile/>

            <arg line="--stringparam 'profile.lang'
'${language}'"/>

            <arg
value="http://www.oasis-open.org/docbook/xsl/profiling/profile.xsl"/>

            <srcfile/>

            <fileset dir="${dir.build.1.doc}"
includes="**/*.dbx"/>

            <mapper type="glob" from="*.dbx" to="*.dbx"/>

        </apply>

    </target>

The doc-prepare task copies some files in the build directories (like
the CSS stylesheet).

The build is in stages: I copy the sources from the src directory in
the dir.build.1.doc directory and then I profile these files saving the
processed files in the dir.build.2.doc directory. At this stage I pass
the profile.lang parameter to xsltproc (indirectly via -Dlanguage=en to
Ant) to generate the English version or the Italian one (${language} is
'it' by default so I don't pass anything in this case).

The next step is:

    <target name="autolayout" depends="profile">

        <exec executable="xsltproc" failonerror="true">

            <arg value="--output"/>

            <arg file="${dir.build.2.doc}/autolayout.xml"/>

            <arg line="--stringparam l10n.gentext.language
'${language}'"/>

            <arg
value="http://docbook.sourceforge.net/release/website/2.2/xsl/autolayout.xsl"/>

            <arg file="${dir.build.2.doc}/layout.xml"/>

        </exec>

    </target>

In this task I generate the autolayout.xml file using the layout.xml
file as input. The third step is:

    <target name="xhtml" depends="autolayout">

        <description>

            creare a mano le sottodirectory

        </description>

        <apply executable="xsltproc" dest="${dir.build.2.doc}"
failonerror="true">

            <arg value="--output"/>

            <targetfile/>

            <arg line="--stringparam l10n.gentext.language
'${language}'"/>

            <arg line="--stringparam output-root
site_${language}"/>

            <arg line="--stringparam autolayout-file
autolayout.xml"/>

            <arg value="${dir.script}/web.xsl"/>

            <srcfile/>

            <fileset dir="${dir.build.2.doc}"
includes="**/*.dbx"/>

            <mapper type="glob" from="*.dbx"
to="site_${language}/*.php"/>

        </apply>

        <move todir="${dir.build.final.doc}">

            <fileset dir="${dir.build.2.doc}">

                <include name ="**/*.php"/>

            </fileset>

        </move>

        <copy
todir="${dir.build.final.doc}/site_${language}/graphics">

            <fileset dir="${dir.graphics}">

                <include name="**/*.*"/>

            </fileset>

        </copy>

    </target>

It seems very complex, but it isn't. Here I generate the php files that
will be part of the site. The output root is site_en for the English
version and site_it for the Italian one. I use the autolayout file
generated in the preceding step and a web.xsl file as customization
layer. I move the generated files in the dir.build.final.doc directory
in which I also put the graphics files.

The last step is:

    <target name="ftp">

        <ftp server="ftp.roberto.gianassi.name"

            userid="" password="***"

            chmod="755" remotedir="site_${language}" verbose="yes">

            <fileset
dir="${dir.build.final.doc}/site_${language}"/>

        </ftp>

        <ftp server="ftp.roberto.gianassi.name"

            userid="" password="***"

            chmod="755" remotedir="php" verbose="yes">

            <fileset dir="${dir.php}"/>

        </ftp>

    </target>

I simply transfer the generated files and the auxiliary php files via
ftp to the server.

So the problem is that the customization file (web.xsl in my case) is
used only at the third step, but the "differentiation" for the language
(profiling) is done at the first. However I solved my problem using the
l10n.gentext.language parameter which is equal to profile.lang in
value. Not a perfect solution, but it works.

I hope this explained better what the problem was.

-- 

 Firma 

 Eng. Roberto Gianassi 

 http://www.roberto.gianassi.name
Next in thread → Next in month →