Skip to content

Commit

Permalink
Complete the split between pur XSLT and Docbook specific part.
Browse files Browse the repository at this point in the history
This avoids Docbook specific stuff in the (Find|Use)Xslt.cmake files.
Also add the files to the distribution and update the doc dir.
  • Loading branch information
hsattler committed May 23, 2009
1 parent d5253dd commit ee92308
Show file tree
Hide file tree
Showing 6 changed files with 183 additions and 127 deletions.
40 changes: 40 additions & 0 deletions CMakeModules/FindDocbook.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

find_file ( JAVA_DOCBOOK_XSL_SAXON_LIBRARY
NAMES docbook-xsl-saxon_1.00.jar
PATH_SUFFIXES share/java
DOC "location of saxon 6.5.x DocBook XSL extension JAR file"
CMAKE_FIND_ROOT_PATH_BOTH
)
mark_as_advanced ( JAVA_DOCBOOK_XSL_SAXON_LIBRARY )
set ( Xslt_SAXON_EXTENSIONS "${JAVA_DOCBOOK_XSL_SAXON_LIBRARY}" )

find_package ( Xslt )
if ( Xslt_FOUND )
if ( NOT DOCBOOK_XSLT_PROCESSOR )
if ( XSLT_XSLTPROC_EXECUTABLE )
set ( DOCBOOK_XSLT_PROCESSOR "xsltproc" )
elseif ( XSLT_SAXON_COMMAND AND JAVA_DOCBOOK_XSL_SAXON_LIBRARY )
set ( DOCBOOK_XSLT_PROCESSOR "saxon" )
elseif ( XSLT_XALAN2_COMMAND )
set ( DOCBOOK_XSLT_PROCESSOR "xalan2" )
endif ( XSLT_XSLTPROC_EXECUTABLE )
endif ( NOT DOCBOOK_XSLT_PROCESSOR )

set ( DOCBOOK_XSLT_PROCESSOR "${DOCBOOK_XSLT_PROCESSOR}"
CACHE STRING "Docbook XSLT processor select (xsltproc, xalan2 or saxon)" )
set ( XSLT_PROCESSOR "${DOCBOOK_XSLT_PROCESSOR}" )

if ( DOCBOOK_XSLT_PROCESSOR )
set ( Docbook_FOUND true )
set ( Docbook_USE_FILE UseDocbook )
endif ( DOCBOOK_XSLT_PROCESSOR )
endif ( Xslt_FOUND )

if ( NOT Docbook_FOUND )
if ( NOT Docbook_FIND_QUIETLY )
message ( STATUS "No support Docbooked XSLT found." )
endif ( NOT Docbook_FIND_QUIETLY )
if ( Docbook_FIND_REQUIRED )
message ( FATAL_ERROR "No support Docbooked XSLT found but it is required." )
endif ( Docbook_FIND_REQUIRED )
endif ( NOT Docbook_FOUND )
73 changes: 35 additions & 38 deletions CMakeModules/FindXslt.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
# can be used for docbook.
#
# The following important variables are created:
# SAXON_COMMAND
# XALAN2_COMMAND
# XSLTPROC
# XSLT_SAXON_COMMAND
# XSLT_XALAN2_COMMAND
# XSLT_XSLTPROC_EXECUTABLE
# Xslt_FOUND
#
find_package ( Java )
if ( JAVA_RUNTIME )
if ( NOT JAVA_CLASSPATH )
set ( JAVA_CLASSPATH $ENV{CLASSPATH} CACHE STRING "java classpath" )
endif ( NOT JAVA_CLASSPATH )
set ( CLASSPATH ${JAVA_CLASSPATH} )
set ( Xslt_CLASSPATH ${JAVA_CLASSPATH} )

