From 8d4be6ddcbfff424020f84b46acb7ddaab3f4cd5 Mon Sep 17 00:00:00 2001 From: Norman Walsh Date: Tue, 26 Oct 2004 13:47:30 +0000 Subject: [PATCH] My classlist script --- cvstools/classlist | 19 ++++++++ cvstools/flatten | 23 ++++++--- cvstools/saxon | 89 +++++++++++++++++++++++++++++----- cvstools/untidy | 117 +++++++++++++++++++++++++++++++++++++-------- cvstools/xalan | 7 ++- cvstools/xjparse | 3 +- cvstools/xslt | 8 ++++ cvstools/xsltproc | 2 +- 8 files changed, 228 insertions(+), 40 deletions(-) create mode 100755 cvstools/classlist diff --git a/cvstools/classlist b/cvstools/classlist new file mode 100755 index 000000000..cf87956d8 --- /dev/null +++ b/cvstools/classlist @@ -0,0 +1,19 @@ +#!/usr/bin/perl -- # --*-Perl-*-- + +my $VPATH = shift; + +chdir($VPATH) if $VPATH; + +@files = glob("*.java"); + +print "CLASSFILES="; + +while (@files) { + $file = shift @files; + $file =~ s/\.java$/\.class/; + print "$file "; + print "\\" if @files; + print "\n"; +} + +print "\n"; diff --git a/cvstools/flatten b/cvstools/flatten index 1a8399f4b..82b6cd41b 100755 --- a/cvstools/flatten +++ b/cvstools/flatten @@ -29,7 +29,7 @@ foreach $ent (keys %entity) { print "\n\n"; open (F, $dtd); @@ -51,15 +51,26 @@ sub read_dtd { local(*F, $_); # HACK HACK HACK - if ($dtd =~ /http:\/\/www.oasis-open.org\/docbook\/xml\/simple\/.*\/([^\/]+)$/) { - print STDERR "match: $1\n"; + if ($dtd =~ /http:\/\/www.oasis-open.org\/docbook\/xml\/simple\/.*\/([^\/]+)$/ + || $dtd =~ /http:\/\/docbook.org\/xml\/simple\/.*\/([^\/]+)$/) { + print STDERR "$dtd ==>\n"; $dtd = "/sourceforge/docbook/docbook/simple/$1"; + print STDERR "\t$dtd\n"; } # HACK HACK HACK - if ($dtd =~ /http:\/\/www.oasis-open.org\/docbook\/xml\/.*?\// - || $dtd =~ /http:\/\/docbook.org\/xml\/.*?\//) { - $dtd = "/sourceforge/docbook/docbook/xml/$'"; + if ($dtd =~ /http:\/\/www.oasis-open.org\/docbook\/xml\/(.*)$/ + || $dtd =~ /http:\/\/docbook.org\/xml\/(.*)$/) { + print STDERR "$dtd ==>\n"; + $dtd = "/share/websites/docbook/xml/$1"; + print STDERR "\t$dtd\n"; + } + + # HACK HACK HACK + if ($dtd =~ /http:\/\/www.w3.org\/2003\/entities\/(.*)$/) { + print STDERR "$dtd ==>\n"; + $dtd = "/projects/w3c/WWW/2003/entities/$1"; + print STDERR "\t$dtd\n"; } if (! -f $dtd) { diff --git a/cvstools/saxon b/cvstools/saxon index f8dbdd4ac..a6707c16f 100755 --- a/cvstools/saxon +++ b/cvstools/saxon @@ -6,17 +6,17 @@ # DONE=0 -VERSION=652 +VERSION=653 EXTVERSION=643 DEBUG=0 XARG="" YARG="" RARG="" MEMORY="" +VALIDATE="" # which parser to use PARSER=auto - MYDIR=`dirname $0` . $MYDIR/common-functions.sh @@ -38,6 +38,13 @@ while [ "$DONE" = "0" ]; do -6*) VERSION=$1; shift; ;; + -7*) VERSION=$1; + shift; + ;; + -8*) VERSION=$1; + EXTVERSION=8 + shift; + ;; -x) shift; XARG="-x $1"; shift; @@ -61,6 +68,9 @@ while [ "$DONE" = "0" ]; do -q) shift VERBOSE=false ;; + -val) shift + VALIDATE=-val + ;; -v) shift VERBOSE=true ;; @@ -94,8 +104,17 @@ if [ ! -d "$DOCBOOKXSL" ]; then exit 1 fi +# Toss the leading hyphen +VERSION=`echo $VERSION | sed -e 's/^-//'` + case $VERSION in - 652|651|65|644|643) + 8a) + VERSION="sa-8.0"; + ;; + 8b) + VERSION="b8.0"; + ;; + 77|751|653|652|651|65|644|643) : # handled normally below ;; *) echo "unexpected Saxon version $VERSION" 1>&2 @@ -119,13 +138,19 @@ DOTTEDVERSION=`echo $VERSION | sed -e 's/\([0-9]\)\([0-9]\)/\1.\2/g; s/\([0-9]\) ## ## locate saxon.jar ## +SAXON= for jar in "/usr/local/java/saxon-$DOTTEDVERSION/saxon.jar" \ + "/usr/local/java/saxon-$DOTTEDVERSION/saxon7.jar" \ + "/usr/local/java/saxon-$DOTTEDVERSION/saxon8sa.jar" \ + "/usr/local/java/saxon$DOTTEDVERSION/saxon8sa.jar" \ "/usr/local/share/java/saxon-$DOTTEDVERSION/saxon.jar" \ + "/usr/local/share/java/saxon-$DOTTEDVERSION/saxon7.jar" \ + "/usr/local/share/java/saxon$DOTTEDVERSION/saxon8sa.jar" \ "/usr/share/java/saxon-$DOTTEDVERSION.jar" \ "/usr/local/java/saxon/saxon.jar" \ "/usr/local/share/java/saxon/saxon.jar" \ "/usr/share/java/saxon.jar"; do - if [ -f "$jar" ]; then + if [ -f "$jar" -a "$SAXON" = "" ]; then SAXON="$jar" break fi @@ -181,7 +206,7 @@ fi ## These are the settings which control the parser: ## javax.xml.parsers.DocumentBuilderFactory ## javax.xml.parsers.SAXParserFactory -## +## # first choice is xerces2 if [ "$PARSER" = "xerces2" -o "$PARSER" = "auto" ]; then @@ -240,14 +265,56 @@ if [ "$DEBUG" != "0" ]; then TFLAG="-T" fi +HTTP_PROXY= +HTTPS_PROXY= + +if [ "$http_proxy_host" != "" ]; then + HTTP_PROXY="-Dhttp.proxyHost=$http_proxy_host -Dhttp.proxyPort=$http_proxy_port" + HTTPS_PROXY="-Dhttps.proxyHost=$http_proxy_host -Dhttps.proxyPort=$http_proxy_port" +fi + if [ ${VERBOSE} ] && ${VERBOSE}; then - echo java $MEMORY $FOO -cp $CLASSPATH $DBFACTORY $SPFACTORY \ + echo java $MEMORY -cp $CLASSPATH $DBFACTORY $SPFACTORY \ -Djavax.xml.transform.TransformerFactory=$TRANSFACTORY \ - com.icl.saxon.StyleSheet $TFLAG \ + com.icl.saxon.StyleSheet $TFLAG $VALIDATE \ $XARG $YARG $RARG $OUTPUT $XMLSRC $XMLSTY "$@" fi -exec java $MEMORY $FOO -cp $CLASSPATH $DBFACTORY $SPFACTORY \ - -Djavax.xml.transform.TransformerFactory=$TRANSFACTORY \ - com.icl.saxon.StyleSheet $TFLAG \ - $XARG $YARG $RARG $OUTPUT $XMLSRC $XMLSTY "$@" +#echo VERSION=$VERSION + +if [ "$VERSION" = "sa-8.0" ]; then + JAVA_HOME=/usr/local/jdk1.4.2 + JAVA=$JAVA_HOME/bin/java +# exec $JAVA $HTTP_PROXY $HTTPS_PROXY $MEMORY -cp $CLASSPATH $DBFACTORY $SPFACTORY \ +# -Djavax.xml.transform.TransformerFactory=$TRANSFACTORY \ +# com.saxonica.Transform $TFLAG $VALIDATE $SAXONOPT \ +# $XARG $YARG $RARG $OUTPUT $XMLSRC $XMLSTY "$@" + CLASSPATH=/usr/local/java/saxonsa-8.0/saxon8sa.jar:/home/ndw/java + exec $JAVA $HTTP_PROXY $HTTPS_PROXY $MEMORY -cp $CLASSPATH \ + com.saxonica.Transform $TFLAG $VALIDATE $SAXONOPT \ + $OUTPUT $XMLSRC $XMLSTY "$@" +else if [ "$VERSION" = "b8.0" ]; then + JAVA_HOME=/usr/local/jdk1.4.2 + JAVA=$JAVA_HOME/bin/java + CLASSPATH=/usr/local/java/saxonb-8.0/saxon8.jar:/home/ndw/java + echo $JAVA $HTTP_PROXY $HTTPS_PROXY $MEMORY -cp $CLASSPATH \ + net.sf.saxon.Transform $TFLAG $VALIDATE $SAXONOPT \ + $OUTPUT $XMLSRC $XMLSTY "$@" + exec $JAVA $HTTP_PROXY $HTTPS_PROXY $MEMORY -cp $CLASSPATH \ + net.sf.saxon.Transform $TFLAG $VALIDATE $SAXONOPT \ + $OUTPUT $XMLSRC $XMLSTY "$@" +else if [ "$VERSION" = "77" ]; then + JAVA_HOME=/usr/local/jdk1.4.2 + JAVA=$JAVA_HOME/bin/java + exec $JAVA $HTTP_PROXY $HTTPS_PROXY $MEMORY -cp $CLASSPATH $DBFACTORY $SPFACTORY \ + -Djavax.xml.transform.TransformerFactory=$TRANSFACTORY \ + net.sf.saxon.Transform $TFLAG \ + $XARG $YARG $RARG $OUTPUT $XMLSRC $XMLSTY "$@" +else + exec java $HTTP_PROXY $HTTPS_PROXY $MEMORY -cp $CLASSPATH $DBFACTORY $SPFACTORY \ + -Djavax.xml.transform.TransformerFactory=$TRANSFACTORY \ + com.icl.saxon.StyleSheet $TFLAG \ + $XARG $YARG $RARG $OUTPUT $XMLSRC $XMLSTY "$@" +fi +fi +fi \ No newline at end of file diff --git a/cvstools/untidy b/cvstools/untidy index 05ca15108..8b375e908 100755 --- a/cvstools/untidy +++ b/cvstools/untidy @@ -10,14 +10,19 @@ while (@ARGV) { } else { $opts .= " " if $opts ne ""; $opts .= $_; + + if ($_ eq '--doctype') { + $_ = shift @ARGV; + $opts .= " $_"; + } } } -if ($#filenames == 0) { - my $filename = shift @filenames; +foreach my $file (@filenames) { my $content = ""; - open (F, "/usr/bin/tidy $opts $filename |"); + print STDERR "Tidy $file...\n"; + open (F, "/usr/bin/tidy -wrap 512 $opts $file |"); while () { $content .= $_; } @@ -25,33 +30,105 @@ if ($#filenames == 0) { if ($content eq '') { # we must have done an "in-place" tidy - if (open (F, $filename)) { - read (F, $content, -s $filename); + if (open (F, $file)) { + read (F, $content, -s $file); close (F); } } - $content =~ s/(]+>)\s+/$1/sg; - $content =~ s/\s+(<\/a>)/$1/sg; + $content = cleanupContent($content); - open (F, ">$filename"); + open (F, ">$file"); print F $content; close (F); -} else { - system ("/usr/bin/tidy $opts " . join(" ", @filenames)); - foreach my $filename (@filenames) { - if (open (F, $filename)) { - read (F, $content, -s $filename); - close (F); - } +} + +# the old way... +# if ($#filenames == 0) { +# my $filename = shift @filenames; +# my $content = ""; +# +# open (F, "/usr/bin/tidy -wrap 512 $opts $filename |"); +# while () { +# $content .= $_; +# } +# close (F); +# +# if ($content eq '') { +# # we must have done an "in-place" tidy +# if (open (F, $filename)) { +# read (F, $content, -s $filename); +# close (F); +# } +# } +# +# $content = cleanupContent($content); +# +# open (F, ">$filename"); +# print F $content; +# close (F); +# } else { +# system ("/usr/bin/tidy -wrap 512 $opts " . join(" ", @filenames)); +# foreach my $filename (@filenames) { +# if (open (F, $filename)) { +# read (F, $content, -s $filename); +# close (F); +# } +# +# $content = cleanupContent($content); +# +# open (F, ">$filename"); +# print F $content; +# close (F); +# } +# } + +sub cleanupContent { + my $content = shift; + + $content =~ s/(]+>)\s+/$1/sg; + $content =~ s/\s+(<\/a>)/$1/sg; + + my $newContent = ""; - $content =~ s/(]+>)\s+/$1/sg; - $content =~ s/\s+(<\/a>)/$1/sg; + # workaround a bug in tidy...it removes   sometimes! + while ($content + =~ /^(.*?)(
)(.*?)(<\/div>.*)$/is) { + my $pre = $1; + my $starttag = $2; + my $litlayout = $4; + my $post = $5; - open (F, ">$filename"); - print F $content; - close (F); + #print "====$litlayout====\n"; + #print "------------------\n"; + #print "====", addnbsp($litlayout), "====\n"; + + $newContent .= $pre . $starttag . addnbsp($litlayout); + $content = $post; } + + return $newContent . $content; } +sub addnbsp { + my $content = shift; + my $esc = ""; + + while ($content ne "") { + if ($content =~ /^(.*?)(<.*?>)(.*)$/s) { + my $text = $1; + my $tag = $2; + $content = $3; + $text =~ s/ /&\#160;/g; + $esc .= $text . $tag; + } else { + my $text = $content; + $content = ""; + $text =~ s/ /&\#160;/g; + $esc .= $text; + } + } + + return $esc; +} diff --git a/cvstools/xalan b/cvstools/xalan index fa9e757f1..9e8d23049 100755 --- a/cvstools/xalan +++ b/cvstools/xalan @@ -126,7 +126,7 @@ else "${XALANROOT}" \ "${XALANROOT}/xalan2.jar" \ "${XALANROOT}/bin/xalan2.jar" \ - "/projects/apache/xml-xalan/java" \ + "/projects/apache/xml-xalan/java/build/classes" \ "/usr/local/java/xalan-j_${STRIKEVERSION}/bin/xalan.jar" \ "/usr/local/share/java/xalan-j_${STRIKEVERSION}/bin/xalan.jar" \ "/usr/local/share/java/xalan-$STRIKEVERSION.jar" \ @@ -189,8 +189,13 @@ else fi fi +RESOLVERS="" +echo java $MEMORY $SAXPARSER org.apache.xalan.xslt.Process $RESOLVERS $@ + CLASSPATH=`fixclasspath "$NDWEXT:$XALAN:$JAXP:$RESOLVER:$XERCES:$CLASSPATH"` +#echo $CLASSPATH + if [ ${VERBOSE} ] && ${VERBOSE}; then echo java $MEMORY $SAXPARSER org.apache.xalan.xslt.Process $RESOLVERS $@ fi diff --git a/cvstools/xjparse b/cvstools/xjparse index 167f1fabb..5e2caaf8d 100755 --- a/cvstools/xjparse +++ b/cvstools/xjparse @@ -32,8 +32,9 @@ else XREAD=org.apache.xml.resolver.apps.xread fi -CLASSPATH=$RESOLVER:$XERCES:$CLASSPATH +#XREAD=org.apache.xerces.impl.Version +CLASSPATH=$RESOLVER:$XERCES:$CLASSPATH #echo $CLASSPATH exec java $HTTP_PROXY $HTTPS_PROXY -cp $CLASSPATH $XREAD $* diff --git a/cvstools/xslt b/cvstools/xslt index dc1e71fab..9aea61fba 100755 --- a/cvstools/xslt +++ b/cvstools/xslt @@ -10,6 +10,7 @@ my $usage = "Usage: $0 [options] files\n"; my %option = ('debug' => 0, 'quiet' => 0, + 'verbose' => 0, 'time' => 0, 'extensions' => 1, 'version' => undef, @@ -24,6 +25,7 @@ my %opt = (); &GetOptions(\%opt, 'debug+', 'quiet+', + 'verbose', 'time', 'extensions!', 'version=s', @@ -60,6 +62,7 @@ my $outFile = $option{'output'} || shift @args; my $time = $option{'time'}; my $version = $option{'version'}; my $quiet = $option{'quiet'}; +my $verbose = $option{'verbose'}; my $memory = $option{'memory'}; my $debug = $option{'debug'}; @@ -71,6 +74,7 @@ if ($processor eq 'saxon') { $cmd = "$exedir/saxon"; $cmd .= " $procopt" if $procopt; $cmd .= " -q" if $quiet; + $cmd .= " -v" if $verbose; $cmd .= " -d" if $debug; $cmd .= " -$version" if $version; $cmd .= " -m $memory" if $memory; @@ -84,6 +88,7 @@ if ($processor eq 'saxon') { $cmd = "$exedir/xalan"; $cmd .= " $procopt" if $procopt; $cmd .= " -q" if $quiet; + $cmd .= " -v" if $verbose; $cmd .= " -d" if $debug; $cmd .= " -$version" if $version; $cmd .= " -m $memory" if $memory; @@ -96,6 +101,7 @@ if ($processor eq 'saxon') { $cmd = "$exedir/xsltproc"; $cmd .= " $procopt" if $procopt; $cmd .= " -q" if $quiet; + $cmd .= " -v" if $verbose; foreach my $key (keys %param) { $cmd .= " -param $key \"'" . $param{$key} . "'\""; } @@ -105,6 +111,7 @@ if ($processor eq 'saxon') { $cmd = "$exedir/4xslt"; $cmd .= " $procopt" if $procopt; $cmd .= " -q" if $quiet; + $cmd .= " -v" if $verbose; foreach my $key (keys %param) { $cmd .= " --define=$key=\"" . $param{$key} . "\""; } @@ -114,6 +121,7 @@ if ($processor eq 'saxon') { $cmd = "$exedir/xt"; $cmd .= " $procopt" if $procopt; $cmd .= " -q" if $quiet; + $cmd .= " -v" if $verbose; $cmd .= " $xmlFile $xslFile"; $outFile = "-" if $outFile eq ''; $cmd .= " $outFile" if $outFile; diff --git a/cvstools/xsltproc b/cvstools/xsltproc index f4a2c6488..a43efbf6e 100755 --- a/cvstools/xsltproc +++ b/cvstools/xsltproc @@ -28,7 +28,7 @@ if [ "$QUIET" = "0" ]; then echo xsltproc $OPTS "$@" fi -/usr/local/bin/xsltproc --catalogs $OPTS "$@" +/usr/bin/xsltproc --catalogs $OPTS "$@" if [ $? != 0 ]; then echo "" -- 2.40.0