« Return to Thread: External Docbook XSLT: status update

External Docbook XSLT: status update

by Luigi Toscano :: Rate this Message:

| View in Thread

Hi,
as many of you probably know, I'm working on removing the embedded copy of
Docbook XSLT (previous episodes here:
http://kde.markmail.org/thread/rp6gj6evd3zwgl3j ,
we are now at step 2).

Most of the work was already committed in 4.5.x; the only big issue is
translation handling.

In the past, every change/customization was committed directly to
kdelibs/kdoctools/docbook/xsl/common/<langcode>.xml and XSLT stylesheets for
new languages have been committed directly to that directory. In the (near)
future kdelibs/kdoctools/docbook (our internal copy of XSLT stylesheets) will
be removed and all the remaining customization will be moved to
kdelibs/kdoctools/customization.
You can already see some localization files under customization/xsl/, but it's
a leftover from the past and those XSLT files were never used, so they will
replaced.

= Technical notes (please skip it if you are not interested):
After the removal of docbook/xsl directory we will use the upstream version of
docbook-xsl stylesheet. But don't be scared, because they are flexible enough
to handle custom translations: it is possible to define a custom xml file
(with the same structure of docbook/xsl/common/l10n.xml) with the list of
localized files containing the customizations.
Unfortunately this is not enough for us, because using that file it is
possible to define customization files only for those languages defined in the
main list of languages, but we support languages which are not shipped with
docbook-xsl (e.g. nds). In order to solve this issue, a custom program will
generate two special files during the compilation of kdelibs: the list of
complete languages (which will be used instead of xsl/common/l10n.xml) and the
list of customization files (see the attached patch).

