@@ -85,6 +85,8 @@ function usage() // {{{
8585 --with-php=PATH Path to php CLI executable [detect]
8686 --with-lang=LANG Language to build [ {$ acd ['LANG ' ]}]
8787 --with-partial=my-xml-id Root ID to build (e.g. <book xml:id="MY-ID">) [ {$ acd ['PARTIAL ' ]}]
88+ --with-jing=auto|yes|no Validate with Jing (requires Java) instead of
89+ libxml [ {$ acd ['JING ' ]}]
8890 --disable-broken-file-listing Do not ignore translated files in
8991 broken-files.txt
9092 --disable-xpointer-reporting Do not show XInclude/XPointer failures. Only effective
@@ -294,6 +296,7 @@ function find_xml_files($path) // {{{
294296 'TRANSLATION_ONLY_INCL_BEGIN ' => '' ,
295297 'TRANSLATION_ONLY_INCL_END ' => '' ,
296298 'XPOINTER_REPORTING ' => 'yes ' ,
299+ 'JING ' => 'auto ' ,
297300); // }}}
298301
299302$ ac = $ acd ;
@@ -425,6 +428,14 @@ function find_xml_files($path) // {{{
425428 $ ac ['XPOINTER_REPORTING ' ] = $ v ;
426429 break ;
427430
431+ case 'jing ' :
432+ if (!in_array ($ v , ['auto ' , 'yes ' , 'no ' ], true )) {
433+ errbox ("Invalid value for --with-jing: $ v (expected auto, yes or no) " );
434+ errors_are_bad (1 );
435+ }
436+ $ ac ['JING ' ] = $ v ;
437+ break ;
438+
428439 case '' :
429440 break ;
430441
@@ -989,11 +1000,15 @@ function xml_validate( $dom )
9891000
9901001 // Jing is faster, but depends on Java.
9911002
992- $ out = null ;
993- $ ret = null ;
994- exec ( "java -version 2>&1 " , $ out , $ ret );
1003+ $ jing = $ GLOBALS ['ac ' ]['JING ' ];
9951004
996- if ( $ ret == 0 )
1005+ if ( $ jing === 'auto ' )
1006+ {
1007+ exec ( "java -version 2>&1 " , $ out , $ ret );
1008+ $ jing = $ ret === 0 ? 'yes ' : 'no ' ;
1009+ }
1010+
1011+ if ( $ jing === 'yes ' )
9971012 xml_validate_jing ();
9981013 else
9991014 xml_validate_libxml ( $ dom );
@@ -1006,16 +1021,11 @@ function xml_validate_jing()
10061021
10071022 echo "Validating temp/manual.xml (jing)... " ;
10081023
1009- $ out = null ;
1010- $ ret = null ;
10111024 $ schema = RNG_SCHEMA_FILE ;
10121025 $ cmdJing = "java -Djdk.xml.totalEntitySizeLimit=300000 -jar {$ srcdir }/docbook/jing.jar {$ schema } {$ idempath }" ;
10131026 exec ( $ cmdJing , $ out , $ ret );
10141027
1015- if ( ! is_array ( $ out ) )
1016- $ out = [];
1017-
1018- if ( $ ret == 0 )
1028+ if ( $ ret === 0 )
10191029 {
10201030 echo "done. \n" ;
10211031 return ;
0 commit comments