find_file ( JAVA_RESOLVER_LIBRARY
NAMES resolver.jar xml-commons-resolver-1.1.jar
Expand All @@ -24,11 +24,11 @@ if ( JAVA_RUNTIME )
)
mark_as_advanced ( JAVA_RESOLVER_LIBRARY )
if ( JAVA_RESOLVER_LIBRARY )
if ( CLASSPATH )
set ( CLASSPATH "${CLASSPATH}:${JAVA_RESOLVER_LIBRARY}" )
else ( CLASSPATH )
set ( CLASSPATH "${JAVA_RESOLVER_LIBRARY}" )
endif ( CLASSPATH )
if ( Xslt_CLASSPATH )
set ( Xslt_CLASSPATH "${Xslt_CLASSPATH}:${JAVA_RESOLVER_LIBRARY}" )
else ( Xslt_CLASSPATH )
set ( Xslt_CLASSPATH "${JAVA_RESOLVER_LIBRARY}" )
endif ( Xslt_CLASSPATH )
endif ( JAVA_RESOLVER_LIBRARY )

find_path ( JAVA_PROPERTIES_CATALOGMANAGER
Expand All @@ -40,11 +40,11 @@ if ( JAVA_RUNTIME )
)
mark_as_advanced ( JAVA_PROPERTIES_CATALOGMANAGER )
if ( JAVA_PROPERTIES_CATALOGMANAGER )
if ( CLASSPATH )
set ( CLASSPATH "${CLASSPATH}:${JAVA_PROPERTIES_CATALOGMANAGER}" )
else ( CLASSPATH )
set ( CLASSPATH "${JAVA_PROPERTIES_CATALOGMANAGER}" )
endif ( CLASSPATH )
if ( Xslt_CLASSPATH )
set ( Xslt_CLASSPATH "${Xslt_CLASSPATH}:${JAVA_PROPERTIES_CATALOGMANAGER}" )
else ( Xslt_CLASSPATH )
set ( Xslt_CLASSPATH "${JAVA_PROPERTIES_CATALOGMANAGER}" )
endif ( Xslt_CLASSPATH )
endif ( JAVA_PROPERTIES_CATALOGMANAGER )