= How will this impact translators' work?
- XSL stylesheet will still be customizable, but the changes must be saved
under kdelibs/kdoctools/customization/xsl/<lang-code>.xml.
- we will be able to handle customization for existing languages and
completely new languages, but it will be better to push them upstream
(http://docbook.sourceforge.net/).
- I will populate the initial structure of customization file extracting the
most important custom strings from the current docbook/xsl/common/<lang>.xml,
with the proper credits in the comments (from svn log - is it enough?). After
this commit, please please check if something is missing.

= Drawbacks
The generated man pages have some differences (see the attached example) and
few warnings are emitted, maybe some docbook files should be fixed. But I'd
like to commit the changes as soon as possible and tune the system on the fly,
in order to test them properly before the freeze of SC 4.6

Comments/ideas/suggestions?

Regards
--
Luigi

'\" t
.\"     Title: \fBark\fR
.\"    Author: Lauri Watts <lauri@...>
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
.\"      Date: 2009-09-10
.\"    Manual: KDE User's Manual
.\"    Source: K Desktop Environment 2.13 (KDE 4.3.1)
.\"  Language: English
.\"
.TH "\FBARK\FR" "1" "2009\-09\-10" "K Desktop Environment 2.13 (KD" "KDE User's Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
ark \- KDE archiving tool
.SH "SYNOPSIS"
.HP \w'\fBark\fR\ 'u
\fBark\fR [\fB\-b\fR] [\fB\-a\fR] [\fB\-e\fR] [\fB\-c\fR] [\fB\-f\fR\fI
suffix\fR] [\fB\-p\fR] [\fB\-t\fR\fI
file\fR] [\fB\-d\fR] [\fB\-o\fR\fI
directory\fR] [KDE\ Generic\ Options] [Qt(TM)\ Generic\ Options]
.SH "DESCRIPTION"
.PP
Ark
is a program for managing various compressed file formats within
KDE\&. Archives can be viewed, extracted, created and modified with
Ark\&. The program can handle various formats such as
tar,
gzip,
bzip2,
zip,
rar
(when the appropriate libraries or command\-line programs are installed)\&.
.SH "OPERATION MODES"
.PP
Ark
can be used either as a stand\-alone
GUI
program as well as a command\-line program in order to perform some specific tasks\&.
.PP
If invoked without the \-b (\-\-batch) or \-c (\-\-add) options,
Ark
is started as a normal
GUI
program\&.
.PP
When the \-b (\-\-batch) option is used,
Ark
can be used to extract the contents of one or more files directly from the command\-line, without launching its
GUI\&.
.PP
When the \-c (\-\-add) option is used,
Ark
prompts for files that should be added to a new archive or to an existing archive\&.
.PP
.PP
.SH "OPTIONS"
.PP
\fB\-d, \-\-dialog\fR
.RS 4
Show a dialog for specifying the options for a batch or add operation\&.
.RE
.PP
\fB\-o, \-\-destination \fR\fB\fIdirectory\fR\fR
.RS 4
Default the extraction directory to
\fIdirectory\fR\&. If not passed, the current path is used\&.
.RE
.SS "Options for adding files"
.PP
\fB\-c, \-\-add\fR
.RS 4
Query the user for an archive filename and add specified files to it\&. Quit when finished\&.
.RE
.PP
\fB\-t, \-\-add\-to \fR\fB\fIfilename\fR\fR
.RS 4
Add the specified files to
\fIfilename\fR\&. Create archive if it does not exist\&. Quit when finished\&.
.RE
.PP
\fB\-p, \-\-changetofirstpath\fR
.RS 4
Change the current directory to the first entry and add all other entries relative to this one\&.
.RE
.PP
\fB\-f, \-\-autofilename \fR\fB\fIsuffix\fR\fR
.RS 4
Automatically choose a filename, with the selected
\fIsuffix\fR
(for example rar, tar\&.gz, zip or any other supported types)\&.
.RE
.SS "Options for batch extraction"
.PP
\fBb, \-\-batch\fR
.RS 4
Use the batch interface instead of the usual dialog\&. This option is implied if more than one url is specified\&.
.RE
.PP
\fB\-e, \-\-autodestination\fR
.RS 4
The destination argument will be set to the path of the first file supplied\&.
.RE
.PP
\fB\-a, \-\-autosubfolder\fR
.RS 4
Archive contents will be read, and if detected to not be a single folder archive, a subfolder by the name of the archive will be created\&.
.RE
.SH "EXAMPLES"
.PP
\fB\fBark\fR\fR\fB \fR\fB\fB\-\-batch\fR\fR\fB \fR\fB\fIarchive\&.tar\&.bz2\fR\fR
.RS 4
Will extract
\fIarchive\&.tar\&.bz2\fR
into the current directory without showing any
GUI\&.
.RE
.PP
\fB\fBark\fR\fR\fB \fR\fB\fB\-b\fR\fR\fB \fR\fB\fB\-d\fR\fR\fB \fR\fB\fIarchive\&.tar\&.bz2\fR\fR\fB \fR\fB\fIarchive2\&.zip\fR\fR
.RS 4
Will first show an extraction options dialog and then extract both
\fIarchive\&.tar\&.bz2\fR
and
\fIarchive2\&.zip\fR
into the directory chosen in the dialog\&.
.RE
.PP
\fB\fBark\fR\fR\fB \fR\fB\fB\-\-add\-to\fR\fR\fB \fR\fB\fImy\-archive\&.zip\fR\fR\fB \fR\fB\fIphoto1\&.jpg\fR\fR\fB \fR\fB\fItext\&.txt\fR\fR
.RS 4
Will create
\fImy\-archive\&.zip\fR
if does not exist and then add
\fIphoto1\&.jpg\fR
and
\fItext\&.txt\fR
to it\&.
.RE
.SH "AUTHORS"
.PP
Ark
is currently maintained by
Harald Hvaal
haraldhv@stud\&.ntnu\&.no
and
Raphael Kubo da Costa
kubito@gmail\&.com\&.
.PP
This man page was first written by
Lauri Watts
lauri@kde\&.org
in 2005 for
KDE
3\&.4, and was later updated in 2009 by
Raphael Kubo da Costa
kubito@gmail\&.com\&.
.SH "AUTHORS"
.PP
\fBLauri Watts\fR <\&lauri@kde\&.org\&>
.RS 4
Author.
.RE
.PP
\fBRaphael Kubo da Costa\fR <\&kubito@gmail\&.com\&>
.RS 4
Author.
.RE

'\" t
.\"     Title: \fBcheckXML\fR
.\"    Author: Lauri Watts <lauri@...>
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
.\"      Date: 2003-07-03
.\"    Manual: KDE User's Manual
.\"    Source: [FIXME: source]
.\"  Language: English
.\"
.TH "\FBCHECKXML\FR" "1" "2003\-07\-03" "[FIXME: source]" "KDE User's Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
checkXML \- An XML lint tool for KDE DocBook XML documents\&.
.SH "SYNOPSIS"
.HP \w'\fBcheckXML\fR\ 'u
\fBcheckXML\fR [\fIfilename\fR]
.SH "DESCRIPTION"
.PP
\fBcheckXML\fR
is a tool to check for syntax errors in
KDE
DocBook
XML
files\&. It can also be used for other DocBook based
XML
files, but you should use the less specific xmllint(1) tool if you are not writing or otherwise working on
KDE
documentation\&.
.SH "SEE ALSO"
.PP
meinproc4(1) xmllint(1)
.SH "AUTHOR"
.PP
\fBLauri Watts\fR <\&lauri@kde\&.org\&>
.RS 4
Author.
.RE

'\" t
.\"     Title: \fBkded4\fR
.\"    Author: David Faure <faure@...>
.\" Generator: DocBook XSL Stylesheets v1.75.2 <http://docbook.sf.net/>
.\"      Date: 2008-11-12
.\"    Manual: KDE User's Manual
.\"    Source: 0.01.01
.\"  Language: English
.\"
.TH "\FBKDED4\FR" "8" "2008\-11\-12" "0.01.01" "KDE User's Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
kded4 \- KDE daemon \- triggers Sycoca database updates when needed\&.
.SH "SYNOPSIS"
.HP \w'\fBkded4\fR\ 'u
\fBkded4\fR [\-\-help] [Generic\ options] [Qt\-options] [KDE\-options] [\-\-check]
.SH "DESCRIPTION"
.PP

\fBkded4\fR
is responsible for creating the sycoca file, i\&.e\&. the binary cache of servicetypes, mimetypes, and services for a particular user\&.
.PP
It monitors the directories containing \&.desktop files\&. When a file is added/removed, it waits 5 seconds (in case of series of updates), and then launches
\fBkbuildsycoca4\fR\&.
.SH "GENERIC OPTIONS"
.PP
.PP
\fB\-\-author\fR
.RS 4
Show author information\&.
.RE
.PP
\fB\-\-help\fR
.RS 4
Show help about options\&.
.RE
.PP
\fB\-\-help\-all\fR
.RS 4
Show all options\&.
.RE
.PP
\fB\-\-help\-kde\fR
.RS 4
Show KDE specific options\&.
.RE
.PP
\fB\-\-help\-qt\fR
.RS 4
Show Qt specific options\&.
.RE
.PP
\fB\-\-license\fR
.RS 4
Show license information\&.
.RE
.PP
\fB\-v\fR \fB\-\-version\fR
.RS 4
Show version information
.RE
.SH "APPLICATION OPTIONS"
.PP
\fB\-\-check\fR
.RS 4
Check Sycoca database only once\&.
.RE
.SH "USAGE"
.PP
If
\fBkded4\fR
is called without parameters and is already running, it shows the message:
.sp
.if n \{\
.RS 4
.\}
.nf
KDE Daemon (kded) already running\&.
.fi
.if n \{\
.RE
.\}
.PP
If
\fBkded4\fR
is called with
\fBkded4 \-\-check\fR, then it updates the
KDE
sycoca using
\fBkbuildsycoca4\fR\&.
.SH "SEE ALSO"
.PP
\fIkdeoptions\fR(7),
\fIqtoptions\fR(7),
\fIkbuildsycoca4\fR(8)
.SH "BUGS"
.PP
There are probably tons of bugs\&. Use
\m[blue]\fBbugs\&.kde\&.org\fR\m[]\&\s-2\u[1]\d\s+2
to report them\&.
.SH "AUTHORS"
.PP
\fBDavid Faure\fR <\&faure@kde\&.org\&>
.RS 4
Author.
.RE
.PP
\fBWaldo Bastian\fR <\&bastian@kde\&.org\&>
.RS 4
Author.
.RE
.SH "NOTES"
.IP " 1." 4
bugs.kde.org
.RS 4
\%http://bugs.kde.org
.RE

[xslt_externalonly.diff]

Index: kdoctools/CMakeLists.txt
===================================================================
--- kdoctools/CMakeLists.txt (revisione 1179901)
+++ kdoctools/CMakeLists.txt (copia locale)
@@ -80,8 +80,10 @@
 
    kde4_add_executable(meinproc4 NOGUI ${meinproc_SRCS})
 
-   target_link_libraries(meinproc4 ${KDE4_KDECORE_LIBS} ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES})
+   target_link_libraries(meinproc4 ${KDE4_KDECORE_LIBS} ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${LIBEXSLT_LIBRARIES})
 
