[tex4ht-commits] [SCM] tex4ht updated: r6 - trunk/lit
karl at gnu.org.ua
karl at gnu.org.ua
Tue Jan 19 02:59:06 CET 2010
Author: karl
Date: 2010-01-19 03:59:06 +0200 (Tue, 19 Jan 2010)
New Revision: 6
Added:
trunk/lit/Makefile
Modified:
trunk/lit/xtpipes.tex
Log:
add copyright notice, in attempt to understand
Added: trunk/lit/Makefile
Modified: trunk/lit/xtpipes.tex
===================================================================
--- trunk/lit/xtpipes.tex 2010-01-19 00:32:33 UTC (rev 5)
+++ trunk/lit/xtpipes.tex 2010-01-19 01:59:06 UTC (rev 6)
@@ -1,3 +1,5 @@
+% xtpipes.tex
+
% generalize -i attribute to accept multiple directories, like for -classpath
% htlatex xtpipes "xhtml,3,next" "" "-d./"
@@ -2,11 +4,27 @@
% htlatex xtpipes "xhtml,3,next,doc" "" "-d./"
-% htlatex xtpipes "xhtml,3,next,win"
-% htlatex xtpipes "xhtml,3,next,win,doc"
+% htlatex xtpipes "xhtml,3,next,win"
+% htlatex xtpipes "xhtml,3,next,win,doc"
% gcj support these ``generics'' with a ``-5'' or ``-1.5'' switch
+% Copyright 1996--2009 Eitan M. Gurari
+% Copyright 2009, 2010 TeX Users Group.
+%
+% This work may be distributed and/or modified under the conditions of
+% the LaTeX Project Public License, either version 1.3c of this license
+% or (at your option) any later version. The latest version of this
+% license is in http://www.latex-project.org/lppl.txt and version 1.3c
+% or later is part of all distributions of LaTeX version 2005/12/01 or later.
+%
+% This work has the LPPL maintenance status "maintained".
+%
+% The Current Maintainer of this work is
+% the TeX4ht Project <http://tug.org/tex4ht>.
+%
+% If you modify this file, changing this signature would be appreciated.
+\message{(<signature>)}
\documentclass{article}
- \usepackage{url}
- \usepackage{verbatim}
+ \usepackage{url}
+ \usepackage{verbatim}
\Configure{ProTex}{java,<<<>>>,title,list,`}
@@ -30,155 +48,155 @@
-\def\CNT{0}
-\bgroup
- \catcode`\^=7
- \catcode`\^^M=13 %
- \gdef\OP#1{%
- \edef\temp{%
- \noexpand\<#1\noexpand\><<<
- \CNT
- >>> %
- } \temp %
- \immediate\write15{...... \CNT\space #1}
- \HAdvance\CNT by 1 %
- } %
-\egroup
+\def\CNT{0}
+\bgroup
+ \catcode`\^=7
+ \catcode`\^^M=13 %
+ \gdef\OP#1{%
+ \edef\temp{%
+ \noexpand\<#1\noexpand\><<<
+ \CNT
+ >>> %
+ } \temp %
+ \immediate\write15{...... \CNT\space #1}
+ \HAdvance\CNT by 1 %
+ } %
+\egroup
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% \AddFile[optional: target file name; default: given file name]
-% (optional: target home dir; default MYDIR)
-% {file name}{dir}
-
-\ifOption{win}
- {\def\mv{move }}
- {\def\mv{mv }}
-
-\def\Slash{/}
-{
- \catcode`\/=0
- \catcode`\\=12
- /ifOption{win}{/gdef/Slash{\}}{}
-}
-\def\SLASH{/}
-
-\def\AddFile{\futurelet\ext\AddFileA}
-\def\AddFileA{%
- \if [\ext \def\ext[##1]{\def\ext{##1}\futurelet\dir\AddFileB}%
- \else \def\ext{\def\ext{}\futurelet\dir\AddFileB}\fi
- \ext}
-\def\AddFileB{%
- \if (\dir \def\dir(##1){\def\dir{##1}\AddFileC}%
- \else \def\dir{\let\dir\MYdir\AddFileC}\fi
- \dir}
-
-
-\def\AddFileC#1#2{%
- \expandafter\setStartDir \dir #2!%
- \bgroup
- \def\Slash{/}%
- \xdef\EndDir{\ifx \dir\empty \else \dir\Slash\fi
- #2\Slash
- \ifx\ext\empty
- \if !#1!\else #1\fi
- \else \ext\fi}%
- \egroup
- \MakeDir
- \if !#1!\else
- \Needs{"\mv #1\space \dir \Slash#2\Slash
- \ifx\ext\empty #1\else \ext\fi"}%
- \fi
-}
-
-\ifOption{win}
-{
- \def\MakeDir{\relax
- \expandafter \ifx \csname !\StartDir\endcsname\relax
- \expandafter\let\csname !\StartDir\endcsname=\empty
- \Needs{"if NOT EXIST \StartDir \space mkdir \StartDir"}%
- \fi
- \ifx \EndDir\empty \else
- \expandafter\AppendDir \EndDir////*%
- \expandafter\MakeDir
- \fi
- }
-}{
- \def\MakeDir{\relax
- \expandafter \ifx \csname !\StartDir\endcsname\relax
- \expandafter\let\csname !\StartDir\endcsname=\empty
- \Needs{"mkdir \StartDir"}%
- \fi
- \ifx \EndDir\empty \else
- \expandafter\AppendDir \EndDir////*%
- \expandafter\MakeDir
- \fi
- }
-}
-
-\def\AppendDir#1/#2/#3/*{%
- \def\temp{#2}\ifx \temp\empty
- \let\EndDir=\empty
- \else
- \edef\StartDir{\ifx \StartDir\empty\else
- \ifx \StartDir\SLASH \Slash \else
- \StartDir\Slash\fi \fi
- #1}%
- \def\EndDir{#2/#3}%
- \expandafter\MakeDir
- \fi
-}
-\def\setStartDir#1#2!{%
- \def\StartDir{#1}\ifx\StartDir\SLASH\else
- \def\StartDir{}\fi
-}
+% \AddFile[optional: target file name; default: given file name]
+% (optional: target home dir; default MYDIR)
+% {file name}{dir}
+\ifOption{win}
+ {\def\mv{move }}
+ {\def\mv{mv }}
+\def\Slash{/}
+{
+ \catcode`\/=0
+ \catcode`\\=12
+ /ifOption{win}{/gdef/Slash{\}}{}
+}
+\def\SLASH{/}
-% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\def\AddFile{\futurelet\ext\AddFileA}
+\def\AddFileA{%
+ \if [\ext \def\ext[##1]{\def\ext{##1}\futurelet\dir\AddFileB}%
+ \else \def\ext{\def\ext{}\futurelet\dir\AddFileB}\fi
+ \ext}
+\def\AddFileB{%
+ \if (\dir \def\dir(##1){\def\dir{##1}\AddFileC}%
+ \else \def\dir{\let\dir\MYdir\AddFileC}\fi
+ \dir}
+
+
+\def\AddFileC#1#2{%
+ \expandafter\setStartDir \dir #2!%
+ \bgroup
+ \def\Slash{/}%
+ \xdef\EndDir{\ifx \dir\empty \else \dir\Slash\fi
+ #2\Slash
+ \ifx\ext\empty
+ \if !#1!\else #1\fi
+ \else \ext\fi}%
+ \egroup
+ \MakeDir
+ \if !#1!\else
+ \Needs{"\mv #1\space \dir \Slash#2\Slash
+ \ifx\ext\empty #1\else \ext\fi"}%
+ \fi
+}
+
+\ifOption{win}
+{
+ \def\MakeDir{\relax
+ \expandafter \ifx \csname !\StartDir\endcsname\relax
+ \expandafter\let\csname !\StartDir\endcsname=\empty
+ \Needs{"if NOT EXIST \StartDir \space mkdir \StartDir"}%
+ \fi
+ \ifx \EndDir\empty \else
+ \expandafter\AppendDir \EndDir////*%
+ \expandafter\MakeDir
+ \fi
+ }
+}{
+ \def\MakeDir{\relax
+ \expandafter \ifx \csname !\StartDir\endcsname\relax
+ \expandafter\let\csname !\StartDir\endcsname=\empty
+ \Needs{"mkdir \StartDir"}%
+ \fi
+ \ifx \EndDir\empty \else
+ \expandafter\AppendDir \EndDir////*%
+ \expandafter\MakeDir
+ \fi
+ }
+}
+
+\def\AppendDir#1/#2/#3/*{%
+ \def\temp{#2}\ifx \temp\empty
+ \let\EndDir=\empty
+ \else
+ \edef\StartDir{\ifx \StartDir\empty\else
+ \ifx \StartDir\SLASH \Slash \else
+ \StartDir\Slash\fi \fi
+ #1}%
+ \def\EndDir{#2/#3}%
+ \expandafter\MakeDir
+ \fi
+}
+\def\setStartDir#1#2!{%
+ \def\StartDir{#1}\ifx\StartDir\SLASH\else
+ \def\StartDir{}\fi
+}
+
+
+
+% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% % \AddFile[optional: target file name; default: given file name]
% % (optional: target home dir; default MYDIR)
% % {file name}{dir}
-%
-% \def\AddFile{\futurelet\ext\AddFileA}
-% \def\AddFileA{%
-% \if [\ext \def\ext[##1]{\def\ext{##1}\futurelet\dir\AddFileB}%
-% \else \def\ext{\def\ext{}\futurelet\dir\AddFileB}\fi
-% \ext}
-% \def\AddFileB{%
-% \if (\dir \def\dir(##1){\def\dir{##1}\AddFileC}%
-% \else \def\dir{\let\dir\MYdir\AddFileC}\fi
-% \dir}
-% \def\AddFileC#1#2{%
+%
+% \def\AddFile{\futurelet\ext\AddFileA}
+% \def\AddFileA{%
+% \if [\ext \def\ext[##1]{\def\ext{##1}\futurelet\dir\AddFileB}%
+% \else \def\ext{\def\ext{}\futurelet\dir\AddFileB}\fi
+% \ext}
+% \def\AddFileB{%
+% \if (\dir \def\dir(##1){\def\dir{##1}\AddFileC}%
+% \else \def\dir{\let\dir\MYdir\AddFileC}\fi
+% \dir}
+% \def\AddFileC#1#2{%
% \expandafter\setStartDir \dir #2!%
-% \edef\EndDir{\ifx \dir\empty \else \dir/\fi
-% #2/\ifx\ext\empty \if !#1!XXX\else #1\fi\else \ext\fi}\MakeDir
-% \if !#1!\else
-% \Needs{"mv #1\space \dir /#2/\ifx\ext\empty #1\else \ext\fi"}%
-% \fi
-% }
-% \def\MakeDir{\relax
-% \expandafter \ifx \csname !\StartDir\endcsname\relax
-% \expandafter\let\csname !\StartDir\endcsname=\empty
-% \Needs{"mkdir \StartDir"}%
-% \fi
-% \ifx \EndDir\empty \else
-% \expandafter\AppendDir \EndDir////*%
-% \expandafter\MakeDir
-% \fi
-% }
-% \def\AppendDir#1/#2/#3/*{%
-% \def\temp{#2}\ifx \temp\empty \let\EndDir=\empty
-% \else
-% \edef\StartDir{\ifx \StartDir\empty\else
-% \ifx \StartDir\SLASH /\else
+% \edef\EndDir{\ifx \dir\empty \else \dir/\fi
+% #2/\ifx\ext\empty \if !#1!XXX\else #1\fi\else \ext\fi}\MakeDir
+% \if !#1!\else
+% \Needs{"mv #1\space \dir /#2/\ifx\ext\empty #1\else \ext\fi"}%
+% \fi
+% }
+% \def\MakeDir{\relax
+% \expandafter \ifx \csname !\StartDir\endcsname\relax
+% \expandafter\let\csname !\StartDir\endcsname=\empty
+% \Needs{"mkdir \StartDir"}%
+% \fi
+% \ifx \EndDir\empty \else
+% \expandafter\AppendDir \EndDir////*%
+% \expandafter\MakeDir
+% \fi
+% }
+% \def\AppendDir#1/#2/#3/*{%
+% \def\temp{#2}\ifx \temp\empty \let\EndDir=\empty
+% \else
+% \edef\StartDir{\ifx \StartDir\empty\else
+% \ifx \StartDir\SLASH /\else
% \StartDir/\fi \fi
-% #1}\def\EndDir{#2/#3}%
-% \fi
-% }
+% #1}\def\EndDir{#2/#3}%
+% \fi
+% }
% \def\setStartDir#1#2!{%
% \def\StartDir{#1}\ifx\StartDir\SLASH\else
% \def\StartDir{}\fi
@@ -186,10 +204,10 @@
% \def\SLASH{/}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\def\MYdir{work.dir}
+\def\MYdir{work.dir}
\expandafter\let\csname !/\endcsname\empty
@@ -200,9 +218,8 @@
\expandafter\let\csname !/home/4/gurari/xtpipes.dir\endcsname\empty
%\expandafter\let\csname !/home/4/gurari/tex4ht.dir/texmf\endcsname\empty
%\expandafter\let\csname !/home/4/gurari/xtpipes.dir\endcsname\empty
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -211,6 +228,7 @@
+
%%%%%%%%%%%%%%%%%%
\part{Core}
%%%%%%%%%%%%%%%%%%
@@ -228,7 +246,7 @@
\AtEndDocument{
\OutputCode[java]\<xtpipes.java\> % double .java to avoid problems on MS
- \OutputCodE\<Xtpipes.java\>
+ \OutputCodE\<Xtpipes.java\>
\OutputCodE\<xtpipes.dtd\>
}
@@ -259,7 +277,7 @@
% \AddFile[xtpipes.dtd](/home/4/gurari/xtpipes.dir/xtpipes/bin){xtpipes.dtd.1}{xtpipes/lib}
-\ifOption{win} {
+\ifOption{win} {
\def\BIN{}
}{
\def\BIN{(/home/4/gurari/xtpipes.dir)}
@@ -289,7 +307,7 @@
`<static void instructionErr(...)`>
`<static String serialize( dom )`>
`<static void cleanXmlns( dom )`>
-}
+}
`<class XtpipesEntityResolver`>
>>>
@@ -354,7 +372,7 @@
import java.io.*;
import java.lang.reflect.*;
import java.util.HashMap;
-import java.util.Stack;
+import java.util.Stack;
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
@@ -380,12 +398,12 @@
\<static void xtpipes(String [], OutputStream, PrintWriter)\><<<
-public static void xtpipes(String [] args,
+public static void xtpipes(String [] args,
OutputStream out,
PrintWriter log)
throws Exception {
`<init fields`>
- outPrintWriter = new XtpipesPrintWriter( out, true );
+ outPrintWriter = new XtpipesPrintWriter( out, true );
logWriter = (log==null)? (new PrintWriter( System.err )) : log;
mainMethod(args);
outPrintWriter.flush();
@@ -395,12 +413,12 @@
\<static void xtpipes(String [], OutputStreamWriter, PrintWriter)\><<<
-public static void xtpipes(String [] args,
+public static void xtpipes(String [] args,
OutputStreamWriter out,
PrintWriter log)
throws Exception {
`<init fields`>
- outPrintWriter = new XtpipesPrintWriter( out );
+ outPrintWriter = new XtpipesPrintWriter( out );
logWriter = (log==null)? (new PrintWriter( System.err )) : log;
mainMethod(args);
outPrintWriter.flush();
@@ -408,12 +426,12 @@
>>>
\<static void xtpipes(String [], XtpipesPrintWriter, PrintWriter)\><<<
-public static void xtpipes(String [] args,
+public static void xtpipes(String [] args,
XtpipesPrintWriter out,
PrintWriter log)
throws Exception {
`<init fields`>
- outPrintWriter = out;
+ outPrintWriter = out;
logWriter = (log==null)? (new PrintWriter( System.err )) : log;
mainMethod(args);
outPrintWriter.flush();
@@ -433,7 +451,7 @@
\<static Document getDOM(...)\><<<
-public static Document getDOM(String args[])
+public static Document getDOM(String args[])
throws Exception {
`<init fields`>
returnDom = true;
@@ -449,12 +467,12 @@
InputStream is = new ByteArrayInputStream( bytes );
dom = domBuilder.parse (is);
} catch ( org.xml.sax.SAXParseException e ){
- if( Xtpipes.trace ){
- Xtpipes.logWriter.println(
+ if( Xtpipes.trace ){
+ Xtpipes.logWriter.println(
"\n---------------------------------------------------\n"
+ result +
- "\n---------------------------------------------------\n" );
- }
+ "\n---------------------------------------------------\n" );
+ }
String s = "";
`<s += input file name within args`>
if( scriptFile != null ){ s += " script file: " + scriptFile; }
@@ -462,15 +480,15 @@
"parsing error: " + e.getMessage() +s, 21 );
} catch ( Exception e ){
instructionErr( null, e.toString(), 5 );
- }
+ }
`<close ml2xml files`>
}
return dom;
-}
+}
>>>
\<static Document getDOM(...)\><<<
-public static Document getDOM(String s, String args[])
+public static Document getDOM(String s, String args[])
throws Exception {
`<init fields`>
returnDom = true;
@@ -488,22 +506,22 @@
InputStream is = new ByteArrayInputStream( bytes );
dom = domBuilder.parse (is);
} catch ( org.xml.sax.SAXParseException e ){
- instructionErr( null, "improper xml: " + e.getMessage()
+ instructionErr( null, "improper xml: " + e.getMessage()
+ "\n code starts with: "
+ result.substring(0, Math.min(100,result.length()))
, 17 );
} catch ( Exception e ){
instructionErr( null, e.toString(), 6 );
- }
+ }
`<close ml2xml files`>
}
return dom;
-}
+}
>>>
\<static Document getDOM(...)\><<<
-public static Document getDOM(String args[], PrintWriter log)
+public static Document getDOM(String args[], PrintWriter log)
throws Exception {
logWriter = (log==null)? new PrintWriter( System.err ) : log;
return getDOM(args);
@@ -511,7 +529,7 @@
>>>
\<static Document getDOM(...)\><<<
-public static Document getDOM(String s, String args[], PrintWriter log)
+public static Document getDOM(String s, String args[], PrintWriter log)
throws Exception {
logWriter = (log==null)? (new PrintWriter( System.err )) : log;
return getDOM(s, args);
@@ -539,7 +557,7 @@
`<command line vars`>
`<process command line`>
} catch (Exception e){
- instructionErr( null, e.getMessage(), e.getStackTrace(), 31 );
+ instructionErr( null, e.getMessage(), e.getStackTrace(), 31 );
}
try {
DocumentBuilderFactory domFactory =
@@ -553,7 +571,7 @@
`<scriptFile := entry script file name`>
while( needScript ){
if( scriptFile == null ){
- instructionErr( null, "Missing 4xt script file name", 32 );
+ instructionErr( null, "Missing 4xt script file name", 32 );
}
`<search script file`>
Document script = validatingDomBuilder.parse(scriptFile);
@@ -562,10 +580,10 @@
}
`<close output file`>
Xtpipes.logWriter.flush();
- } catch( org.xml.sax.SAXParseException e ){
+ } catch( org.xml.sax.SAXParseException e ){
String s = "Improper file " + scriptFile + ": " + e.getMessage();
- instructionErr( null, s, 2 );
- } catch( java.io.FileNotFoundException e ){
+ instructionErr( null, s, 2 );
+ } catch( java.io.FileNotFoundException e ){
String s;
if( scriptFile.equals( e.getMessage() ) ){
s = "Could not find file: " + scriptFile;
@@ -573,11 +591,11 @@
s = "Problem at script " + scriptFile + ": Could not find file "
+ e.getMessage();
}
- instructionErr( null, s, 3 );
- } catch( Exception e ){
+ instructionErr( null, s, 3 );
+ } catch( Exception e ){
String s = "Problems at file: " + scriptFile + "\n " + e;
- instructionErr( null, s, 4 );
-} }
+ instructionErr( null, s, 4 );
+} }
>>>
@@ -628,7 +646,7 @@
\<static void execute( node )\><<<
private static void execute( Node node ) throws Exception {
- while( node != null ){
+ while( node != null ){
if( node.getNodeType()==Node.ELEMENT_NODE ){
String instruction = node.getNodeName();
`<trace element`>
@@ -651,7 +669,7 @@
} else if( instruction.equals( "sax" ) ){
`<execute sax`>
} else {
- instructionErr( node, "Improper instruction: " + instruction, 11 );
+ instructionErr( node, "Improper instruction: " + instruction, 11 );
} }
node = node.getNextSibling();
} }
@@ -669,29 +687,29 @@
if( args[n] == null ){}
else if( args[n].equals("") ){}
else if( args[n].charAt(0)!='-' ){ inFile = args[n]; }
-else if( args[n].equals("-m") ){
+else if( args[n].equals("-m") ){
messages = true;
`<output system info`>
}
-else if( args[n].equals("-s") ){
+else if( args[n].equals("-s") ){
`<scan script file name`>
}
-else if( args[n].equals("-S") ){
+else if( args[n].equals("-S") ){
`<scan script map file name`>
}
-else if( args[n].equals("-i") ){
+else if( args[n].equals("-i") ){
`<scan script dir name`>
}
-else if( args[n].equals("-o") ){
+else if( args[n].equals("-o") ){
`<scan output file name`>
}
-else if( args[n].startsWith("-x") ){
+else if( args[n].startsWith("-x") ){
`<scan ml2xml argument`>
}
-else if( args[n].equals("-E") ){
+else if( args[n].equals("-E") ){
exceptionErrs = true;
}
-else if( args[n].equals("-d") ){
+else if( args[n].equals("-d") ){
`<scan input data`>
}
else if( args[n].equals("-trace") ){ trace=true; }
@@ -707,7 +725,7 @@
\<command line vars\><<<
String xtpipes_call =
" xtpipes (`version)"
- + "\n Command line options: "
+ + "\n Command line options: "
+ "\n java xtpipes [-trace] [-help] [-m] [-E] [-s script_file]"
+ " [-S script_map]"
+ "\n [-i script_dir] [-o out_file] "
@@ -721,7 +739,7 @@
-At least one `-x' command line option is required for ml2xml
+At least one `-x' command line option is required for ml2xml
to be called. An empty postfix is also fine.
@@ -730,13 +748,13 @@
for( int n=0; n<args.length; n++ ){
if( args[n].charAt(0)!='-' ){
s += " input file: " + args[n] + "."; break;
- }
- else if( args[n].equals("-s")
+ }
+ else if( args[n].equals("-s")
|| args[n].equals("-S")
|| args[n].equals("-i")
- || args[n].equals("-o")
+ || args[n].equals("-o")
|| args[n].equals("-d") ){ n++; }
-}
+}
>>>
%%%%%%%%%%%%%
@@ -756,7 +774,7 @@
if( inFile != null ){
inputObject = new InputObject( inFile, logWriter );
if( inputObject.getInputStream() == null ){
- instructionErr( null, "Could not find or open file: " + inFile, 28 );
+ instructionErr( null, "Could not find or open file: " + inFile, 28 );
}
inFile = inputObject.getFilename();
} else {
@@ -779,7 +797,7 @@
for(int i=n+1; i<args.length; i++ ){
if( args[i].equals("-E") ){ exceptionErrs = true; }
} }
-instructionErr( null,
+instructionErr( null,
"Improper argument: " + args[n] + "\n" + xtpipes_call, 26 );
>>>
@@ -818,12 +836,12 @@
>>>
-%%%%%%%%%%%%%
-\subsection{Ouput File}
-%%%%%%%%%%%%%
+%%%%%%%%%%%%%
+\subsection{Output File}
+%%%%%%%%%%%%%
-The output file name mentioned in the input command line `-o file.out' is
+The output file name mentioned in the input command line `-o file.out' is
employed in the following cases.
\begin{itemize}
@@ -866,18 +884,18 @@
\<open output file\><<<
if( outFileName != null ){
- try {
- FileWriter fw = new FileWriter( outFileName );
- outPrintWriter = new XtpipesPrintWriter( fw );
+ try {
+ FileWriter fw = new FileWriter( outFileName );
+ outPrintWriter = new XtpipesPrintWriter( fw );
returnToFile = true;
- } catch(Exception e){
- instructionErr( null, e.toString(), 12 );
-} }
+ } catch(Exception e){
+ instructionErr( null, e.toString(), 12 );
+} }
>>>
\<close output file\><<<
if( outFileName != null ){
- outPrintWriter.close();
+ outPrintWriter.close();
}
>>>
@@ -887,9 +905,9 @@
}
>>>
-\AtEndDocument{
- \OutputCodE\<XtpipesPrintWriter.java\>
-}
+\AtEndDocument{
+ \OutputCodE\<XtpipesPrintWriter.java\>
+}
\AddFile{XtpipesPrintWriter.java}{xtpipes}
\<XtpipesPrintWriter.java\><<<
@@ -901,7 +919,7 @@
public class XtpipesPrintWriter extends PrintWriter {
public XtpipesPrintWriter() {
super(System.out, true);
- }
+ }
public XtpipesPrintWriter (PrintStream ps, boolean b){
super(ps, b);
}
@@ -910,16 +928,16 @@
}
public XtpipesPrintWriter (FileWriter fw){
super(fw);
- }
+ }
public XtpipesPrintWriter (Writer wr){
super(wr);
- }
+ }
public void print(String str) {
super.print( XtpipesUni.toUni(str, "") );
- }
+ }
public void println(String str) {
super.println( XtpipesUni.toUni(str, "") );
-} }
+} }
>>>
@@ -982,8 +1000,8 @@
\<scan script dir name\><<<
n++;
-if( n < args.length ){
- i_scriptDir=args[n];
+if( n < args.length ){
+ i_scriptDir=args[n];
} else {
System.err.println(
"--- Error --- Missing field for -i argument" );
@@ -1014,7 +1032,7 @@
\subsection{Getting the Start Up Script}
%%%%%%%%%%%%%
-The command line arguments may provide a pointer to
+The command line arguments may provide a pointer to
a `scriptFile' and a pointer to an algorithm `scriptMap'
for getting the script file name.
@@ -1029,7 +1047,7 @@
} else {
scriptMap = f;
}
- `<get sax reader`>
+ `<get sax reader`>
saxReader.setContentHandler( new DefaultHandler(){
`<process script map`>
} );
@@ -1037,13 +1055,13 @@
(InputStream) (new File(scriptMap).toURI().toURL().openStream());
saxReader.parse( new InputSource(inputStream) );
saxReaderStack.push( saxReader );
- } catch( java.io.FileNotFoundException e ){
- instructionErr( null,
+ } catch( java.io.FileNotFoundException e ){
+ instructionErr( null,
"File not found: " + e.getMessage()
+ "; command line option -i",
- 33 );
- } catch( Exception e ){
- instructionErr( null, e.toString(), e.getStackTrace(), 27 );
+ 33 );
+ } catch( Exception e ){
+ instructionErr( null, e.toString(), e.getStackTrace(), 27 );
}
}
if( scriptFile == null ){
@@ -1071,16 +1089,16 @@
if( qName.equals("when") ){
if( cond ){ `<cond := when ...`> }
}
- else
+ else
if( qName.equals("command-line") ){
- if( scriptFile != null ){
+ if( scriptFile != null ){
`<trace found script in map`>
condition = null;
return;
} }
- else
+ else
if( qName.equals("processing-instruction") ){
- if( cond ){
+ if( cond ){
String s = inputObject.getXtpipes();
if( s != null ){
Xtpipes.scriptFile = s;
@@ -1088,9 +1106,9 @@
condition = null;
return;
} } }
- else
+ else
if( qName.equals("select") ){
- if( cond ){
+ if( cond ){
Xtpipes.scriptFile = atts.getValue("name");
`<trace found script in map`>
condition = null;
@@ -1118,45 +1136,45 @@
String value = atts.getValue("value");
if( name.equals("system-id") ){
cond = value.equals(inputObject.getSystemId());
-}
-else
+}
+else
if( name.equals("public-id") ){
cond = value.equals(inputObject.getPublicId());
-}
+}
else
if( name.equals("dtd-root") ){
cond = value.equals(inputObject.getDtdRoot());
-}
+}
else
if( name.equals("root") ){
cond = value.equals(inputObject.getRoot());
-}
+}
else
if( name.equals("ext") ){
cond = inputObject.getFilename().endsWith("." + value);
-}
+}
else
if( name.equals("prefix") ){
name = inputObject.getFilename();
if( name != null ){
int i = name.lastIndexOf('/');
if( (i != -1) && ((i+1) < name.length()) ){
- name = name.substring(i+1);
+ name = name.substring(i+1);
}
i = name.lastIndexOf('\\');
if( (i != -1) && ((i+1) < name.length()) ){
- name = name.substring(i+1);
+ name = name.substring(i+1);
}
cond = name.startsWith(value);
} }
else
if( name.equals("meta-type") ){
cond = value.equals(inputObject.getMetaType());
-}
+}
else
if( name.equals("content-type") ){
cond = value.equals(inputObject.getContentType());
-}
+}
>>>
@@ -1173,13 +1191,13 @@
>>>
-\<trace start map element\><<<
+\<trace start map element\><<<
if( Xtpipes.trace ){
String s = "<" + qName + "\n";
for(int i=0; i<atts.getLength(); i++ ){
String name = atts.getQName(i);
s += " " + name + "=\"" + atts.getValue(i) + "\"";
- }
+ }
s += ">" ;
Xtpipes.logWriter.println( s );
}
@@ -1225,9 +1243,9 @@
\end{verbatim}
\<xtpipes.dtd\><<<
-<!ELEMENT xtpipes (#PCDATA `<xtpipes entries`>)* >
+<!ELEMENT xtpipes (#PCDATA `<xtpipes entries`>)* >
<!ATTLIST xtpipes
- preamble CDATA #IMPLIED DEFAULT (yes | no) "no"
+ preamble CDATA #IMPLIED DEFAULT (yes | no) "no"
signature CDATA #IMPLIED >
>>>
@@ -1238,39 +1256,39 @@
}
\expandafter\AddFile\BIN{xtpipes-map.dtd}{xtpipes\Slash lib}
-
-
-\<xtpipes-map.dtd\><<<
-<!-- xtpipes-map.dtd (`version) -->
-<!ELEMENT xtpipes-map (when | processing-instruction
+
+
+\<xtpipes-map.dtd\><<<
+<!-- xtpipes-map.dtd (`version) -->
+<!ELEMENT xtpipes-map (when | processing-instruction
| select
- | command-line)* >
+ | command-line)* >
<!ELEMENT when (when | select
- | processing-instruction
- | command-line )* >
-<!ELEMENT select EMPTY >
-<!ELEMENT processing-instruction EMPTY >
-<!ELEMENT command-line EMPTY >
+ | processing-instruction
+ | command-line )* >
+<!ELEMENT select EMPTY >
+<!ELEMENT processing-instruction EMPTY >
+<!ELEMENT command-line EMPTY >
<!ATTLIST xtpipes-map
- signature CDATA #IMPLIED
->
-<!ATTLIST when
+ signature CDATA #IMPLIED
+>
+<!ATTLIST when
name (
- system-id
- | public-id
- | dtd-root
- | root
- | ext
- | meta-type
- | content-type
+ system-id
+ | public-id
+ | dtd-root
+ | root
+ | ext
+ | meta-type
+ | content-type
| prefix ) "public-id"
- value CDATA #IMPLIED
- case-sensitive (yes|no) "no"
->
-<!ATTLIST select
- name CDATA #REQUIRED
->
->>>
+ value CDATA #IMPLIED
+ case-sensitive (yes|no) "no"
+>
+<!ATTLIST select
+ name CDATA #REQUIRED
+>
+>>>
%%%%%%%%%%%%%
@@ -1312,35 +1330,35 @@
\<search file for xtpipes instructionOLD\><<<
errMsg = "Searching <?xtpipes file=\"...\"?> in "
+ inFile + ": ";
- `<get sax reader`>
+ `<get sax reader`>
saxReader.setContentHandler( new XtPipesSearch() );
try{
saxReader.parse( new File(inFile).toURI().toURL().toString() );
-} catch ( java.io.FileNotFoundException ioe ){
+} catch ( java.io.FileNotFoundException ioe ){
try{
saxReader.parse( new InputSource(
- new URL(inFile) . openStream() ));
- } catch ( java.io.FileNotFoundException fnf ){
- saxReader.parse( new File(inFile).toURI().toURL().toString() );
-} }
+ new URL(inFile) . openStream() ));
+ } catch ( java.io.FileNotFoundException fnf ){
+ saxReader.parse( new File(inFile).toURI().toURL().toString() );
+} }
saxReaderStack.push( saxReader );
>>>
-%%%%%%%%%%%%%
+%%%%%%%%%%%%%
\subsection{Copy Preamble}
-%%%%%%%%%%%%%
+%%%%%%%%%%%%%
-Copy into th eoutput the code preceeding the root. Note: assumes proper
+Copy into th eoutput the code preceeding the root. Note: assumes proper
XML file as it doesn't use ml2xml. NEEDS FIXING.
Example:
\begin{verbatim}
-----> <?xml version="1.0" encoding="UTF-8"?>
-----> <!DOCTYPE math:math PUBLIC "-//W3C//DTD MathML 2.0//EN" "math.dtd">
-----> <?xtpipes file="oo-math.4xt" ?>
-----> <!-- try-m12 by TeX4ht from try.tex line 69 2007-01-09-11:20
-----> (http://www.cse.ohio-state.edu/~gurari/TeX4ht/) -->
+----> <?xml version="1.0" encoding="UTF-8"?>
+----> <!DOCTYPE math:math PUBLIC "-//W3C//DTD MathML 2.0//EN" "math.dtd">
+----> <?xtpipes file="oo-math.4xt" ?>
+----> <!-- try-m12 by TeX4ht from try.tex line 69 2007-01-09-11:20
+----> (http://www.cse.ohio-state.edu/~gurari/TeX4ht/) -->
\end{verbatim}
@@ -1352,10 +1370,10 @@
`<preamble output into log`>
attr = node.getAttributes()
.getNamedItem( "preamble" );
- if( (attr != null)
+ if( (attr != null)
&& attr.getNodeValue().equals( "yes" ) ){
`<get src preamble`>
-} }
+} }
>>>
@@ -1363,7 +1381,7 @@
// BufferedReader br = null;
try {
String s;
- boolean front = true;
+ boolean front = true;
rootName = "<" + ((rootName==null)? inputObject.getRoot() : rootName);
if( inData == null ){
`<get src preamble from file`>
@@ -1396,7 +1414,7 @@
>>>
\<BufferedReader in := inFile\><<<
-URLConnection connection =
+URLConnection connection =
new URL(inFile).openConnection();
connection.setRequestProperty("User-Agent",
"["
@@ -1439,11 +1457,11 @@
-%%%%%%%%%%%%%
+%%%%%%%%%%%%%
\subsection{XtPipes}
-%%%%%%%%%%%%%
+%%%%%%%%%%%%%
-The xtpipes element is the root of the script file through which
+The xtpipes element is the root of the script file through which
the transformation starts.
\<execute xtpipes\><<<
@@ -1455,7 +1473,7 @@
execute( node.getFirstChild() );
} else {
`<script := xtpipes processing instruction`>
-}
+}
>>>
@@ -1471,17 +1489,17 @@
-%%%%%%%%%%%%%
+%%%%%%%%%%%%%
\subsection{Handle Set}
-%%%%%%%%%%%%%
+%%%%%%%%%%%%%
Associate a name to the given enclosed code.
\begin{verbatim}
-<set name="...">
-<![CDATA[
- ...
-]]>
+<set name="...">
+<![CDATA[
+ ...
+]]>
</set>
\end{verbatim}
@@ -1490,7 +1508,7 @@
>>>
\<xtpipes.dtd\><<<
-<!ELEMENT set (#PCDATA) >
+<!ELEMENT set (#PCDATA) >
<!ATTLIST set
name CDATA #REQUIRED >
>>>
@@ -1535,9 +1553,9 @@
\<xtpipes.dtd\><<<
-<!ELEMENT get EMPTY >
+<!ELEMENT get EMPTY >
<!ATTLIST get
- name CDATA #REQUIRED
+ name CDATA #REQUIRED
file CDATA #REQUIRED
>
>>>
@@ -1549,22 +1567,22 @@
.getNamedItem( "name" ).getNodeValue();
String file = node.getAttributes()
.getNamedItem( "file" ).getNodeValue();
- StreamSource in = new StreamSource( new File(file) );
+ StreamSource in = new StreamSource( new File(file) );
ByteArrayOutputStream baos = new ByteArrayOutputStream();
identityTransformer.transform( in, new StreamResult(baos) );
byte [] bytes = baos.toByteArray();
map.put( name, (Object) new String(bytes) );
-} catch( Exception e ){
- instructionErr( node, e.toString(), 14 );
-}
+} catch( Exception e ){
+ instructionErr( node, e.toString(), 14 );
+}
>>>
\<xtpipes initialization\><<<
fc = TransformerFactory.newInstance();
-identityTransformer = fc.newTransformer();
-identityTransformer.setErrorListener(
+identityTransformer = fc.newTransformer();
+identityTransformer.setErrorListener(
`<identity transformer XML error listener`> );
>>>
@@ -1599,9 +1617,9 @@
\<xtpipes.dtd\><<<
-<!ELEMENT print EMPTY >
+<!ELEMENT print EMPTY >
<!ATTLIST print
- name CDATA #REQUIRED
+ name CDATA #REQUIRED
file CDATA #IMPLIED
>
>>>
@@ -1620,13 +1638,13 @@
} else {
String file = node.getAttributes()
.getNamedItem( "file" ).getNodeValue();
- try{
- FileWriter fw = new FileWriter( file );
- XtpipesPrintWriter out = new XtpipesPrintWriter( fw );
- out.println( xml );
- out.close();
- } catch(Exception e){
- instructionErr( node, e.toString(),15 );
+ try{
+ FileWriter fw = new FileWriter( file );
+ XtpipesPrintWriter out = new XtpipesPrintWriter( fw );
+ out.println( xml );
+ out.close();
+ } catch(Exception e){
+ instructionErr( node, e.toString(),15 );
} }
>>>
@@ -1651,9 +1669,9 @@
\<xtpipes.dtd\><<<
-<!ELEMENT return EMPTY >
+<!ELEMENT return EMPTY >
<!ATTLIST return
- name CDATA #REQUIRED
+ name CDATA #REQUIRED
>
>>>
@@ -1671,15 +1689,15 @@
-%%%%%%%%%%%%%
+%%%%%%%%%%%%%
\subsection{Conditional `if' statements}
-%%%%%%%%%%%%%
+%%%%%%%%%%%%%
-Execute the enclosed instructions provided the named XML code
-satisfied the named DTD conditions.
-
+Execute the enclosed instructions provided the named XML code
+satisfied the named DTD conditions.
+
\begin{verbatim}
-<if xml="..." dtd="..." root="..." >
+<if xml="..." dtd="..." root="..." >
...
</if>
\end{verbatim}
@@ -1691,23 +1709,23 @@
\<xtpipes.dtd\><<<
-<!ELEMENT if (#PCDATA `<xtpipes entries`>)* >
+<!ELEMENT if (#PCDATA `<xtpipes entries`>)* >
<!ATTLIST if
- xml CDATA #REQUIRED
- dtd CDATA #REQUIRED
- root CDATA #REQUIRED
+ xml CDATA #REQUIRED
+ dtd CDATA #REQUIRED
+ root CDATA #REQUIRED
>
>>>
\<execute if\><<<
-try{
+try{
`<doc = dtd + xml`>
byte [] bytes = doc.getBytes("UTF-8");
ByteArrayInputStream bais = new ByteArrayInputStream( bytes );
InputSource in = new InputSource( bais );
SAXParser saxParser = saxFactory.newSAXParser();
XMLReader xmlReader = saxParser.getXMLReader();
- xmlReader.parse( in );
+ xmlReader.parse( in );
`<trace if true`>
execute( node.getFirstChild() );
} catch ( Exception e ){ `<trace if false`> }
@@ -1723,7 +1741,7 @@
// .getNamedItem( "root" ).getNodeValue();
String doc = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
+ "<!DOCTYPE doc [\n"
- + (String) map.get(dtd)
+ + (String) map.get(dtd)
+ "\n]>\n"
+ (String) map.get(xml) ;
>>>
@@ -1741,7 +1759,7 @@
>>>
-%%%%%%%%%%%%%
+%%%%%%%%%%%%%
\subsection{Handle XSLT}
%%%%%%%%%%%%%
@@ -1769,38 +1787,38 @@
\<xtpipes.dtd\><<<
-<!ELEMENT xslt EMPTY >
+<!ELEMENT xslt EMPTY >
<!ATTLIST xslt
name CDATA #IMPLIED
- xml CDATA #REQUIRED
- xsl CDATA #REQUIRED
+ xml CDATA #REQUIRED
+ xsl CDATA #REQUIRED
>
>>>
\<execute xslt\><<<
-try{
+try{
`<StreamSource inDoc = ...`>
`<StreamSource inXslt = ...`>
`<StreamResult outDoc = ...`>
errMssg = null;
fc.setErrorListener( `<transformer factory XSLT error listener`> );
Transformer transformer = fc.newTransformer( inXslt );
- transformer.setErrorListener( `<transformer XML error listener`> );
- transformer.transform(inDoc, outDoc );
+ transformer.setErrorListener( `<transformer XML error listener`> );
+ transformer.transform(inDoc, outDoc );
`<store xslt outcome`>
} catch ( javax.xml.transform.TransformerException e ){
if( Xtpipes.trace ){ e.printStackTrace(); }
- instructionErr( node,
+ instructionErr( node,
e.getMessage()
- +
+ +
((errMssg==null)? "" : ("; " +errMssg))
, 37);
-} catch ( Exception e ){
+} catch ( Exception e ){
if( Xtpipes.trace ){ e.printStackTrace(); }
- instructionErr( node, (errMssg==null)? e.toString()
+ instructionErr( node, (errMssg==null)? e.toString()
: e.toString() + "; " + errMssg
- , 16 );
-}
+ , 16 );
+}
>>>
@@ -1925,12 +1943,12 @@
\<xtpipes.dtd\><<<
-<!ELEMENT dom EMPTY >
+<!ELEMENT dom EMPTY >
<!ATTLIST dom
- name CDATA #REQUIRED
- xml CDATA #REQUIRED
- method CDATA #REQUIRED
- class CDATA #REQUIRED
+ name CDATA #REQUIRED
+ xml CDATA #REQUIRED
+ method CDATA #REQUIRED
+ class CDATA #REQUIRED
dcl CDATA #IMPLIED DEFAULT (yes | no) "no"
>
>>>
@@ -1938,20 +1956,20 @@
\<execute dom\><<<
-try{
+try{
`<load xml into dom`>
`<transform dom`>
`<store dom into map`>
-} catch ( NoSuchMethodException e ){
- instructionErr( node,
- "could not find method: " + e.getMessage(), 18 );
+} catch ( NoSuchMethodException e ){
+ instructionErr( node,
+ "could not find method: " + e.getMessage(), 18 );
} catch ( java.lang.reflect.InvocationTargetException e ){
if( Xtpipes.trace ){ e.printStackTrace(); }
instructionErr( node, e.getCause().toString(), 36);
-} catch ( Exception e ){
+} catch ( Exception e ){
if( Xtpipes.trace ){ e.printStackTrace(); }
- instructionErr( node, e.toString(), 20 );
-}
+ instructionErr( node, e.toString(), 20 );
+}
>>>
@@ -1967,11 +1985,11 @@
String methodName = node.getAttributes()
.getNamedItem( "method" ).getNodeValue();
Class <?> cls = Class.forName( className );
-Class<?> [] argTypes = { Node.class };
-Method m = cls.getMethod( methodName, argTypes );
-Object parmValues[] = new Object[1];
-parmValues[0] = dom;
-m.invoke( null, parmValues );
+Class<?> [] argTypes = { Node.class };
+Method m = cls.getMethod( methodName, argTypes );
+Object parmValues[] = new Object[1];
+parmValues[0] = dom;
+m.invoke( null, parmValues );
>>>
\<xtpipes initialization\><<<
@@ -1998,13 +2016,13 @@
} else {
String xml = xmlNode.getNodeValue();
String doc = (String) map.get(xml);
- if( doc == null ){
- instructionErr( node, "improper xml attribute value", 18 );
+ if( doc == null ){
+ instructionErr( node, "improper xml attribute value", 18 );
}
byte [] bytes = doc.getBytes("UTF-8");
InputStream is = new ByteArrayInputStream( bytes );
dom = domBuilder.parse (is);
-}
+}
>>>
\<dom = parse input\><<<
@@ -2027,7 +2045,7 @@
`<StreamResult outDoc = ...`>
cleanXmlns(dom);
DOMSource domSource = new DOMSource(dom);
-try{
+try{
identityTransformer.transform( domSource, outDoc );
} catch ( javax.xml.transform.TransformerException e ){
String s = Xtpipes.trace?
@@ -2093,7 +2111,7 @@
content.
\begin{verbatim}
-<sax name="..." xml="..." content-handler="..."
+<sax name="..." xml="..." content-handler="..."
lexical-handler="..." >
<script element="..." > ... </script>
...
@@ -2132,12 +2150,12 @@
\<xtpipes.dtd\><<<
-<!ELEMENT sax (#PCDATA | script)* >
-<!ELEMENT script (#PCDATA `<xtpipes entries`> )* >
+<!ELEMENT sax (#PCDATA | script)* >
+<!ELEMENT script (#PCDATA `<xtpipes entries`> )* >
<!ATTLIST sax
name CDATA #IMPLIED
xml CDATA #IMPLIED
- content-handler CDATA #REQUIRED
+ content-handler CDATA #REQUIRED
lexical-handler CDATA #IMPLIED
>
<!ATTLIST script
@@ -2147,14 +2165,14 @@
\<execute sax\><<<
String errMsg = "";
-try{
+try{
`<load xml into input source`>
`<String [] className = ...`>
`<ch := content handler`>
`<get sax reader`>
XMLReader reader = saxReader;
`<insert sax filters`>
- errMsg = "setContentHandler( "
+ errMsg = "setContentHandler( "
+ className[0].trim() + " )";
saxReader.setContentHandler( (org.xml.sax.ContentHandler) ch );
`<saxReader += lexical handler`>
@@ -2167,31 +2185,31 @@
}
`<store chars into map`>
saxReaderStack.push( reader );
-} catch ( java.io.FileNotFoundException e ){
- instructionErr( node, errMsg
- + "could not find file: " + e.getMessage(), 19 );
-} catch ( ClassNotFoundException e ){
- instructionErr( node, errMsg
+} catch ( java.io.FileNotFoundException e ){
+ instructionErr( node, errMsg
+ + "could not find file: " + e.getMessage(), 19 );
+} catch ( ClassNotFoundException e ){
+ instructionErr( node, errMsg
+ " class not found: "
+ e.getMessage() + "\n classpath = "
+ System.getProperty("java.class.path")
- + " ---", 22 );
-} catch ( java.lang.reflect.InvocationTargetException e ){
- instructionErr( node, errMsg + ": " + e.getCause(), 23 );
-} catch ( Exception e ){
+ + " ---", 22 );
+} catch ( java.lang.reflect.InvocationTargetException e ){
+ instructionErr( node, errMsg + ": " + e.getCause(), 23 );
+} catch ( Exception e ){
Xtpipes.logWriter.flush();
e.printStackTrace();
- instructionErr( node, errMsg + ": " + e.toString(), 29 );
+ instructionErr( node, errMsg + ": " + e.toString(), 29 );
}
>>>
\<open sax input file\><<<
errMsg = "While parsing file " + xml + ": ";
-InputStream inputStream = null;
+InputStream inputStream = null;
if( Xtpipes.ml2xml == null ){
if( Xtpipes.trace ){
- Xtpipes.logWriter.println(
- "No request for ml2xml configuration (command line option -x)" );
+ Xtpipes.logWriter.println(
+ "No request for ml2xml configuration (command line option -x)" );
}
`<inputStream := ml2xml-less imput`>
} else {
@@ -2203,23 +2221,23 @@
\<inputStream := ml2xml-less imput\><<<
try{
- inputStream = (InputStream) (new File(xml).toURI().toURL().openStream());
-} catch ( java.io.FileNotFoundException ioe ){
+ inputStream = (InputStream) (new File(xml).toURI().toURL().openStream());
+} catch ( java.io.FileNotFoundException ioe ){
try{
URL url = null;
try {
url = new URL(xml);
- } catch ( java.net.MalformedURLException fnf ){
+ } catch ( java.net.MalformedURLException fnf ){
url = new File(xml).toURI().toURL();
}
- inputStream = (InputStream) (url.openStream());
- } catch ( java.io.FileNotFoundException fnf ){
+ inputStream = (InputStream) (url.openStream());
+ } catch ( java.io.FileNotFoundException fnf ){
inputStream = (InputStream)
(
new File( new File(xml).toURI().toURL().toString() )
. toURI().toURL()
. openStream()
- );
+ );
} }
>>>
@@ -2383,7 +2401,7 @@
\item
An output stream
\item
-A hash map containing the enclosed defdinitions of scripts
+A hash map containing the enclosed defdinitions of scripts
\item A method name
\item A log stream
\item A trace flag
@@ -2393,29 +2411,29 @@
\<ch := content handler\><<<
Class<?> [] argTypes = {
PrintWriter.class, HashMap.class, Method.class,
- PrintWriter.class, boolean.class };
+ PrintWriter.class, boolean.class };
`<output stream for sax`>
-Object parmValues[] = new Object[5];
-parmValues[0] = out;
-`<sax scripts`> parmValues[1] = scripts;
-parmValues[2] = method;
-parmValues[3] = Xtpipes.logWriter;
-parmValues[4] = (Object) Xtpipes.trace;
+Object parmValues[] = new Object[5];
+parmValues[0] = out;
+`<sax scripts`> parmValues[1] = scripts;
+parmValues[2] = method;
+parmValues[3] = Xtpipes.logWriter;
+parmValues[4] = (Object) Xtpipes.trace;
Class<?> cls = Class.forName( className[0].trim() );
-Constructor<?> c = cls.getConstructor( argTypes );
-Object ch = (Object) c.newInstance( parmValues );
+Constructor<?> c = cls.getConstructor( argTypes );
+Object ch = (Object) c.newInstance( parmValues );
>>>
\<sax scripts\><<<
HashMap <String,Object> scripts = new HashMap <String,Object> ();
Node script = node.getFirstChild();
-while( script != null ){
+while( script != null ){
if( script.getNodeType()==Node.ELEMENT_NODE ){
String element = script.getAttributes().getNamedItem( "element" )
.getNodeValue();
if( scripts.containsKey(element) ){
- System.err.println(
- "--- Warning --- redfining script: " + element );
+ System.err.println(
+ "--- Warning --- redfining script: " + element );
}
scripts.put( element, (Object) script );
}
@@ -2425,8 +2443,8 @@
\<xtpipes initialization\><<<
Class <?> cls = Xtpipes.class;
-Class<?> [] argTypes = { Node.class, String.class };
-method = cls.getMethod( "execute", argTypes );
+Class<?> [] argTypes = { Node.class, String.class };
+method = cls.getMethod( "execute", argTypes );
>>>
\<xtpipes fields\><<<
@@ -2442,28 +2460,28 @@
\<insert sax filters\><<<
for( int i=1; i<className.length; i++ ){
argTypes = new Class [3];
- argTypes[0] = PrintWriter.class;
- argTypes[1] = PrintWriter.class;
- argTypes[2] = boolean.class;
- parmValues = new Object[3];
- parmValues[0] = out;
- parmValues[1] = Xtpipes.logWriter;
- parmValues[2] = (Object) Xtpipes.trace;
+ argTypes[0] = PrintWriter.class;
+ argTypes[1] = PrintWriter.class;
+ argTypes[2] = boolean.class;
+ parmValues = new Object[3];
+ parmValues[0] = out;
+ parmValues[1] = Xtpipes.logWriter;
+ parmValues[2] = (Object) Xtpipes.trace;
errMsg = "Class.forName( " + className[i].trim() + ") " ;
cls = Class.forName( className[i].trim() );
- errMsg = "get-constructor "
+ errMsg = "get-constructor "
+ className[i].trim()
+ "( PrintWriter, PrintWriter, boolean ) " ;
- c = cls.getConstructor( argTypes );
- errMsg = "get-object "
- + className[i].trim()
+ c = cls.getConstructor( argTypes );
+ errMsg = "get-object "
+ + className[i].trim()
+ "( PrintWriter, PrintWriter, boolean ) " ;
if( (cls.getModifiers() % 2) != 1 ){
errMsg += "; class not defined to be public. ";
}
- XMLFilter filter = (XMLFilter) c.newInstance( parmValues );
- errMsg = "set-parent "
- + className[i].trim()
+ XMLFilter filter = (XMLFilter) c.newInstance( parmValues );
+ errMsg = "set-parent "
+ + className[i].trim()
+ "( PrintWriter, PrintWriter, boolean ) " ;
filter.setParent(saxReader);
saxReader = filter;
@@ -2472,7 +2490,7 @@
The filters are assumed to have a tri-parameter constructors which
-get an output stream for first arguments, log stream for second argument, and
+get an output stream for first arguments, log stream for second argument, and
a trace boolean value for third argument.
@@ -2489,7 +2507,7 @@
-The constructor of a lexical handler is provided the
+The constructor of a lexical handler is provided the
content handler as an argument.
@@ -2498,25 +2516,25 @@
Node lexAttr = node.getAttributes()
.getNamedItem( "lexical-handler" );
if( lexAttr != null ){
- String lexName = lexAttr.getNodeValue();
- argTypes = new Class[3];
- argTypes[0] = Class.forName( className[0].trim() );
- argTypes[1] = PrintWriter.class;
- argTypes[2] = boolean.class;
- parmValues = new Object[3];
- parmValues[0] = ch;
- parmValues[1] = Xtpipes.logWriter;
- parmValues[2] = (Object) Xtpipes.trace;
+ String lexName = lexAttr.getNodeValue();
+ argTypes = new Class[3];
+ argTypes[0] = Class.forName( className[0].trim() );
+ argTypes[1] = PrintWriter.class;
+ argTypes[2] = boolean.class;
+ parmValues = new Object[3];
+ parmValues[0] = ch;
+ parmValues[1] = Xtpipes.logWriter;
+ parmValues[2] = (Object) Xtpipes.trace;
errMsg = "Class.forName( " + lexName.trim() + ") " ;
cls = Class.forName( lexName.trim() );
- errMsg = "get-constructor " +
+ errMsg = "get-constructor " +
lexName.trim() +
"( " + className[0].trim() + " ) " ;
- c = cls.getConstructor( argTypes );
- errMsg = "get-object " +
+ c = cls.getConstructor( argTypes );
+ errMsg = "get-object " +
lexName.trim() + "( ... ) " ;
- Object xh = (Object) c.newInstance( parmValues );
- errMsg = "set lexical handler " + lexName.trim() + " ";
+ Object xh = (Object) c.newInstance( parmValues );
+ errMsg = "set lexical handler " + lexName.trim() + " ";
saxReader.setProperty(
"http://xml.org/sax/properties/lexical-handler",
(org.xml.sax.ext.LexicalHandler) xh
@@ -2550,7 +2568,7 @@
>>>
\<class XtpipesEntityResolver\><<<
-class XtpipesEntityResolver implements org.xml.sax.EntityResolver {
+class XtpipesEntityResolver implements org.xml.sax.EntityResolver {
`<InputSource resolveEntity(publicID, systemId)`>
}
>>>
@@ -2563,23 +2581,23 @@
\<InputSource resolveEntity(publicID, systemId)\><<<
-public InputSource resolveEntity(String publicID, String systemID)
- throws SAXException {
- if( Xtpipes.trace ){
+public InputSource resolveEntity(String publicID, String systemID)
+ throws SAXException {
+ if( Xtpipes.trace ){
Xtpipes.logWriter.println( "Resolving: publicID = \" " + publicID
- + "\" systemID = \"" + systemID + "\"" );
- }
+ + "\" systemID = \"" + systemID + "\"" );
+ }
String file = FileInfo.searchFile( systemID );
- if( file != null ){
+ if( file != null ){
try{
file = new File(file).toURI().toURL().toString();
- return new InputSource( file );
+ return new InputSource( file );
} catch( java.net.MalformedURLException mfe){
- throw new SAXException(
- "--- xtpipes error 30 --- improper file name: " + file );
+ throw new SAXException(
+ "--- xtpipes error 30 --- improper file name: " + file );
} }
- return null;
-}
+ return null;
+}
>>>
@@ -2630,7 +2648,7 @@
\<FileInfo fields\><<<
static String [] classPaths = null;
static String [] scriptPaths = null;
-static java.util.HashMap <String,String> registry =
+static java.util.HashMap <String,String> registry =
new java.util.HashMap <String,String>();
static String slash = System.getProperty("file.separator");
static String ii_scriptDir;
@@ -2654,57 +2672,57 @@
\<static String searchFile( file )\><<<
public static String searchFile( String file ){
String key = ((ii_scriptDir == null)? "" : ii_scriptDir )
- + "!" + file;
+ + "!" + file;
String result = (String) registry.get( key );
if( result == null ){
for(int i=0; i<2; i++){
- if( trace ){
+ if( trace ){
log.println( "Searching: " + file );
}
- if( (new File(file)).exists() ){
+ if( (new File(file)).exists() ){
result = ( file.indexOf(slash) == -1 )?
(System.getProperty("user.dir") + slash + file)
:
- file;
+ file;
}
else {
if( ii_scriptDir != null ){
- `<search file in script directories`>
+ `<search file in script directories`>
}
- if( result == null ){
- `<search file in classpath/xtpipes/lib`>
+ if( result == null ){
+ `<search file in classpath/xtpipes/lib`>
} }
if( result != null ){ break; }
file = new File(file).getName();
}
- if( result != null ){
+ if( result != null ){
result = FileInfo.cleanPath(result);
- registry.put(key, result);
- }
- }
- if( trace ){
+ registry.put(key, result);
+ }
+ }
+ if( trace ){
if( result == null ){
- log.println(
+ log.println(
"Directory paths from xtpipes command line option -i: "
- + ii_scriptDir );
+ + ii_scriptDir );
} else { log.println( "Found: " + result + "\n" ); }
log.flush();
}
- return result;
-}
+ return result;
+}
>>>
\<search file in script directories\><<<
-int k = scriptPaths.length;
-while( k>0 ){
- k--;
+int k = scriptPaths.length;
+while( k>0 ){
+ k--;
if( trace ){
- log.println( "Searching: " + file
- + ", recursively in directory: " + scriptPaths[k] );
- }
- result = searchDirectory( new File(scriptPaths[k]), file);
+ log.println( "Searching: " + file
+ + ", recursively in directory: " + scriptPaths[k] );
+ }
+ result = searchDirectory( new File(scriptPaths[k]), file);
if( result != null ){ break; }
}
String s = ii_scriptDir + file;
@@ -2713,14 +2731,14 @@
\<search file in classpath/xtpipes/lib\><<<
-int k = classPaths.length;
+int k = classPaths.length;
String toFile = "xtpipes" + slash + "lib" + slash + file;
-while( k>0 ){
- k--;
+while( k>0 ){
+ k--;
String s = classPaths[k] + toFile;
if( trace ){ log.println( "Searching: " + s ); }
if( new File(s).exists() ){ result = s; break; }
-}
+}
>>>
@@ -2737,7 +2755,7 @@
String s = dir.toString();
if( s.equals(file) || s.endsWith(slash + file) ){
result = s;
- }
+ }
}
return result;
}
@@ -2761,23 +2779,23 @@
\<classPaths[] := ...\><<<
if( iii_scriptDir != null ){
scriptPaths = FileInfo.getPaths( iii_scriptDir );
-}
+}
>>>
\<static String [] getPaths( dirs )\><<<
static String [] getPaths( String dirs ){
String [] paths = null;
- paths = dirs.split( System.getProperty("path.separator") );
- int k = paths.length;
- while( k>0 ){
+ paths = dirs.split( System.getProperty("path.separator") );
+ int k = paths.length;
+ while( k>0 ){
k--;
`<set full path`>
int len = paths[k].length();
- if( (len>1) && (paths[k].lastIndexOf(slash + ".") == (len-1)) ){
- paths[k] = paths[k].substring(0,len-1);
+ if( (len>1) && (paths[k].lastIndexOf(slash + ".") == (len-1)) ){
+ paths[k] = paths[k].substring(0,len-1);
} else if( (len>0) && ((len-1) != paths[k].lastIndexOf( slash )) ){
- paths[k] += slash;
- } }
+ paths[k] += slash;
+ } }
return paths;
}
>>>
@@ -2792,7 +2810,7 @@
if( (paths[k].length() > 0) && (paths[k].charAt(0) == '~') ){
if( (paths[k].length() == 1)|| (paths[k].charAt(1) != '~') ){
paths[k] = System.getProperty( "user.home" ) + paths[k].substring(1);
-} }
+} }
if( paths[k].charAt(0) == '.' ){
paths[k] = System.getProperty( "user.dir" ) + slash + paths[k];
}
@@ -2834,7 +2852,7 @@
public InputStream getInputStream(){ return inputStream; }
public String getFilename(){
return (url == null)?
- ( (connection == null)? filename
+ ( (connection == null)? filename
:
connection . getURL() . toString()
)
@@ -2876,22 +2894,22 @@
\<public InputObject(...)\><<<
public InputObject( String filename, PrintWriter log ){
InputObject.log = log;
- filename = filename.trim();
- try{
- inputStream = getInputStream(filename);
- } catch (Exception exp0){
- if( !filename.startsWith( "http://" ) ){
- try{
+ filename = filename.trim();
+ try{
+ inputStream = getInputStream(filename);
+ } catch (Exception exp0){
+ if( !filename.startsWith( "http://" ) ){
+ try{
String name = "http://" + filename;
- inputStream = getInputStream( name );
- filename = name;
- } catch (Exception exp1){
- try{
+ inputStream = getInputStream( name );
+ filename = name;
+ } catch (Exception exp1){
+ try{
String name = FileInfo.cleanPath(filename);
- inputStream = getInputStream( name );
- filename = name;
- } catch (Exception exp2){ inputStream = null; }
- } } }
+ inputStream = getInputStream( name );
+ filename = name;
+ } catch (Exception exp2){ inputStream = null; }
+ } } }
this.filename = filename;
}
>>>
@@ -2941,7 +2959,7 @@
\subsection{Stream from a URL}
%%%%%%%%%%%%%
-\<java.io.InputStream getInputStream( url )\><<<
+\<java.io.InputStream getInputStream( url )\><<<
private java.io.InputStream getInputStream( URL url )
throws java.io.FileNotFoundException,
java.io.IOException {
@@ -2988,61 +3006,61 @@
%%%%%%%%%%%%%
-
-\<static String cleanPath( path )\><<<
-public static String cleanPath( String path ){
+
+\<static String cleanPath( path )\><<<
+public static String cleanPath( String path ){
String slash = System.getProperty("file.separator");
String userDir = System.getProperty( "user.dir" );
`<clean leading wigle`>
`<clean leading dots`>
`<clean internal dots`>
- return path;
-}
->>>
+ return path;
+}
+>>>
-\<clean leading wigle\><<<
- if( (path.length() > 0) && (path.charAt(0) == '~') ){
- if( (path.length() == 1) || (path.charAt(1) != '~') ){
- path = System.getProperty( "user.home" )
- + path.substring(1);
- } }
+\<clean leading wigle\><<<
+ if( (path.length() > 0) && (path.charAt(0) == '~') ){
+ if( (path.length() == 1) || (path.charAt(1) != '~') ){
+ path = System.getProperty( "user.home" )
+ + path.substring(1);
+ } }
>>>
\<clean leading dots\><<<
- if( path.startsWith("..") ){
- path = userDir.substring(0,
- Math.max(0,Math.max(
- userDir.lastIndexOf("/")
- ,
- userDir.lastIndexOf("\\")
- )))
- + path.substring(2);
- }
- if( path.startsWith(".") ){
- path = userDir + slash + path.substring(1);
- }
+ if( path.startsWith("..") ){
+ path = userDir.substring(0,
+ Math.max(0,Math.max(
+ userDir.lastIndexOf("/")
+ ,
+ userDir.lastIndexOf("\\")
+ )))
+ + path.substring(2);
+ }
+ if( path.startsWith(".") ){
+ path = userDir + slash + path.substring(1);
+ }
>>>
\<clean internal dots\><<<
- int i;
- while(
- ((i=path.indexOf("/..")) != -1)
- ||
- ((i=path.indexOf("\\..")) != -1)
- ){
- String s = path.substring(0,i);
- int j = Math.max(s.lastIndexOf("/"), s.lastIndexOf("\\"));
- path = path.substring(0,j) + path.substring(i+3);
- }
- while(
- ((i=path.indexOf("/.")) != -1)
- ||
- ((i=path.indexOf("\\.")) != -1)
- ){
- String s = path.substring(0,i);
- int j = Math.max(s.indexOf("/"), s.indexOf("\\"));
- path = path.substring(0,j) + path.substring(i+2);
- }
+ int i;
+ while(
+ ((i=path.indexOf("/..")) != -1)
+ ||
+ ((i=path.indexOf("\\..")) != -1)
+ ){
+ String s = path.substring(0,i);
+ int j = Math.max(s.lastIndexOf("/"), s.lastIndexOf("\\"));
+ path = path.substring(0,j) + path.substring(i+3);
+ }
+ while(
+ ((i=path.indexOf("/.")) != -1)
+ ||
+ ((i=path.indexOf("\\.")) != -1)
+ ){
+ String s = path.substring(0,i);
+ int j = Math.max(s.indexOf("/"), s.indexOf("\\"));
+ path = path.substring(0,j) + path.substring(i+2);
+ }
>>>
@@ -3056,62 +3074,62 @@
if( trace ){
log.println(
"xtpipes (`version)"
- + "\n java.version: " + System.getProperty("java.version")
- + "\n java.class.path: " + System.getProperty("java.class.path")
- + "\n os.name: " + System.getProperty("os.name")
- + "\n user.home: " + System.getProperty("user.home")
- + "\n user.dir: " + System.getProperty("user.dir")
+ + "\n java.version: " + System.getProperty("java.version")
+ + "\n java.class.path: " + System.getProperty("java.class.path")
+ + "\n os.name: " + System.getProperty("os.name")
+ + "\n user.home: " + System.getProperty("user.home")
+ + "\n user.dir: " + System.getProperty("user.dir")
);
}
- if( connection != null ){
+ if( connection != null ){
`<profile info from connection`>
}
`<profile from preamble of file`>
if( trace ){
log.println(
- " url = " + url
+ " url = " + url
+ "\n contentType = " + contentType
- + "\n publicId = " + publicId
+ + "\n publicId = " + publicId
+ "\n systemId = " + systemId
+ "\n xtpipes = " + xtpipes
+ "\n root = " + root
+ "\n dtdRoot = " + dtdRoot
- );
+ );
} }
>>>
-\<profile info from connection\><<<
-contentType = connection . getContentType();
+\<profile info from connection\><<<
+contentType = connection . getContentType();
url = connection . getURL() . toString();
->>>
+>>>
-
-
-\<profile from preamble of file\><<<
-int max = 8192;
+
+
+\<profile from preamble of file\><<<
+int max = 8192;
int buffSize = 4096;
byte [] buff = new byte [ buffSize ];
-int m = 0;
-int length = 0;
+int m = 0;
+int length = 0;
int ch;
int type = `<undef type`>;
String token = null;
-while( m < max ){
- try{
- int k = Math.min( max - m, buffSize );
- length = inputStream.read( buff, 0, k );
- if( length == -1 ){ break; }
- if( length == 0 ){ continue; }
- } catch (java.io.IOException e){
- System.err.println( "--- xtpipes error --- : " + e );
- break;
- }
- for(int i = 0 ; i < length; i++ ){
- `<search preamble info`>
- m++;
-} }
->>>
+while( m < max ){
+ try{
+ int k = Math.min( max - m, buffSize );
+ length = inputStream.read( buff, 0, k );
+ if( length == -1 ){ break; }
+ if( length == 0 ){ continue; }
+ } catch (java.io.IOException e){
+ System.err.println( "--- xtpipes error --- : " + e );
+ break;
+ }
+ for(int i = 0 ; i < length; i++ ){
+ `<search preamble info`>
+ m++;
+} }
+>>>
%%%%%%%%%%%%%
@@ -3120,39 +3138,39 @@
-
-\<search preamble info\><<<
-switch( ch = buff[i] ){
- case '<': token = "";
+
+\<search preamble info\><<<
+switch( ch = buff[i] ){
+ case '<': token = "";
type = `<new tok`>;
- break;
+ break;
case '>': if( token != null ){
token = token . replaceAll( "\\s+", " ");
`<at token end`>
token = null;
}
- break;
- case '\n':
- case ' ': if( token != null ){
+ break;
+ case '\n':
+ case ' ': if( token != null ){
`<at token space`>
}
- break;
+ break;
case '"':
case '\'': if( token == null ){ break; }
`<public and system ids`>
- default: if( token != null ){
+ default: if( token != null ){
if( type == `<pre doctype`> ){
if( ch == 'D' ){
type = `<doctype`>;
token += (char) ch;
} else { token = null; type = `<undef type`>; }
- }
- else
+ }
+ else
if( token.equals("") && (type == `<new tok`>) ){
`<get token type`>
} else { token += (char) ch; }
-} }
->>>
+} }
+>>>
\<public and system ids\><<<
@@ -3163,7 +3181,7 @@
type = `<system id`>;
token = "";
break;
- }
+ }
else if( type == `<system id`> ){
systemId = token.trim().substring(1);
token = null;
@@ -3179,10 +3197,10 @@
break;
case '?': type = `<proc instruction`> ;
break;
- default: if( Character.isLetter(ch)
- && ((root == null) || (metaType == null)) ){
+ default: if( Character.isLetter(ch)
+ && ((root == null) || (metaType == null)) ){
type = `<root or meta`>;
- token += (char) ch;
+ token += (char) ch;
} else { token = null; }
}
>>>
@@ -3225,7 +3243,7 @@
} else {
token = null;
}
- } else {
+ } else {
if( root == null ){
root = token;
}
@@ -3236,7 +3254,7 @@
type = `<doctype root`>;
token = " ";
} else { token = null; }
-} else if( type == `<doctype root`> ){
+} else if( type == `<doctype root`> ){
if( !token.trim().equals("") ){
dtdRoot = token.trim();
token = " ";
@@ -3255,8 +3273,8 @@
}
} else { token += ' '; }
>>>
-
+
\<InputObject fields\><<<
String dtdRoot = null,
publicId = null,
@@ -3303,14 +3321,14 @@
Remove XtPipesSearch!!!!!!!!!!!!!!
\<\><<<
-try{
- `<get sax reader`>
+try{
+ `<get sax reader`>
saxReader.setContentHandler( new XtPipesSearch() );
`<body of search string for xtpipes instruction`>
- saxReaderStack.push( saxReader );
-} catch(Exception e){
+ saxReaderStack.push( saxReader );
+} catch(Exception e){
e.printStackTrace();
- instructionErr( node, errMsg + e.toString(), 13 );
+ instructionErr( node, errMsg + e.toString(), 13 );
}
>>>
@@ -3332,7 +3350,7 @@
\<xtpipes fields DELETED\><<<
private static class XtPipesSearch extends DefaultHandler {
- public void endElement(String uri,
+ public void endElement(String uri,
String localName, String qName){
`<extract root element name`>
}
@@ -3355,25 +3373,25 @@
\<extract script file name\><<<
try {
- `<get sax reader`>
- saxReader.setContentHandler(new DefaultHandler() {
- public void startElement(String uri, String localName,
- String qName, Attributes atts) {
+ `<get sax reader`>
+ saxReader.setContentHandler(new DefaultHandler() {
+ public void startElement(String uri, String localName,
+ String qName, Attributes atts) {
String filename = atts.getValue("file");
if( filename != null ){
scriptFile = filename;
`<show script file name in log file`>
needScript = true;
} }
- });
- String str = "<xtpipes " + attrs + "/>";
- StringReader reader = new StringReader(str);
- InputSource in = new InputSource(reader);
- saxReader.parse(in);
+ });
+ String str = "<xtpipes " + attrs + "/>";
+ StringReader reader = new StringReader(str);
+ InputSource in = new InputSource(reader);
+ saxReader.parse(in);
saxReaderStack.push( saxReader );
-} catch(Exception e){
- System.err.println( "--- Error 10 --- " + e );
-}
+} catch(Exception e){
+ System.err.println( "--- Error 10 --- " + e );
+}
>>>
@@ -3407,17 +3425,17 @@
\<output system info\><<<
logWriter.println(
"xtpipes (`version)"
- + "\n java.version: " + System.getProperty("java.version")
- + "\n java.class.path: " + System.getProperty("java.class.path")
- + "\n os.name: " + System.getProperty("os.name")
- + "\n user.home: " + System.getProperty("user.home")
- + "\n user.dir: " + System.getProperty("user.dir")
+ + "\n java.version: " + System.getProperty("java.version")
+ + "\n java.class.path: " + System.getProperty("java.class.path")
+ + "\n os.name: " + System.getProperty("os.name")
+ + "\n user.home: " + System.getProperty("user.home")
+ + "\n user.dir: " + System.getProperty("user.dir")
);
for( int k=0; k<args.length; k++ ){
logWriter.println( " " + args[k] );
}
>>>
-
+
%%%%%%%%%%%%%
\subsection{Script to be Used}
%%%%%%%%%%%%%
@@ -3466,9 +3484,9 @@
NamedNodeMap attributes = node.getAttributes();
for(int i=0; i < attributes.getLength(); i++ ){
Node attr = attributes.item(i);
- logWriter.print( " " + attr.getNodeName()
+ logWriter.print( " " + attr.getNodeName()
+ "=\"" + attr.getNodeValue() + "\"" );
- } }
+ } }
logWriter.println(); logWriter.flush();
}
>>>
@@ -3517,7 +3535,7 @@
String [] m2x = new String [ml2xml.length + 1];
for(int cnt=0; cnt < ml2xml.length; cnt++){
m2x[cnt] = ml2xml[cnt];
- }
+ }
ml2xml = m2x;
}
ml2xml[ ml2xml.length - 1 ] = args[n].substring(2);
@@ -3529,23 +3547,23 @@
try{
ml2xmlClassObj = Class.forName( "ml2xml.Ml2xml" );
} catch (java.lang.ClassNotFoundException cnf ){
- instructionErr( null, "Class not found: ml2xml.Ml2xml", 25 );
+ instructionErr( null, "Class not found: ml2xml.Ml2xml", 25 );
}
-Class<?> [] argTyp = { String.class, String[].class };
-Constructor<?> con = ml2xmlClassObj.getConstructor( argTyp );
+Class<?> [] argTyp = { String.class, String[].class };
+Constructor<?> con = ml2xmlClassObj.getConstructor( argTyp );
try{
`<trace call to ml2xml`>
- inputStream = (InputStream) con.newInstance(
+ inputStream = (InputStream) con.newInstance(
new Object[]{xml, ml2xml}
- );
+ );
} catch(java.lang.reflect.InvocationTargetException ite){
String s = "Problem at: ml2xml.Ml2xml(" + xml + ","
+ "new String[]{" ;
for(int i=0; i < Xtpipes.ml2xml.length; i++){
s += ((i==0)? "\"" : ", \"") + Xtpipes.ml2xml[i] + "\"";
}
- s += "})";
- instructionErr( null, s + "; " + ite.getCause(), 38);
+ s += "})";
+ instructionErr( null, s + "; " + ite.getCause(), 38);
}
>>>
@@ -3554,10 +3572,10 @@
\<Ml2xml close files\><<<
if( Xtpipes.ml2xml != null ){
- Class<?> [] argTyp = {};
- Method m = ml2xmlClassObj . getMethod( "closeFiles", argTyp );
- m.invoke( null, new Object[0] );
-}
+ Class<?> [] argTyp = {};
+ Method m = ml2xmlClassObj . getMethod( "closeFiles", argTyp );
+ m.invoke( null, new Object[0] );
+}
>>>
\<trace call to ml2xml\><<<
@@ -3567,18 +3585,18 @@
for(int i=0; i < Xtpipes.ml2xml.length; i++){
s += ((i==0)? "\"" : ", \"") + Xtpipes.ml2xml[i] + "\"";
}
- s += "})";
- Xtpipes.logWriter.println( s );
+ s += "})";
+ Xtpipes.logWriter.println( s );
}
>>>
\<close ml2xml files\><<<
if( ml2xmlClassObj != null ){
- Class<?> [] argTypes = { };
- Method m = ml2xmlClassObj.getMethod( "closeFiles", argTypes );
- Object parmValues[] = new Object[0];
- m.invoke( null, parmValues );
+ Class<?> [] argTypes = { };
+ Method m = ml2xmlClassObj.getMethod( "closeFiles", argTypes );
+ Object parmValues[] = new Object[0];
+ m.invoke( null, parmValues );
}
>>>
@@ -3588,8 +3606,8 @@
>>>
Ml2xml is referenced through reflection instead of directly so that xtpipes can
-be delivered also without that utility, e.g., for tex4ht where no treatment of faulty
-XML file is to be done. In fact, this approach can be generalized to offer
+be delivered also without that utility, e.g., for tex4ht where no treatment of faulty
+XML file is to be done. In fact, this approach can be generalized to offer
arbitrary filter for the input.
@@ -3618,14 +3636,14 @@
>>>
\<String toUni( char[], start, length, filter )\><<<
-private static int D800 = Integer.parseInt("D800", 16);
-private static int DFFF = Integer.parseInt("DFFF", 16);
-private static int DC00 = Integer.parseInt("DC00", 16);
-private static int X400 = Integer.parseInt("400",16);
+private static int D800 = Integer.parseInt("D800", 16);
+private static int DFFF = Integer.parseInt("DFFF", 16);
+private static int DC00 = Integer.parseInt("DC00", 16);
+private static int X400 = Integer.parseInt("400",16);
private static int X10000 = Integer.parseInt("10000",16);
-public static String toUni( char[] ch, int start, int length,
+public static String toUni( char[] ch, int start, int length,
String filter ){
StringBuffer buf = new StringBuffer(length);
for (int i = 0; i < length; i++) {
@@ -3634,14 +3652,14 @@
|| (chr > 31) && (chr < 127) ;
if( filter.indexOf(chr) > -1 ){ ascii = false; }
- if( (chr >= D800) && (chr<= DFFF) ){
- chr = ((ch[i] - D800) * X400 + (ch[++i] - DC00)) + X10000;
- }
+ if( (chr >= D800) && (chr<= DFFF) ){
+ chr = ((ch[i] - D800) * X400 + (ch[++i] - DC00)) + X10000;
+ }
buf.append(
ascii ? Character.toString((char) chr)
- : ("&#x"
+ : ("&#x"
+ Integer.toHexString(chr).toUpperCase()
+ ";" ) );
}
@@ -3677,23 +3695,23 @@
throws Exception {
String err = "--- xtpipes error " + num + " --- ";
if( node != null ){
- err += "At <" + node.getNodeName();
+ err += "At <" + node.getNodeName();
NamedNodeMap attr = node.getAttributes();
for(int i=0; i<attr.getLength(); i++){
Node nd = attr.item(i);
err += " " +
- nd.getNodeName() + "=\"" +
+ nd.getNodeName() + "=\"" +
nd.getNodeValue() + "\"" ;
}
- err += " > : " ;
+ err += " > : " ;
}
err += e;
`<close ml2xml files`>
Xtpipes.logWriter.flush();
- if( exceptionErrs ) { throw new Exception( err ); }
- else {
+ if( exceptionErrs ) { throw new Exception( err ); }
+ else {
System.err.println( err );
- System.exit(1);
+ System.exit(1);
}
}
>>>
@@ -3707,9 +3725,9 @@
Xtpipes.logWriter.println(
"--- xtpipes error " + num + " --- " + e
);
- for(int i=st.length-1; i>=0; i-- ){
- Xtpipes.logWriter.println( st[i].toString() );
- }
+ for(int i=st.length-1; i>=0; i-- ){
+ Xtpipes.logWriter.println( st[i].toString() );
+ }
instructionErr( node, e, num );
}
>>>
@@ -3734,11 +3752,11 @@
+ " line " + e.getLineNumber()
+ " col " + e.getColumnNumber()
+ " : " + e.getMessage() ;
- if( exceptionErrs ) { throw new SAXParseException(
+ if( exceptionErrs ) { throw new SAXParseException(
err, (org.xml.sax.Locator) null ); }
- else {
+ else {
System.err.println( err );
- System.exit(1);
+ System.exit(1);
} } }
>>>
@@ -3765,7 +3783,7 @@
}
public void fatalError(TransformerException e) throws TransformerException {
showSpecifics(e);
- }
+ }
void showSpecifics(TransformerException e)
throws TransformerException{
String err = e.getMessage() ;
@@ -3790,7 +3808,7 @@
}
public void fatalError(TransformerException e) throws TransformerException {
showSpecifics(e);
- }
+ }
void showSpecifics(TransformerException e)
throws TransformerException{
String err = e.getMessage() ;
@@ -3813,7 +3831,7 @@
}
public void fatalError(TransformerException e) throws TransformerException {
showSpecifics(e);
- }
+ }
void showSpecifics(TransformerException e)
throws TransformerException{
String err = e.getMessage() ;
@@ -3839,10 +3857,10 @@
\<static String serialize( dom )\><<<
static String serialize( Node root ){
- if( root.getNodeType() == Node.TEXT_NODE) {
- return root.getNodeValue();
- }
- if( root.getNodeType() == Node.ELEMENT_NODE) {
+ if( root.getNodeType() == Node.TEXT_NODE) {
+ return root.getNodeValue();
+ }
+ if( root.getNodeType() == Node.ELEMENT_NODE) {
String ser = "";
String tagName = root.getNodeName();
ser += "<" + tagName;
@@ -3852,95 +3870,95 @@
ser += "</" + tagName + ">";
return ser;
}
- if( root.getNodeType() == Node.DOCUMENT_NODE) {
+ if( root.getNodeType() == Node.DOCUMENT_NODE) {
String ser = "";
`<res += serialize children`>
return ser;
- }
+ }
if( root == null ){ return "null"; }
return "";
}
>>>
\<res += serialize children\><<<
-NodeList children = root.getChildNodes();
-if(children.getLength() > 0) {
- for(int i = 0; i < children.getLength(); i++) {
- ser += serialize(children.item(i));
-} }
+NodeList children = root.getChildNodes();
+if(children.getLength() > 0) {
+ for(int i = 0; i < children.getLength(); i++) {
+ ser += serialize(children.item(i));
+} }
>>>
\<res += serialize attributes\><<<
-NamedNodeMap attributes = root.getAttributes();
-for(int i = 0; i < attributes.getLength(); i++) {
- Attr attribute = (Attr) attributes.item(i);
- ser += "\n" + attribute.getName() + "=\""
- + attribute.getValue() + "\" ";
-}
+NamedNodeMap attributes = root.getAttributes();
+for(int i = 0; i < attributes.getLength(); i++) {
+ Attr attribute = (Attr) attributes.item(i);
+ ser += "\n" + attribute.getName() + "=\""
+ + attribute.getValue() + "\" ";
+}
>>>
-%%%%%%%%%%%%%
-\subsection{Clean Xmlns}
-%%%%%%%%%%%%%
-
-
-\<static void cleanXmlns( dom )\><<<
+%%%%%%%%%%%%%
+\subsection{Clean Xmlns}
+%%%%%%%%%%%%%
+
+
+\<static void cleanXmlns( dom )\><<<
static ArrayList<String> nsName, nsValue;
-static void cleanXmlns( Node root ){
- if( root.getNodeType() == Node.ELEMENT_NODE) {
+static void cleanXmlns( Node root ){
+ if( root.getNodeType() == Node.ELEMENT_NODE) {
int top = nsName.size();
- `<clean xmlns attributes`>
- `<clean xmlns in children`>
+ `<clean xmlns attributes`>
+ `<clean xmlns in children`>
for(int i=nsName.size(); i>top; ){
i--;
nsName.remove(i);
nsValue.remove(i);
}
- } else if( root.getNodeType() == Node.DOCUMENT_NODE) {
+ } else if( root.getNodeType() == Node.DOCUMENT_NODE) {
nsName = new ArrayList<String>();
nsValue = new ArrayList<String>();
- `<clean xmlns in children`>
+ `<clean xmlns in children`>
nsName = null;
nsValue = null;
-} }
->>>
-
-
-
-\<clean xmlns in children\><<<
-NodeList children = root.getChildNodes();
-if(children.getLength() > 0) {
- for(int i = 0; i < children.getLength(); i++) {
- cleanXmlns(children.item(i));
-} }
->>>
-
-\<clean xmlns attributes\><<<
+} }
+>>>
+
+
+
+\<clean xmlns in children\><<<
+NodeList children = root.getChildNodes();
+if(children.getLength() > 0) {
+ for(int i = 0; i < children.getLength(); i++) {
+ cleanXmlns(children.item(i));
+} }
+>>>
+
+\<clean xmlns attributes\><<<
ArrayList<Attr> remove = new ArrayList<Attr>();
-NamedNodeMap attributes = root.getAttributes();
-for(int i = 0; i < attributes.getLength(); i++) {
- Attr attribute = (Attr) attributes.item(i);
- String name = attribute.getName();
- if( name.startsWith("xmlns") ){
+NamedNodeMap attributes = root.getAttributes();
+for(int i = 0; i < attributes.getLength(); i++) {
+ Attr attribute = (Attr) attributes.item(i);
+ String name = attribute.getName();
+ if( name.startsWith("xmlns") ){
if( (name.length() == 5) || (name.charAt(5) == ':') ){
String value = attribute.getValue();
`<bool := xmlns active?`>
if( bool ){ remove.add(attribute);
} else { nsName.add(name); nsValue.add(value); }
-} } }
+} } }
for(int i=remove.size(); i>0; ){
i--;
((Element) root).removeAttributeNode( (Attr) remove.get(i) );
}
remove = null;
->>>
+>>>
\<bool := xmlns active?\><<<
boolean bool = false;
-for(int k=nsName.size(); k>0; ){
+for(int k=nsName.size(); k>0; ){
k--;
if( ((String) nsName.get(k)) . equals(name) ){
bool = ((String) nsValue.get(k)) . equals(value);
@@ -4021,7 +4039,7 @@
boolean savemode=false;
String code="", match = null;
Stack<Object[]> stack = new Stack<Object[]>();
- public ScriptsManager( PrintWriter out,
+ public ScriptsManager( PrintWriter out,
HashMap<String,Object> scripts,
Method method,
PrintWriter log, boolean trace ){
@@ -4044,11 +4062,11 @@
\<ScriptsManager imports\><<<
import org.xml.sax.helpers.DefaultHandler;
-import org.xml.sax.*;
-import java.io.*;
+import org.xml.sax.*;
+import java.io.*;
import java.lang.reflect.*;
import java.util.HashMap;
-import java.util.Stack;
+import java.util.Stack;
>>>
%%%%%%%%%%%%%
@@ -4069,9 +4087,9 @@
String name = atts.getQName(i),
value = atts.getValue(i);
`<record xmlns`>
- s += " " + name + "=\"" +
+ s += " " + name + "=\"" +
XtpipesUni.toUni(value, "<>&\"") + "\"";
- }
+ }
if( flag ){ `<add missing xmlns attributes`> }
s += ">" ;
`<set start element`>
@@ -4086,7 +4104,7 @@
\<flag := start new save?\><<<
String key = (atts==null)?
- null
+ null
: (qName + "::" + atts.getValue("class"));
boolean flag = (key != null) && scripts.containsKey(key);
@@ -4097,12 +4115,12 @@
>>>
\<set start element\><<<
-if( flag ){
- Object [] state = { new Boolean(savemode), code, match };
+if( flag ){
+ Object [] state = { new Boolean(savemode), code, match };
stack.push( state );
savemode=true; code=""; match= key;
} else {
- Object [] state = { new Boolean(savemode), null, null };
+ Object [] state = { new Boolean(savemode), null, null };
stack.push( state );
}
add( s );
@@ -4130,8 +4148,8 @@
public void endElement(String ns, String sName, String qName){
String s = "</" + qName + ">";
add( s );
- Object [] state = (Object []) stack.pop();
- if( (String) state[1] != null ){
+ Object [] state = (Object []) stack.pop();
+ if( (String) state[1] != null ){
`<s := invoke script`>
`<set end element`>
`<recall status of xmlns above element`>
@@ -4150,11 +4168,11 @@
\<s := invoke script\><<<
-Object parmValues[] = new Object[2];
+Object parmValues[] = new Object[2];
parmValues[0] = scripts.get( match );
-parmValues[1] = code;
-try {
- s = (String) method.invoke( null, parmValues );
+parmValues[1] = code;
+try {
+ s = (String) method.invoke( null, parmValues );
} catch(java.lang.reflect.InvocationTargetException e){
log.println("--- ScriptsManager Error 1 --- " + e.getCause() );
log.flush();
@@ -4167,9 +4185,9 @@
Can't invoke exception above.
-\<set end element\><<<
+\<set end element\><<<
savemode = ((Boolean) state[0]).booleanValue();
-code = (String) state[1];
+code = (String) state[1];
match = (String) state[2];
>>>
@@ -4181,11 +4199,11 @@
%%%%%%%%%%%%%
\<record xmlns\><<<
-if( name.startsWith("xmlns") ){
+if( name.startsWith("xmlns") ){
if( (name.length() == 5) || (name.charAt(5) == ':') ){
`<bool := xmlns active?`>
- if( !bool ){
- nsName.add(name); nsValue.add(value);
+ if( !bool ){
+ nsName.add(name); nsValue.add(value);
} } }
>>>
@@ -4204,7 +4222,7 @@
String nm = (String) nsName.get(i);
if( ! registry.contains(nm) ){
registry.add( nm );
- s += " " + nm + "=\"" +
+ s += " " + nm + "=\"" +
XtpipesUni.toUni( (String) nsValue.get(i), "<>&\"") + "\"";
} }
>>>
@@ -4213,7 +4231,7 @@
\<ScriptsManager fields\><<<
-ArrayList<String> nsName = new ArrayList<String>(),
+ArrayList<String> nsName = new ArrayList<String>(),
nsValue = new ArrayList<String>();
Stack<Integer> nsStack = new Stack<Integer>();
>>>
@@ -4233,14 +4251,14 @@
\<remove xmlns attributes supported from above\><<<
int m = s.indexOf('>');
char [] attrs = s.substring(0,m).toCharArray();
-int result = qName.length()+1,
+int result = qName.length()+1,
mark = result,
from=-1,
control = `<xmlns name`>;
char delimiter = ' ';
String name="";
for(int i=result; i<m; i++ ){
- attrs[result++] = attrs[i];
+ attrs[result++] = attrs[i];
switch( control ){
case `<xmlns name`>: { `<insert attribute name`> break; }
case `<xmlns quote`>: { `<insert attribute quote`> break; }
@@ -4255,8 +4273,8 @@
\<insert attribute name\><<<
if( attrs[i] == '=' ){
name = (new String(attrs,mark,result-mark-1)).trim();
- control = `<xmlns quote`>;
-}
+ control = `<xmlns quote`>;
+}
>>>
\<insert attribute quote\><<<
@@ -4269,7 +4287,7 @@
\<insert attribute value\><<<
if( attrs[i] == delimiter ){
- if( name.startsWith("xmlns")
+ if( name.startsWith("xmlns")
&& ((name.length() == 5) || (name.charAt(5) == ':')) ){
String value = (new String(attrs,from,result-from-1)).trim();
`<bool := xmlns active?`>
@@ -4277,7 +4295,7 @@
}
mark = result;
control = `<xmlns name`>;
-}
+}
>>>
@@ -4346,7 +4364,7 @@
// `version
package xtpipes.util;
import org.xml.sax.ext.LexicalHandler;
-// import org.xml.sax.ContentHandler;
+// import org.xml.sax.ContentHandler;
import java.io.PrintWriter;
public class ScriptsManagerLH implements LexicalHandler {
ScriptsManager contentHandler;
@@ -4366,17 +4384,17 @@
public void startCDATA(){}
public void endCDATA(){}
public void startDTD(String x, String y, String z){}
- public void endDTD(){}
+ public void endDTD(){}
}
>>>
\begin{itemize}
\item
-The line breaks in the comments are to avoid sequences of comments
-loosing their intermediate line breaks and as a result causing
+The line breaks in the comments are to avoid sequences of comments
+loosing their intermediate line breaks and as a result causing
overflow of buffers.
-\item The comments in the preamble are included through the
+\item The comments in the preamble are included through the
preamble pattribute of xtpipes.
\end{itemize}
@@ -4405,11 +4423,11 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ifOption{win}
-{
+{
\AtEndDocument{
\OutputCodE\<dodoc.bat\>
\Needs{"dodoc"}
- }
+ }
}
{ \ifOption{doc}{
\AtEndDocument{\Needs{"
@@ -4417,11 +4435,11 @@
;
cd doc.dir
;
- java
- -classpath
+ java
+ -classpath
..:../cgjsapi.jar:../../../jldir.dir:../../../jldir.dir/jldoc.jar:../../../ml2xml.dir/ml2xml.dir/bin/ml2xml.jar
- jldoc.Jldoc
- -title "Xtpipes APIs"
+ jldoc.Jldoc
+ -title "Xtpipes APIs"
../work.dir
;
cd ..
@@ -4434,11 +4452,11 @@
\<dodoc.bat\><<<
-cd work.dir
+cd work.dir
if NOT EXIST bin mkdir bin
- javac -Xlint:unchecked -d bin xtpipes/*.java
+ javac -Xlint:unchecked -d bin xtpipes/*.java
javac -Xlint:unchecked -d bin xtpipes/util/*.java
- javac -Xlint:unchecked -d bin *.java
+ javac -Xlint:unchecked -d bin *.java
cd bin
jar cf xtpipes.jar *
cd ..
@@ -4459,7 +4477,7 @@
-\ifx\DOC\def
+\ifx\DOC\def
%%%%%%%%%%%%%%%%%%%%%%%
\<dodoc.bat\><<<
if NOT EXIST doc.dir mkdir doc.dir
@@ -4479,17 +4497,17 @@
../../..;..;../../jldoc;../../xtpipes/cgjsapi.jar;../../xtpipes/xtpipes.jar;../../jldoc/jldoc.jar;../../ml2xml.dir/ml2xml.dir/bin/ml2xml.jar
\ifOption{win} {}{
-\AtEndDocument{\Needs{%
- "cd /home/4/gurari/xtpipes.dir
- ;
- jar cf tex4ht.jar *
- ;
- mv tex4ht.jar /home/4/gurari/tex4ht.dir/texmf/tex4ht/bin/.
- ;
- cp /home/4/gurari/xtpipes.dir/xtpipes/lib/*
- /home/4/gurari/tex4ht.dir/texmf/tex4ht/xtpipes/.
-"}}
-}
+\AtEndDocument{\Needs{%
+ "cd /home/4/gurari/xtpipes.dir
+ ;
+ jar cf tex4ht.jar *
+ ;
+ mv tex4ht.jar /home/4/gurari/tex4ht.dir/texmf/tex4ht/bin/.
+ ;
+ cp /home/4/gurari/xtpipes.dir/xtpipes/lib/*
+ /home/4/gurari/tex4ht.dir/texmf/tex4ht/xtpipes/.
+"}}
+}
More information about the tex4ht-commits
mailing list