OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]

Subject: 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.


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:

        <para lang="it">10 marzo 2005</para>
        <para lang="en">10th of March, 2005</para>
        <para lang="it">
          Prima versione del mio sito web finalmente online!</para>
        <para lang="en">
          First version of my web site finally online!</para>

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"/>
            <arg line="--stringparam 'profile.lang' '${language}'"/>
            <arg value="http://www.oasis-open.org/docbook/xsl/profiling/profile.xsl"/>
            <fileset dir="${dir.build.1.doc}" includes="**/*.dbx"/>
            <mapper type="glob" from="*.dbx" to="*.dbx"/>

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"/>

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">
            creare a mano le sottodirectory
        <apply executable="xsltproc" dest="${dir.build.2.doc}" failonerror="true">
            <arg value="--output"/>
            <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"/>
            <fileset dir="${dir.build.2.doc}" includes="**/*.dbx"/>
            <mapper type="glob" from="*.dbx" to="site_${language}/*.php"/>
        <move todir="${dir.build.final.doc}">
            <fileset dir="${dir.build.2.doc}">
                <include name ="**/*.php"/>
        <copy todir="${dir.build.final.doc}/site_${language}/graphics">
            <fileset dir="${dir.graphics}">
                <include name="**/*.*"/>

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="1240764@aruba.it" password="***"
            chmod="755" remotedir="site_${language}" verbose="yes">
            <fileset dir="${dir.build.final.doc}/site_${language}"/>
        <ftp server="ftp.roberto.gianassi.name"
            userid="1240764@aruba.it" password="***"
            chmod="755" remotedir="php" verbose="yes">
            <fileset dir="${dir.php}"/>

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.

Eng. Roberto Gianassi

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]