+   add_dependencies(meinproc4 docbookl10nhelper)
+
    # "export" this target too so we can use the LOCATION property of the imported target in
    # FindKDE4Internal.cmake to get the full path to the installed executable instead of using FIND_PROGRAM(), Alex
    install(TARGETS meinproc4  EXPORT kdelibsToolsTargets ${INSTALL_TARGETS_DEFAULT_ARGS})
@@ -104,8 +106,10 @@
 
    kde4_add_executable(meinproc4_simple NOGUI ${meinproc_qt_SRCS})
 
-   target_link_libraries(meinproc4_simple ${QT_QTCORE_LIBRARIES} ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES})
+   target_link_libraries(meinproc4_simple ${QT_QTCORE_LIBRARIES} ${LIBXML2_LIBRARIES} ${LIBXSLT_LIBRARIES} ${LIBEXSLT_LIBRARIES})
 
+   add_dependencies(meinproc4_simple docbookl10nhelper)
+
    install(TARGETS meinproc4_simple ${INSTALL_TARGETS_DEFAULT_ARGS})
 
 endif (NOT CMAKE_CROSSCOMPILING)
@@ -120,6 +124,19 @@
 target_link_libraries(genshortcutents ${KDE4_KDECORE_LIBS} ${KDE4_KDEUI_LIBS})
 
 
