@@ -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,20 @@ 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 !== 'no ' )
1006+ {
1007+ exec ( "java -version 2>&1 " , $ out , $ ret );
1008+ if ( $ ret !== 0 && $ jing === 'yes ' )
1009+ {
1010+ errbox ( "--with-jing=yes was given, but no working java executable was found. " );
1011+ errors_are_bad ( 1 );
1012+ }
1013+ $ jing = $ ret === 0 ? 'yes ' : 'no ' ;
1014+ }
1015+
1016+ if ( $ jing === 'yes ' )
9971017 xml_validate_jing ();
9981018 else
9991019 xml_validate_libxml ( $ dom );
@@ -1006,16 +1026,11 @@ function xml_validate_jing()
10061026
10071027 echo "Validating temp/manual.xml (jing)... " ;
10081028
1009- $ out = null ;
1010- $ ret = null ;
10111029 $ schema = RNG_SCHEMA_FILE ;
1012- $ cmdJing = "java -Djdk.xml.totalEntitySizeLimit=300000 -jar {$ srcdir }/docbook/jing.jar {$ schema } {$ idempath }" ;
1030+ $ cmdJing = "java -Djdk.xml.totalEntitySizeLimit=300000 -jar {$ srcdir }/docbook/jing.jar {$ schema } {$ idempath } 2>&1 " ;
10131031 exec ( $ cmdJing , $ out , $ ret );
10141032
1015- if ( ! is_array ( $ out ) )
1016- $ out = [];
1017-
1018- if ( $ ret == 0 )
1033+ if ( $ ret === 0 )
10191034 {
10201035 echo "done. \n" ;
10211036 return ;
0 commit comments