]> granicus.if.org Git - docbook-dsssl/commitdiff
My classlist script
authorNorman Walsh <ndw@nwalsh.com>
Tue, 26 Oct 2004 13:47:30 +0000 (13:47 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Tue, 26 Oct 2004 13:47:30 +0000 (13:47 +0000)
cvstools/classlist [new file with mode: 0755]
cvstools/flatten
cvstools/saxon
cvstools/untidy
cvstools/xalan
cvstools/xjparse
cvstools/xslt
cvstools/xsltproc

diff --git a/cvstools/classlist b/cvstools/classlist
new file mode 100755 (executable)
index 0000000..cf87956
--- /dev/null
@@ -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";
index 1a8399f4b19d49b19dcb40435cf328108f0107fb..82b6cd41b7b39c21b4de16b82402a5c066a1a9de 100755 (executable)
@@ -29,7 +29,7 @@ foreach $ent (keys %entity) {
 
 print "<!-- *********************************************************************
      *** THIS IS THE FLATTENED DTD. DO NOT EDIT THIS DTD BY HAND, EDIT ***
-     *** THE CUSTOMIZATION LAYER AND REGNERATE THE FLATTENED DTD! ********
+     *** THE CUSTOMIZATION LAYER AND REGENERATE THE FLATTENED DTD! ********
      ********************************************************************* -->\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) {
index f8dbdd4ac37730cfd2e619afb78e2a90734b1d5f..a6707c16f4d5e486f4bb8f9c2babb99d21a0cf4d 100755 (executable)
@@ -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
index 05ca151081df873c6f19e7b3f77b2bced67aeffc..8b375e9082e158fe84589d361aa1e4e3af4a643f 100755 (executable)
@@ -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 (<F>) {
        $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/(<a\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 (<F>) {
+#      $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/(<a\s[^>]+>)\s+/$1/sg;
+    $content =~ s/\s+(<\/a>)/$1/sg;
+
+    my $newContent = "";
 
-       $content =~ s/(<a\s[^>]+>)\s+/$1/sg;
-       $content =~ s/\s+(<\/a>)/$1/sg;
+    # workaround a bug in tidy...it removes &nbsp; sometimes!
+    while ($content
+            =~ /^(.*?)(<div class=([\'\"])literallayout\3.*?>)(.*?)(<\/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;
+}
 
index fa9e757f14a9395a03fa5207693dafe8debdbf24..9e8d2304975d7ccfb94b1f7a2d0abca62cc29053 100755 (executable)
@@ -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
index 167f1fabb3702edb04727184afdaed0388383ffb..5e2caaf8d339aa2002b366a2cf1fbfbe5a4316ff 100755 (executable)
@@ -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 $*
index dc1e71fab0fdc978a38e56c779565abebf1af627..9aea61fba6d0a1833858a5cd34e8b712bc935317 100755 (executable)
@@ -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;
index f4a2c6488c859a7e585b593e8a7d53c591a9c272..a43efbf6e8a79b9775109b682acd13118645e783 100755 (executable)
@@ -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 ""