+########### customize includes for xslt ###############
+
+file( GLOB _kdeincludexslt_ALL "customization/kde-include*.xsl.cmake" )
+foreach( _kdeincludexslt ${_kdeincludexslt_ALL} )
+    get_filename_component( _kdeincludexslt_name ${_kdeincludexslt} NAME )
+    string( REGEX REPLACE ".cmake$" "" _kdeincludexslt_out "${_kdeincludexslt_name}" )
+    set( _kdeincludexslt_binarypath "${CMAKE_CURRENT_BINARY_DIR}/customization/${_kdeincludexslt_out}" )
+    configure_file( ${_kdeincludexslt} ${_kdeincludexslt_binarypath} )
+    install(FILES ${_kdeincludexslt_binarypath}
+            DESTINATION ${DATA_INSTALL_DIR}/ksgmltools2/customization )
+endforeach( _kdeincludexslt ${_kdeincludexslt_ALL} )
+
+
 ########### install files ###############
 
 install( FILES help.protocol ghelp.protocol  DESTINATION  ${SERVICES_INSTALL_DIR} )
@@ -154,91 +171,8 @@
     endforeach(_curentfile ${_file_CUST})
 endmacro(INSTALL_CUSTOMIZE_L_DIR _expr _directory)
 
-set(docbookdir xsl )
 
-set(expr "docbook/README.kde")
-INSTALL_CUSTOMIZE_DIR( ${expr} docbook/)
 
-foreach (_currentdocbookdir ${docbookdir})
- set(expr "docbook/${_currentdocbookdir}/*.mod")
- install_customize_dir( ${expr} docbook/${_currentdocbookdir}/)
- set(expr "docbook/${_currentdocbookdir}/*.txt")
- install_customize_dir( ${expr} docbook/${_currentdocbookdir}/)
- set(expr "docbook/${_currentdocbookdir}/*.dtd")
-    install_customize_dir( ${expr} docbook/${_currentdocbookdir}/)
- set(expr "docbook/${_currentdocbookdir}/*.cat")
-    install_customize_dir( ${expr} docbook/${_currentdocbookdir}/)
- set(expr "docbook/${_currentdocbookdir}/README*")
- install_customize_dir( ${expr} docbook/${_currentdocbookdir}/)
- set(expr "docbook/${_currentdocbookdir}/Changelog*")
- install_customize_dir( ${expr} docbook/${_currentdocbookdir}/)
- set(expr "docbook/${_currentdocbookdir}/*.xml")
- install_customize_dir( ${expr} docbook/${_currentdocbookdir}/)
- set(expr "docbook/${_currentdocbookdir}/VERSION*")
- install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/)
- set(expr "docbook/${_currentdocbookdir}/What*")
- install_customize_dir( ${expr} docbook/${_currentdocbookdir}/)
-
- set(expr "docbook/${_currentdocbookdir}/ent/*.ent")
- install_customize_dir( ${expr} docbook/${_currentdocbookdir}/ent/)
-
- set(expr "docbook/${_currentdocbookdir}/common/*.xsl")
- install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/common/)
- set(expr "docbook/${_currentdocbookdir}/common/*.xml")
- install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/common/)
- set(expr "docbook/${_currentdocbookdir}/common/*.dtd")
- install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/common/)
- set(expr "docbook/${_currentdocbookdir}/common/Changelog")
- install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/common/)
-
-    set(expr "docbook/${_currentdocbookdir}/html/*.xsl")
-    install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/html/)
-    set(expr "docbook/${_currentdocbookdir}/html/*.xml")
-    install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/html/)
-    set(expr "docbook/${_currentdocbookdir}/html/*.dtd")
-    install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/html/)
- set(expr "docbook/${_currentdocbookdir}/html/Changelog")
- install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/html/)
- set(expr "docbook/${_currentdocbookdir}/html/*.ent")
- install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/html/)
- set(expr "docbook/${_currentdocbookdir}/html/*.xweb")
- install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/html/)
-
-    set(expr "docbook/${_currentdocbookdir}/images/*.png")
-    install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/images/)
- set(expr "docbook/${_currentdocbookdir}/images/*.gif")
- install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/images/)
- set(expr "docbook/${_currentdocbookdir}/images/*.tif")
- install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/images/)
- set(expr "docbook/${_currentdocbookdir}/images/Changelog")
- install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/images/)
-
- set(expr "docbook/${_currentdocbookdir}/images/callouts/*.png")
- install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/images/callouts/)
-    set(expr "docbook/${_currentdocbookdir}/images/callouts/*.gif")
-    install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/images/callouts/)
- set(expr "docbook/${_currentdocbookdir}/images/callouts/Changelog")
- install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/images/callouts/)
-
- set(expr "docbook/${_currentdocbookdir}/lib/lib.*")
- install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/lib/)
- set(expr "docbook/${_currentdocbookdir}/lib/Changel*")
- install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/lib/)
- set(expr "docbook/${_currentdocbookdir}/lib/README*")
- install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/lib/)
-
- set(expr "docbook/${_currentdocbookdir}/manpages/*.xsl")
- install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/manpages/)
-
- set(expr "docbook/${_currentdocbookdir}/params/*.xml")
- install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/params/)
- set(expr "docbook/${_currentdocbookdir}/params/Changelog")
- install_customize_l_dir( ${expr} docbook/${_currentdocbookdir}/params/)
-
-
-endforeach(_currentdocbookdir ${docbookdir})
-
-
 set(expr "customization/*.xsl")
 install_customize_l_dir( ${expr} customization/)
 