#
Expand Down Expand Up @@ -72,13 +72,15 @@ if ( JAVA_RUNTIME )
)
mark_as_advanced ( JAVA_XERCES_IMPL_LIBRARY )
if ( XALAN2 AND JAVA_XML_APIS_LIBRARY AND JAVA_XERCES_IMPL_LIBRARY )
set ( XALAN2_COMMAND
${JAVA_RUNTIME}
-cp "${CLASSPATH}:${XALAN2}:${JAVA_XML_APIS_LIBRARY}:${JAVA_XERCES_IMPL_LIBRARY}"
org.apache.xalan.xslt.Process
set ( Xslt_XALAN2_CLASSPATH "${Xslt_CLASSPATH}:${XALAN2}:${JAVA_XML_APIS_LIBRARY}:${JAVA_XERCES_IMPL_LIBRARY}" )
if ( Xslt_XALAN2_EXTENSIONS )
set ( Xslt_XALAN2_CLASSPATH "${Xslt_XALAN2_CLASSPATH}:${Xslt_XALAN2_EXTENSIONS}" )
endif ( Xslt_XALAN2_EXTENSIONS )
set ( XSLT_XALAN2_COMMAND
${JAVA_RUNTIME} -cp "${Xslt_XALAN2_CLASSPATH}" org.apache.xalan.xslt.Process
)
if ( JAVA_RESOLVER_LIBRARY AND JAVA_PROPERTIES_CATALOGMANAGER )
list ( APPEND XALAN2_COMMAND
list ( APPEND XSLT_XALAN2_COMMAND
-ENTITYRESOLVER org.apache.xml.resolver.tools.CatalogResolver
-URIRESOLVER org.apache.xml.resolver.tools.CatalogResolver
)
Expand All @@ -95,45 +97,40 @@ if ( JAVA_RUNTIME )
CMAKE_FIND_ROOT_PATH_BOTH
)
mark_as_advanced ( SAXON )
find_file ( JAVA_DOCBOOK_XSL_SAXON_LIBRARY
NAMES docbook-xsl-saxon_1.00.jar
PATH_SUFFIXES share/java
DOC "location of saxon 6.5.x DocBook XSL extension JAR file"
CMAKE_FIND_ROOT_PATH_BOTH
)
mark_as_advanced ( JAVA_DOCBOOK_XSL_SAXON_LIBRARY )
if ( SAXON AND JAVA_DOCBOOK_XSL_SAXON_LIBRARY )
set ( SAXON_COMMAND
${JAVA_RUNTIME}
-cp "${CLASSPATH}:${SAXON}:${JAVA_DOCBOOK_XSL_SAXON_LIBRARY}"
com.icl.saxon.StyleSheet
if ( SAXON )
set ( Xslt_SAXON_CLASSPATH "${Xslt_CLASSPATH}:${SAXON}" )
if ( Xslt_SAXON_EXTENSIONS )
set ( Xslt_SAXON_CLASSPATH "${Xslt_SAXON_CLASSPATH}:${Xslt_SAXON_EXTENSIONS}" )
endif ( Xslt_SAXON_EXTENSIONS )
set ( XSLT_SAXON_COMMAND
${JAVA_RUNTIME} -cp "${Xslt_SAXON_CLASSPATH}" com.icl.saxon.StyleSheet
)
if ( JAVA_RESOLVER_LIBRARY )
list ( APPEND SAXON_COMMAND
list ( APPEND XSLT_SAXON_COMMAND
-x org.apache.xml.resolver.tools.ResolvingXMLReader
-y org.apache.xml.resolver.tools.ResolvingXMLReader
-u
)
if ( JAVA_PROPERTIES_CATALOGMANAGER )
list ( APPEND SAXON_COMMAND
list ( APPEND XSLT_SAXON_COMMAND
-r org.apache.xml.resolver.tools.CatalogResolver
)
endif ( JAVA_PROPERTIES_CATALOGMANAGER )
endif ( JAVA_RESOLVER_LIBRARY )
endif ( SAXON AND JAVA_DOCBOOK_XSL_SAXON_LIBRARY )
endif ( SAXON )
endif ( JAVA_RUNTIME )

find_program ( XSLTPROC
find_program ( XSLT_XSLTPROC_EXECUTABLE
NAMES xsltproc
DOC "path to the libxslt XSLT processor xsltproc"
)
mark_as_advanced ( XSLTPROC )
mark_as_advanced ( XSLT_XSLTPROC_EXECUTABLE )

set ( Xslt_USE_FILE UseXslt )

if ( XSLTPROC OR SAXON_COMMAND OR XALAN2_COMMAND )
if ( XSLT_XSLTPROC_EXECUTABLE OR XSLT_SAXON_COMMAND OR XSLT_XALAN2_COMMAND )
set ( Xslt_FOUND true )
endif ( XSLTPROC OR SAXON_COMMAND OR XALAN2_COMMAND )
endif ( XSLT_XSLTPROC_EXECUTABLE OR XSLT_SAXON_COMMAND OR XSLT_XALAN2_COMMAND )

if ( NOT Xslt_FOUND )
if ( NOT Xslt_FIND_QUIETLY )
Expand Down
46 changes: 19 additions & 27 deletions CMakeModules/UseDocbook.cmake
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@

find_package ( Xslt )
if ( NOT DOCBOOK_XSLT_PROCESSOR )
if ( XSLTPROC )
set ( DOCBOOK_XSLT_PROCESSOR "xsltproc" )
elseif ( SAXON_COMMAND )
set ( DOCBOOK_XSLT_PROCESSOR "saxon" )
elseif ( XALAN2_COMMAND )
set ( DOCBOOK_XSLT_PROCESSOR "xalan2" )
endif ( XSLTPROC )
endif ( NOT DOCBOOK_XSLT_PROCESSOR )

set ( DOCBOOK_XSLT_PROCESSOR "${DOCBOOK_XSLT_PROCESSOR}"
CACHE STRING "Docbook XSLT processor select (xsltproc, xalan2 or saxon)" )
set ( XSLT_PROCESSOR "${DOCBOOK_XSLT_PROCESSOR}" )
include ( ${Xslt_USE_FILE} )

set ( DOCBOOK_XSL_PREFIX "http://docbook.sourceforge.net/release/xsl/current"
if ( NOT DOCBOOK_XSL_VERSION )
set ( DOCBOOK_XSL_VERSION current )
endif ( NOT DOCBOOK_XSL_VERSION )
set ( DOCBOOK_XSL_PREFIX "http://docbook.sourceforge.net/release/xsl/${DOCBOOK_XSL_VERSION}"
CACHE STRING "prefix to locate the docbook-XSL release files" )
mark_as_advanced ( DOCBOOK_XSL_PREFIX )

Expand All @@ -36,19 +25,19 @@ function ( _DOCBOOK_GET_MANPAGE_IDS inFile outNameList )
string ( REGEX MATCHALL "<refentry[ ]+.*</refentry>" ENTRIES "${XML_FILE_CONTENTS}" )
string ( REPLACE "</refentry>" ";" ENTRIES "${ENTRIES}" )
list ( LENGTH ENTRIES COUNT )
math ( EXPR COUNT "${COUNT} - 1" )
foreach ( index RANGE ${COUNT} )
if ( index LESS COUNT )
list ( GET ENTRIES ${index} entry )
string ( REGEX MATCH "<refentry[ ]+[^>]*" MANPAGE_NAME "${entry}" )
string ( REGEX REPLACE ".*id=\"([^\"]*)\".*" "\\1" MANPAGE_NAME "${MANPAGE_NAME}" )

string ( REGEX MATCH "<manvolnum>[^<]*" MANPAGE_VOLUME "${entry}" )
string ( REGEX REPLACE "^<manvolnum>" "" MANPAGE_VOLUME "${MANPAGE_VOLUME}" )
string ( REGEX REPLACE "[[:space:]]" "" MANPAGE_VOLUME "${MANPAGE_VOLUME}" )
if ( MANPAGE_NAME AND MANPAGE_VOLUME )
list ( APPEND FILES "${MANPAGE_NAME}.${MANPAGE_VOLUME}" )
endif ( MANPAGE_NAME AND MANPAGE_VOLUME )
endif ( index LESS COUNT )
list ( GET ENTRIES ${index} entry )
string ( REGEX MATCH "<refname>[^<]*" MANPAGE_NAME "${entry}" )
string ( REGEX REPLACE "^<refname>" "" MANPAGE_NAME "${MANPAGE_NAME}" )
string ( REGEX REPLACE "[[:space:]]" "" MANPAGE_NAME "${MANPAGE_NAME}" )

string ( REGEX MATCH "<manvolnum>[^<]*" MANPAGE_VOLUME "${entry}" )
string ( REGEX REPLACE "^<manvolnum>" "" MANPAGE_VOLUME "${MANPAGE_VOLUME}" )
string ( REGEX REPLACE "[[:space:]]" "" MANPAGE_VOLUME "${MANPAGE_VOLUME}" )
if ( MANPAGE_NAME AND MANPAGE_VOLUME )
list ( APPEND FILES "${MANPAGE_NAME}.${MANPAGE_VOLUME}" )
endif ( MANPAGE_NAME AND MANPAGE_VOLUME )
endforeach ( index )
set ( ${outNameList} ${FILES} PARENT_SCOPE )
endfunction ( )
Expand All @@ -74,6 +63,9 @@ function ( _DOCBOOK_HTML inFile outList )
# one or more refentries.
list ( APPEND FILES index.html )

set ( XSLT_PARAMS
"use.id.as.filename=1"
)
xsl_transform (
"${DOCBOOK_XSL_PREFIX}/xhtml/chunk.xsl"
"${inFile}"
Expand Down
52 changes: 37 additions & 15 deletions CMakeModules/UseXslt.cmake
Original file line number Diff line number Diff line change
@@ -1,28 +1,50 @@
#
# call as XSLT_TRANSFORM(<.xsl file URL> <input file> <output files...>)
#
# The following variables are supported:
# XSLT_PROCESSOR (mandatory):
# select the xslt processor to use (xsltproc, xalan2, saxon)
# XSLT_PARAMS (optional):
# a list which may contain param=value entries.
# XSLT_(XSLTPROC|XALAN2|SAXON)_OPTIONS (optional):
# a list with extra options for those xslt processors.
#
function ( XSL_TRANSFORM xslurl infile )
if ( XSLT_PARAMS )
foreach ( param ${XSLT_PARAMS} )
set ( param_name )
string ( REGEX MATCH "[^=]+" param_name "${param}" )
if ( param_name )
set ( param_value )
string ( REGEX REPLACE "[^=]+=(.*)" "\\1" param_value "${param}" )
set ( XSLT_XSLTPROC_OPTIONS ${XSLT_XSLTPROC_OPTIONS} --param ${param_name} ${param_value} )
set ( XSLT_XALAN2_OPTIONS ${XSLT_XALAN2_OPTIONS} -param ${param_name} ${param_value} )
endif ( param_name )
endforeach ( param )
endif ( XSLT_PARAMS )

if ( XSLT_PROCESSOR STREQUAL "xsltproc" )
if ( XSLTPROC )
if ( XSLT_XSLTPROC_EXECUTABLE )
set ( XSL_TRANSFORM_COMMAND
${XSLTPROC}
--param use.id.as.filename 1
${XSLT_XSLTPROC_EXECUTABLE}
${XSLT_XSLTPROC_OPTIONS}
"${xslurl}" "${infile}"
)
else ( XSLTPROC )
else ( XSLT_XSLTPROC_EXECUTABLE )
message ( FATAL_ERROR "xsltproc not found" )
endif ( XSLTPROC )
endif ( XSLT_XSLTPROC_EXECUTABLE )

elseif ( XSLT_PROCESSOR STREQUAL "saxon" )
if ( SAXON_COMMAND )
if ( XSLT_SAXON_COMMAND )
set ( XSL_TRANSFORM_COMMAND
${SAXON_COMMAND}
${XSLT_SAXON_COMMAND}
${XSLT_SAXON_OPTIONS}
"${infile}" "${xslurl}"
use.id.as.filename=1
${Xslt_PARAMS}
)
else ( SAXON_COMMAND )
else ( XSLT_SAXON_COMMAND )
message ( FATAL_ERROR "Saxon-6.5.x not found" )
endif ( SAXON_COMMAND )
endif ( XSLT_SAXON_COMMAND )

elseif ( XSLT_PROCESSOR STREQUAL "xalan2" )
# Xalan places the output in the source file's directory :-(
Expand All @@ -34,15 +56,15 @@ function ( XSL_TRANSFORM xslurl infile )
VERBATIM
)
set ( infile "${CMAKE_CURRENT_BINARY_DIR}/${infile_name}" )
if ( XALAN2_COMMAND )
if ( XSLT_XALAN2_COMMAND )
set ( XSL_TRANSFORM_COMMAND
${XALAN2_COMMAND}
-param use.id.as.filename 1
${XSLT_XALAN2_COMMAND}
${XSLT_XALAN2_OPTIONS}
-in "${infile}" -xsl "${xslurl}"
)
else ( XALAN2_COMMAND )
else ( XSLT_XALAN2_COMMAND )
message ( FATAL_ERROR " Xalan 2.x not found" )
endif ( XALAN2_COMMAND )
endif ( XSLT_XALAN2_COMMAND )

else ( XSLT_PROCESSOR STREQUAL "xsltproc" )
message ( FATAL_ERROR "Unsupported XSLT processor" )
Expand Down
4 changes: 3 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ DISTCHECK_CONFIGURE_FLAGS = --enable-apps

EXTRA_DIST = openobex.m4 CMakeLists.txt \
CMakeModules/FindBluetooth.cmake CMakeModules/FindGlib.cmake \
CMakeModules/FindIrda.cmake CMakeModules/FindLibUSB.cmake
CMakeModules/FindIrda.cmake CMakeModules/FindLibUSB.cmake \
CMakeModules/FindXslt.cmake CMakeModules/UseXslt.cmake \
CMakeModules/FindDocbook.cmake CMakeModules/UseDocbook.cmake

DISTCLEANFILES = $(pkgconfig_DATA)

Expand Down
Loading

0 comments on commit ee92308

Please sign in to comment.