@@ -272,5 +206,19 @@
   
 
 
+########### l10n xml helper ###############
 
+set( docbookl10nhelper_SRCS docbookl10nhelper.cpp )
+kde4_add_executable( docbookl10nhelper NOGUI ${docbookl10nhelper_SRCS} )
+target_link_libraries( docbookl10nhelper ${QT_QTCORE_LIBRARIES} )
 
+add_custom_command( TARGET docbookl10nhelper POST_BUILD
+  COMMAND ${EXECUTABLE_OUTPUT_PATH}/docbookl10nhelper
+  ${DOCBOOKXSL_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/customization/xsl
+  ${CMAKE_CURRENT_BINARY_DIR}/customization/xsl
+)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/customization/xsl/all-l10n.xml
+  DESTINATION ${DATA_INSTALL_DIR}/ksgmltools2/customization/xsl/ )
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/customization/xsl/kde-custom-l10n.xml
+  DESTINATION ${DATA_INSTALL_DIR}/ksgmltools2/customization/xsl/ )
+
Index: kdoctools/docbookl10nhelper.cpp
===================================================================
--- kdoctools/docbookl10nhelper.cpp (revisione 0)
+++ kdoctools/docbookl10nhelper.cpp (revisione 0)
@@ -0,0 +1,178 @@
+#include <QCoreApplication>
+#include <QDebug>
+#include <QDir>
+#include <QFile>
+#include <QIODevice>
+#include <QList>
+#include <QPair>
+#include <QRegExp>
+#include <QStringList>
+#include <QTextStream>
+
+
+class LangListType: public QList<QPair<QString,QString> >
+{
+public:
+   int searchLang( QString el ) {
+
+      for ( int i = 0; i < size(); ++i ) {
+         if ( at( i ).first == el )
+            return i;
+      }
+      return -1;
+   }
+};
+
+int writeLangFile( const QString &fname, const QString &dtdPath,
+                   const LangListType &langMap ) {
+
+   QFile outFile( fname );
+   if ( ! outFile.open( QIODevice::WriteOnly ) ) {
+      qCritical() << QString( "Could not write %1" )
+                     .arg( outFile.fileName() );
+      return( 1 );
+   }
+
+   QTextStream outStream( &outFile );
+   outStream << "<?xml version='1.0'?>" << endl;
+   outStream << QString( "<!DOCTYPE l:i18n SYSTEM \"%1\" [" )
+               .arg( dtdPath ) << endl;
+
+   LangListType::const_iterator i = langMap.constBegin();
+   while ( i != langMap.constEnd() ) {
+      //qDebug() << (*i).first << ": " << (*i).second;
+      outStream << QString( "<!ENTITY %1 SYSTEM \"%2\">" )
+                   .arg( (*i).first ).arg( (*i).second ) << endl;
+      ++i;
+   }
+   outStream << "]>" << endl;
+
+   if ( langMap.size() > 0 ) {
+      outStream
+         << "<l:i18n xmlns:l=\"http://docbook.sourceforge.net/xmlns/l10n/1.0\">"
+         << endl;
+      i = langMap.constBegin();
+      while ( i != langMap.constEnd() ) {
+         outStream << QString( "&%1;" )
+                      .arg( (*i).first ) << endl;
+         ++i;
+      }
+      outStream << "</l:i18n>" << endl;
+   }
+
+   outFile.close();
+
+   return( 0 );
+}
+
+inline const QString addTrailingSlash( const QString &p ) {
+   return p.endsWith( "/" ) ? p : p + "/";
+}
+
+int main( int argc, char **argv ) {
+   QCoreApplication app( argc, argv );
+
+   const QStringList arguments = app.arguments();
+   if ( arguments.count() != 4 ) {
+      qCritical() << "wrong argument count";
+      return ( 1 );
+   }
+
+   const QString l10nDir = arguments[1].endsWith( "/" ) ?
+                           arguments[1] : arguments[1] + "/";
+   const QString l10nCustomDir = arguments[2].endsWith( "/" ) ?
+                           arguments[2] : arguments[2] + "/";
+   const QString destDir = arguments[3].endsWith( "/" ) ?
+                           arguments[3] : arguments[3] + "/";
+
+   QFile i18nFile( l10nDir + "common/l10n.xml" );
+
+   if ( ! i18nFile.open( QIODevice::ReadOnly ) ) {
+      qCritical() << i18nFile.fileName() << " not found";
+      return( 1 );
+   }
+
+   const QString all10nFName = destDir + "all-l10n.xml";
+   const QString customl10nFName = destDir + "kde-custom-l10n.xml";
+
+   /*
+    * for each language defined in the original l10n.xml, copy
+    * it into all-l10n.xml and store it in a list;
+    **/
+   QRegExp rxEntity, rxDocType;
+   rxDocType.setPattern("^\\s*<!DOCTYPE\\s+l:i18n\\s+SYSTEM\\s+\"l10n\\.dtd\"\\s+\\[\\s*$");
+   rxEntity.setPattern("^\\s*<!ENTITY\\s+([^\\s]+)\\s+SYSTEM\\s+\"([^\\s]+)\">\\s*$");
+   QTextStream inStream( &i18nFile );
+   int parsingState = 0;
+   //line = inStream.readLine();
+   LangListType allLangs, customLangs;
+
+   while ( ! inStream.atEnd() ) {
+      QString line = inStream.readLine();
+
+      switch ( parsingState ) {
+       case 0:
+         if ( rxDocType.indexIn( line ) != -1 ) {
+            parsingState = 1;
+            //qDebug() << "DTD found";
+         }
+         break;
+       case 1:
+         QString langCode, langFile;
+         if ( rxEntity.indexIn( line ) != -1 ) {
+            langCode = rxEntity.cap( 1 );
+            langFile = l10nDir + "common/" + rxEntity.cap( 2 );
+            allLangs += qMakePair( langCode, langFile );
+            //qDebug() << langCode << " - " << langFile;
+         }
+         break;
+      }
+
+   }
+   i18nFile.close();
+
+   /* read the list of locally-available custom languages */
+   QDir outDir( l10nCustomDir );
+
+   QStringList dirFileFilters;
+   dirFileFilters << "*.xml";
+   QStringList customLangFiles = outDir.entryList( dirFileFilters,
+                           QDir::Files|QDir::NoSymLinks, QDir::Name );
+   /* the following two calls to removeOne should not be needed, as
+    * the customization directory from the sources should not contain
+    * those files
+    */
+   customLangFiles.removeOne( "all-l10n.xml" );
+   customLangFiles.removeOne( "kde-custom-l10n.xml" );
+   //qDebug() << "customLangFiles:" << customLangFiles;
+
+   /*
+    * for each custom language (from directory listing), if it is not
+    * in the list of upstream languages, add it to all-l10n.xml,
+    * otherwise add it to kde-custom-l10n.xml
+    */
+   QStringList::const_iterator i = customLangFiles.constBegin();
+   while ( i != customLangFiles.constEnd() ) {
+      QString langFile = (*i);
+      /* remove trailing .xml */
+      QString langCode = langFile.left( langFile.length() - 4 );
+
+      QPair<QString,QString> cl = qMakePair( langCode, langFile );
+      if ( ( allLangs.searchLang( langCode ) ) > 0 ) {
+      /* custom language found in upstream list */
+         customLangs += cl;
+      } else {
+      /* custom language not found in upstream list */
+         allLangs += cl;
+      }
+      ++i;
+   }
+
+
+   int res = writeLangFile( all10nFName, l10nDir + "common/l10n.dtd",
+                            allLangs );
+   res += writeLangFile( customl10nFName, l10nDir + "common/l10n.dtd",
+                         customLangs );
+
+   return( res );
+}
Index: kdoctools/meinproc.cpp
===================================================================
--- kdoctools/meinproc.cpp (revisione 1179901)
+++ kdoctools/meinproc.cpp (copia locale)
@@ -31,6 +31,7 @@
 #include <libxslt/xsltInternals.h>
 #include <libxslt/transform.h>
 #include <libxslt/xsltutils.h>
+#include <libexslt/exslt.h>
 
 #include <stdlib.h>
 #include <string.h>
@@ -113,6 +114,8 @@
         return ( 1 );
     }
 
+    exsltRegisterAll();
+
     // Need to set SRCDIR before calling fillInstance
     QString srcdir;
     if ( args->isSet( "srcdir" ) )
Index: kdoctools/meinproc_simple.cpp
===================================================================
--- kdoctools/meinproc_simple.cpp (revisione 1179901)
+++ kdoctools/meinproc_simple.cpp (copia locale)
@@ -22,6 +22,7 @@
 #include <libxslt/xsltInternals.h>
 #include <libxslt/transform.h>
 #include <libxslt/xsltutils.h>
+#include <libexslt/exslt.h>
 
 #include <stdlib.h>
 #include <string.h>
@@ -60,6 +61,8 @@
         return ( 2 );
     }
 
+    exsltRegisterAll();
+
     QByteArray catalogs;
     catalogs += customizationCatalog.toUtf8();
     
Index: kdoctools/customization/kde-include-common.xsl.cmake
===================================================================
--- kdoctools/customization/kde-include-common.xsl.cmake (revisione 1147294)
+++ kdoctools/customization/kde-include-common.xsl.cmake (copia locale)
@@ -1,7 +1,10 @@
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">
 
-   <xsl:import href="../docbook/xsl/html/autoidx.xsl"/>
-   <xsl:import href="../docbook/xsl/html/chunk.xsl"/>
+   <xsl:import href="@DOCBOOKXSL_DIR@/html/autoidx.xsl"/>
+   <xsl:import href="@DOCBOOKXSL_DIR@/html/chunk.xsl"/>
 
+   <xsl:param name="l10n.xml" select="document('xsl/all-l10n.xml')"/>
+   <xsl:param name="local.l10n.xml" select="document('xsl/kde-custom-l10n.xml')"/>
+        
 </xsl:stylesheet>
Index: kdoctools/customization/kde-include-man.xsl.cmake
===================================================================
--- kdoctools/customization/kde-include-man.xsl.cmake (revisione 1147294)
+++ kdoctools/customization/kde-include-man.xsl.cmake (copia locale)
@@ -1,6 +1,12 @@
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">
 
-   <xsl:import href="../docbook/xsl/manpages/docbook.xsl"/>
+   <xsl:import href="@DOCBOOKXSL_DIR@/manpages/docbook.xsl"/>
 
+   <xsl:param name="chunker.output.encoding" select="'UTF-8'"/>
+   <xsl:output method="text" encoding="UTF-8" indent="no"/>
+
+   <xsl:param name="l10n.xml" select="document('xsl/all-l10n.xml')"/>
+   <xsl:param name="local.l10n.xml" select="document('xsl/kde-custom-l10n.xml')"/>
+
 </xsl:stylesheet>
Index: kdoctools/customization/kde-include-common.xsl
===================================================================
--- kdoctools/customization/kde-include-common.xsl (revisione 1179901)
+++ kdoctools/customization/kde-include-common.xsl (copia locale)
@@ -1,7 +0,0 @@
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- version="1.0">
-
-   <xsl:import href="../docbook/xsl/html/autoidx.xsl"/>
-   <xsl:import href="../docbook/xsl/html/chunk.xsl"/>
-
-</xsl:stylesheet>
Index: kdoctools/customization/kde-man.xsl
===================================================================
--- kdoctools/customization/kde-man.xsl (revisione 1179901)
+++ kdoctools/customization/kde-man.xsl (copia locale)
@@ -1,142 +0,0 @@
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
-<!-- vim:set syntax=xml ts=2 et: -->
-<xsl:import href="kde-include-man.xsl"/>
-
-<!-- Disable the automatically generated AUTHORS section by overloading the
-  respective template and making it a no-op. -->
-<xsl:template match="articleinfo|bookinfo|refentryinfo" mode="authorsect"/>
-<xsl:param name="chunker.output.encoding" select="'UTF-8'"/>
-<xsl:output method="text" encoding="UTF-8" indent="no"/>
-<!--
-  Copied from ../docbook/xsl/manpages/docbook.xsl and changed it so that the
-  output file's name is harccoded to 'manpage.troff', and the quiet parameter
-  is set to 1 to avoid the 'Writing foo.X' message which write.text.chunk
-  prints.
-  -->
-<xsl:template match="refentry">
-
-  <xsl:variable name="section">
-    <xsl:choose>
-      <xsl:when test="refmeta/manvolnum">
-        <xsl:value-of select="refmeta/manvolnum[1]"/>
-      </xsl:when>
-      <xsl:when test=".//funcsynopsis">3</xsl:when>
-      <xsl:otherwise>1</xsl:otherwise>
-    </xsl:choose>
-  </xsl:variable>
-
-  <xsl:variable name="name" select="refnamediv/refname[1]"/>
-
-  <!-- standard man page width is 64 chars; 6 chars needed for the two
-       (x) volume numbers, and 2 spaces, leaves 56 -->
-  <xsl:variable name="twidth" select="(56 - string-length(refmeta/refentrytitle)) div 2"/>
-
-  <xsl:variable name="reftitle"
- select="substring(refmeta/refentrytitle, 1, $twidth)"/>
-
-  <xsl:variable name="title">
-    <xsl:choose>
-      <xsl:when test="refentryinfo/title">
-        <xsl:value-of select="refentryinfo/title"/>
-      </xsl:when>
-      <xsl:when test="../referenceinfo/title">
-        <xsl:value-of select="../referenceinfo/title"/>
-      </xsl:when>
-    </xsl:choose>
-  </xsl:variable>
-
-  <xsl:variable name="date">
-    <xsl:choose>
-      <xsl:when test="refentryinfo/date">
-        <xsl:value-of select="refentryinfo/date"/>
-      </xsl:when>
-      <xsl:when test="../referenceinfo/date">
-        <xsl:value-of select="../referenceinfo/date"/>
-      </xsl:when>
-    </xsl:choose>
-  </xsl:variable>
-
-  <xsl:variable name="productname">
-    <xsl:choose>
-      <xsl:when test="refentryinfo/productname">
-        <xsl:value-of select="refentryinfo/productname"/>
-      </xsl:when>
-      <xsl:when test="../referenceinfo/productname">
-        <xsl:value-of select="../referenceinfo/productname"/>
-      </xsl:when>
-    </xsl:choose>
-  </xsl:variable>
-
-  <xsl:variable name="filename">
-    <xsl:text>manpage.troff</xsl:text>
-  </xsl:variable>
-
-  <xsl:call-template name="write.text.chunk">
-    <xsl:with-param name="quiet" select="1"/>
-    <xsl:with-param name="filename" select="$filename"/>
-    <xsl:with-param name="content">
-      <xsl:text>.\"Generated by db2man.xsl. Don't modify this, modify the source.
-.de Sh \" Subsection
-.br
-.if t .Sp
-.ne 5
-.PP
-\fB\\$1\fR
-.PP
-..
-.de Sp \" Vertical space (when we can't use .PP)
-.if t .sp .5v
-.if n .sp
-..
-.de Ip \" List item
-.br
-.ie \\n(.$>=3 .ne \\$3
-.el .ne 3
-.IP "\\$1" \\$2
-..
-.TH "</xsl:text>
-      <xsl:value-of select="translate($reftitle,'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
-      <xsl:text>" </xsl:text>
-      <xsl:value-of select="$section"/>
-      <xsl:text> "</xsl:text>
-      <xsl:value-of select="normalize-space($date)"/>
-      <xsl:text>" "</xsl:text>
-      <xsl:value-of select="normalize-space($productname)"/>
-      <xsl:text>" "</xsl:text>
-      <xsl:value-of select="$title"/>
-      <xsl:text>"
-</xsl:text>
-      <xsl:apply-templates/>
-      <xsl:text> </xsl:text>
-
-      <!-- Author section -->
-      <xsl:choose>
-        <xsl:when test="refentryinfo//author">
-          <xsl:apply-templates select="refentryinfo" mode="authorsect"/>
-        </xsl:when>
-        <xsl:when test="/book/bookinfo//author">
-          <xsl:apply-templates select="/book/bookinfo" mode="authorsect"/>
-        </xsl:when>
-        <xsl:when test="/article/articleinfo//author">
-          <xsl:apply-templates select="/article/articleinfo" mode="authorsect"/>
-        </xsl:when>
-      </xsl:choose>
-
-    </xsl:with-param>
-  </xsl:call-template>
-  <!-- Now generate stub include pages for every page documented in
-       this refentry (except the page itself) -->
-  <xsl:for-each select="refnamediv/refname">
-    <xsl:if test=". != $name">
-      <xsl:call-template name="write.text.chunk">
- <xsl:with-param name="filename"
-        select="concat(normalize-space(.), '.', $section)"/>
- <xsl:with-param name="content" select="concat('.so man',
-      $section, '/', $name, '.', $section, ' ')"/>
-      </xsl:call-template>
-    </xsl:if>
-  </xsl:for-each>
-</xsl:template>
-
-</xsl:stylesheet>
-
Index: kdoctools/customization/kde-include-man.xsl
===================================================================
--- kdoctools/customization/kde-include-man.xsl (revisione 1179901)
+++ kdoctools/customization/kde-include-man.xsl (copia locale)
@@ -1,6 +0,0 @@
-<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- version="1.0">
-
-   <xsl:import href="../docbook/xsl/manpages/docbook.xsl"/>
-
-</xsl:stylesheet>
Index: cmake/modules/KDE4Macros.cmake
===================================================================
--- cmake/modules/KDE4Macros.cmake (revisione 1179901)
+++ cmake/modules/KDE4Macros.cmake (copia locale)
@@ -281,10 +281,10 @@
 
    #Bootstrap
    if (_kdeBootStrapping)
-      set(_ssheet ${CMAKE_SOURCE_DIR}/kdoctools/customization/kde-chunk.xsl)
+      set(_ssheet "${CMAKE_BINARY_DIR}/kdoctools/customization/kde-chunk.xsl")
       set(_bootstrapOption "--srcdir=${CMAKE_BINARY_DIR}/kdoctools/")
    else (_kdeBootStrapping)
-      set(_ssheet ${KDE4_DATA_INSTALL_DIR}/ksgmltools2/customization/kde-chunk.xsl)
+      set(_ssheet "${KDE4_DATA_INSTALL_DIR}/ksgmltools2/customization/kde-chunk.xsl")
       set(_bootstrapOption)
    endif (_kdeBootStrapping)
 
@@ -360,10 +360,10 @@
 
    #Bootstrap
    if (_kdeBootStrapping)
-      set(_ssheet "${CMAKE_SOURCE_DIR}/kdoctools/docbook/xsl/manpages/docbook.xsl")
+      set(_ssheet "${CMAKE_BINARY_DIR}/kdoctools/customization/kde-include-man.xsl")
       set(_bootstrapOption "--srcdir=${CMAKE_BINARY_DIR}/kdoctools/")
    else (_kdeBootStrapping)
-      set(_ssheet "${KDE4_DATA_INSTALL_DIR}/ksgmltools2/docbook/xsl/manpages/docbook.xsl")
+      set(_ssheet "${KDE4_DATA_INSTALL_DIR}/ksgmltools2/customization/kde-include-man.xsl")
       set(_bootstrapOption)
    endif (_kdeBootStrapping)
 


_______________________________________________
kde-docbook mailing list
kde-docbook@...
https://mail.kde.org/mailman/listinfo/kde-docbook

 « Return to Thread: External Docbook XSLT: status update