all: jars
-jars: saxon65.jar xalan2.jar xalan27.jar
+jars: saxon65.jar xalan27.jar
saxon65.jar: $(wildcard saxon65/src/com/nwalsh/saxon/*.java)
cd saxon65 && $(ANT) jar
cp saxon65/dist/saxon65.jar .
-xalan2.jar: $(wildcard xalan2/src/com/nwalsh/xalan/*.java)
- cd xalan2 && $(ANT) jar
- cp xalan2/dist/xalan2.jar .
-
xalan27.jar: $(wildcard xalan27/src/com/nwalsh/xalan/*.java)
cd xalan27 && $(ANT) jar
cp xalan27/dist/xalan27.jar .
+++ /dev/null
-*.class
-Makefile.incl
+++ /dev/null
-SOURCEPATH=..
-VPATH=$(SOURCEPATH)/
-CLASSBASE=$(SOURCEPATH)/.classes
-SUBDIRS=__PHONY__ com
-
-include Makefile.incl
-include ../.classes/Makefile.common
-
+++ /dev/null
-XALANROOT=/usr/local/java/xalan2
-
-CLASSPATH=$(CLASSBASE):$(XALANROOT)/bin/xalan.jar:$(XALANROOT)/bin/xml-apis.jar:$(XALANROOT)/bin/xercesImpl.jar:/usr/local/jwsdp-1.3/jaxp/lib/jaxp-api.jar
-
-all: $(CLASSFILES)
- -@for f in $(SUBDIRS); do \
- if [ "$$f" != "__PHONY__" ]; then \
- cd $$f; make all; cd ..; \
- fi \
- done
-
-clean:
- rm -f *.class
- -@for f in $(SUBDIRS); do \
- if [ "$$f" != "__PHONY__" ]; then \
- cd $$f; make clean; cd ..; \
- fi \
- done
-
-jar: all
- jar cf ../../xalan25.jar `find com -name "*.class" -print`
-
-%.class : %.java
- javac -classpath $(CLASSPATH) \
- -sourcepath $(SOURCEPATH) \
- -g -d $(CLASSBASE) \
- $<
-
-includes:
- classlist $(VPATH) > Makefile.incl
- -@for f in $(SUBDIRS); do \
- if [ "$$f" != "__PHONY__" ]; then \
- if [ -d "$$f" -a -f "$$f/Makefile" ]; then \
- cd $$f; make includes; cd ..; \
- else if [ ! -d "$$f" ]; then \
- mkdir $$f; \
- fi; \
- fi; \
- fi; \
- done
+++ /dev/null
-*.class
-Makefile.incl
+++ /dev/null
-SOURCEPATH=../..
-VPATH=$(SOURCEPATH)/com
-CLASSBASE=$(SOURCEPATH)/.classes
-SUBDIRS=__PHONY__ nwalsh
-
-include Makefile.incl
-include ../../.classes/Makefile.common
-
+++ /dev/null
-*.class
-Makefile.incl
+++ /dev/null
-SOURCEPATH=../../..
-VPATH=$(SOURCEPATH)/com/nwalsh
-CLASSBASE=$(SOURCEPATH)/.classes
-SUBDIRS=__PHONY__ xalan
-
-include Makefile.incl
-include ../../../.classes/Makefile.common
-
+++ /dev/null
-*.class
-Makefile.incl
+++ /dev/null
-SOURCEPATH=../../../..
-VPATH=$(SOURCEPATH)/com/nwalsh/xalan
-CLASSBASE=$(SOURCEPATH)/.classes
-SUBDIRS=__PHONY__
-
-include Makefile.incl
-include ../../../../.classes/Makefile.common
-
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- You may freely edit this file. See commented blocks below for -->
-<!-- some examples of how to customize the build. -->
-<!-- (If you delete it and reopen the project it will be recreated.) -->
-<project name="xalan2" default="default" basedir=".">
- <description>Builds, tests, and runs the project xalan2.</description>
- <import file="nbproject/build-impl.xml"/>
- <!--
-
- There exist several targets which are by default empty and which can be
- used for execution of your tasks. These targets are usually executed
- before and after some main targets. They are:
-
- -pre-init: called before initialization of project properties
- -post-init: called after initialization of project properties
- -pre-compile: called before javac compilation
- -post-compile: called after javac compilation
- -pre-compile-single: called before javac compilation of single file
- -post-compile-single: called after javac compilation of single file
- -pre-compile-test: called before javac compilation of JUnit tests
- -post-compile-test: called after javac compilation of JUnit tests
- -pre-compile-test-single: called before javac compilation of single JUnit test
- -post-compile-test-single: called after javac compilation of single JUunit test
- -pre-jar: called before JAR building
- -post-jar: called after JAR building
- -post-clean: called after cleaning build products
-
- (Targets beginning with '-' are not intended to be called on their own.)
-
- Example of inserting an obfuscator after compilation could look like this:
-
- <target name="-post-compile">
- <obfuscate>
- <fileset dir="${build.classes.dir}"/>
- </obfuscate>
- </target>
-
- For list of available properties check the imported
- nbproject/build-impl.xml file.
-
-
- Another way to customize the build is by overriding existing main targets.
- The targets of interest are:
-
- -init-macrodef-javac: defines macro for javac compilation
- -init-macrodef-junit: defines macro for junit execution
- -init-macrodef-debug: defines macro for class debugging
- -init-macrodef-java: defines macro for class execution
- -do-jar-with-manifest: JAR building (if you are using a manifest)
- -do-jar-without-manifest: JAR building (if you are not using a manifest)
- run: execution of project
- -javadoc-build: Javadoc generation
- test-report: JUnit report generation
-
- An example of overriding the target for project execution could look like this:
-
- <target name="run" depends="xalan2-impl.jar">
- <exec dir="bin" executable="launcher.exe">
- <arg file="${dist.jar}"/>
- </exec>
- </target>
-
- Notice that the overridden target depends on the jar target and not only on
- the compile target as the regular run target does. Again, for a list of available
- properties which you can use, check the target you are overriding in the
- nbproject/build-impl.xml file.
-
- -->
-</project>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-*** GENERATED FROM project.xml - DO NOT EDIT ***
-*** EDIT ../build.xml INSTEAD ***
-
-For the purpose of easier reading the script
-is divided into following sections:
-
- - initialization
- - compilation
- - jar
- - execution
- - debugging
- - javadoc
- - junit compilation
- - junit execution
- - junit debugging
- - applet
- - cleanup
-
--->
-<project name="xalan2-impl" default="default" basedir=".." xmlns:j2seproject3="http://www.netbeans.org/ns/j2se-project/3" xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1">
- <target name="default" depends="test,jar,javadoc" description="Build and test whole project."/>
- <!--
- ======================
- INITIALIZATION SECTION
- ======================
- -->
- <target name="-pre-init">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target name="-init-private" depends="-pre-init">
- <property file="nbproject/private/private.properties"/>
- </target>
- <target name="-init-user" depends="-pre-init,-init-private">
- <property file="${user.properties.file}"/>
- <!-- The two properties below are usually overridden -->
- <!-- by the active platform. Just a fallback. -->
- <property name="default.javac.source" value="1.4"/>
- <property name="default.javac.target" value="1.4"/>
- </target>
- <target name="-init-project" depends="-pre-init,-init-private,-init-user">
- <property file="nbproject/project.properties"/>
- </target>
- <target name="-do-init" depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property">
- <j2seproject1:property name="platform.home" value="platforms.${platform.active}.home"/>
- <j2seproject1:property name="platform.bootcp" value="platforms.${platform.active}.bootclasspath"/>
- <j2seproject1:property name="platform.compiler" value="platforms.${platform.active}.compile"/>
- <j2seproject1:property name="platform.javac.tmp" value="platforms.${platform.active}.javac"/>
- <condition property="platform.javac" value="${platform.home}/bin/javac">
- <equals arg1="${platform.javac.tmp}" arg2="$${platforms.${platform.active}.javac}"/>
- </condition>
- <property name="platform.javac" value="${platform.javac.tmp}"/>
- <j2seproject1:property name="platform.java.tmp" value="platforms.${platform.active}.java"/>
- <condition property="platform.java" value="${platform.home}/bin/java">
- <equals arg1="${platform.java.tmp}" arg2="$${platforms.${platform.active}.java}"/>
- </condition>
- <property name="platform.java" value="${platform.java.tmp}"/>
- <j2seproject1:property name="platform.javadoc.tmp" value="platforms.${platform.active}.javadoc"/>
- <condition property="platform.javadoc" value="${platform.home}/bin/javadoc">
- <equals arg1="${platform.javadoc.tmp}" arg2="$${platforms.${platform.active}.javadoc}"/>
- </condition>
- <property name="platform.javadoc" value="${platform.javadoc.tmp}"/>
- <condition property="platform.invalid" value="true">
- <or>
- <contains string="${platform.javac}" substring="$${platforms."/>
- <contains string="${platform.java}" substring="$${platforms."/>
- <contains string="${platform.javadoc}" substring="$${platforms."/>
- </or>
- </condition>
- <fail unless="platform.home">Must set platform.home</fail>
- <fail unless="platform.bootcp">Must set platform.bootcp</fail>
- <fail unless="platform.java">Must set platform.java</fail>
- <fail unless="platform.javac">Must set platform.javac</fail>
- <fail if="platform.invalid">Platform is not correctly set up</fail>
- <available file="${manifest.file}" property="manifest.available"/>
- <condition property="manifest.available+main.class">
- <and>
- <isset property="manifest.available"/>
- <isset property="main.class"/>
- <not>
- <equals arg1="${main.class}" arg2="" trim="true"/>
- </not>
- </and>
- </condition>
- <condition property="manifest.available+main.class+mkdist.available">
- <and>
- <istrue value="${manifest.available+main.class}"/>
- <isset property="libs.CopyLibs.classpath"/>
- </and>
- </condition>
- <condition property="have.tests">
- <or>
- <available file="${test.src.dir}"/>
- </or>
- </condition>
- <condition property="have.sources">
- <or>
- <available file="${src.dir}"/>
- </or>
- </condition>
- <condition property="netbeans.home+have.tests">
- <and>
- <isset property="netbeans.home"/>
- <isset property="have.tests"/>
- </and>
- </condition>
- <condition property="no.javadoc.preview">
- <isfalse value="${javadoc.preview}"/>
- </condition>
- <property name="run.jvmargs" value=""/>
- <property name="javac.compilerargs" value=""/>
- <property name="work.dir" value="${basedir}"/>
- <condition property="no.deps">
- <and>
- <istrue value="${no.dependencies}"/>
- </and>
- </condition>
- <property name="javac.debug" value="true"/>
- <property name="javadoc.preview" value="true"/>
- </target>
- <target name="-post-init">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target name="-init-check" depends="-pre-init,-init-private,-init-user,-init-project,-do-init">
- <fail unless="src.dir">Must set src.dir</fail>
- <fail unless="test.src.dir">Must set test.src.dir</fail>
- <fail unless="build.dir">Must set build.dir</fail>
- <fail unless="dist.dir">Must set dist.dir</fail>
- <fail unless="build.classes.dir">Must set build.classes.dir</fail>
- <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail>
- <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail>
- <fail unless="build.test.results.dir">Must set build.test.results.dir</fail>
- <fail unless="build.classes.excludes">Must set build.classes.excludes</fail>
- <fail unless="dist.jar">Must set dist.jar</fail>
- </target>
- <target name="-init-macrodef-property">
- <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1">
- <attribute name="name"/>
- <attribute name="value"/>
- <sequential>
- <property name="@{name}" value="${@{value}}"/>
- </sequential>
- </macrodef>
- </target>
- <target name="-init-macrodef-javac">
- <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute name="srcdir" default="${src.dir}"/>
- <attribute name="destdir" default="${build.classes.dir}"/>
- <attribute name="classpath" default="${javac.classpath}"/>
- <attribute name="debug" default="${javac.debug}"/>
- <element name="customize" optional="true"/>
- <sequential>
- <javac srcdir="@{srcdir}" destdir="@{destdir}" debug="@{debug}" deprecation="${javac.deprecation}" source="${javac.source}" target="${javac.target}" fork="yes" executable="${platform.javac}" tempdir="${java.io.tmpdir}" includeantruntime="false">
- <classpath>
- <path path="@{classpath}"/>
- </classpath>
- <compilerarg line="${javac.compilerargs}"/>
- <customize/>
- </javac>
- </sequential>
- </macrodef>
- </target>
- <target name="-init-macrodef-junit">
- <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute name="includes" default="**/*Test.java"/>
- <sequential>
- <junit showoutput="true" fork="true" dir="${basedir}" failureproperty="tests.failed" errorproperty="tests.failed" jvm="${platform.java}">
- <batchtest todir="${build.test.results.dir}">
- <fileset dir="${test.src.dir}" includes="@{includes}"/>
- </batchtest>
- <classpath>
- <path path="${run.test.classpath}"/>
- </classpath>
- <syspropertyset>
- <propertyref prefix="test-sys-prop."/>
- <mapper type="glob" from="test-sys-prop.*" to="*"/>
- </syspropertyset>
- <formatter type="brief" usefile="false"/>
- <formatter type="xml"/>
- <jvmarg line="${run.jvmargs}"/>
- </junit>
- </sequential>
- </macrodef>
- </target>
- <target name="-init-macrodef-nbjpda">
- <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
- <attribute name="name" default="${main.class}"/>
- <attribute name="classpath" default="${debug.classpath}"/>
- <attribute name="stopclassname" default=""/>
- <sequential>
- <nbjpdastart transport="dt_socket" addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}">
- <classpath>
- <path path="@{classpath}"/>
- </classpath>
- <bootclasspath>
- <path path="${platform.bootcp}"/>
- </bootclasspath>
- </nbjpdastart>
- </sequential>
- </macrodef>
- <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1">
- <attribute name="dir" default="${build.classes.dir}"/>
- <sequential>
- <nbjpdareload>
- <fileset includes="${fix.includes}*.class" dir="@{dir}"/>
- </nbjpdareload>
- </sequential>
- </macrodef>
- </target>
- <target name="-init-macrodef-debug">
- <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
- <attribute name="classname" default="${main.class}"/>
- <attribute name="classpath" default="${debug.classpath}"/>
- <element name="customize" optional="true"/>
- <sequential>
- <java fork="true" classname="@{classname}" dir="${work.dir}" jvm="${platform.java}">
- <jvmarg value="-Xdebug"/>
- <jvmarg value="-Xnoagent"/>
- <jvmarg value="-Djava.compiler=none"/>
- <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
- <jvmarg line="${run.jvmargs}"/>
- <classpath>
- <path path="@{classpath}"/>
- </classpath>
- <syspropertyset>
- <propertyref prefix="run-sys-prop."/>
- <mapper type="glob" from="run-sys-prop.*" to="*"/>
- </syspropertyset>
- <customize/>
- </java>
- </sequential>
- </macrodef>
- </target>
- <target name="-init-macrodef-java">
- <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1">
- <attribute name="classname" default="${main.class}"/>
- <element name="customize" optional="true"/>
- <sequential>
- <java fork="true" classname="@{classname}" dir="${work.dir}" jvm="${platform.java}">
- <jvmarg line="${run.jvmargs}"/>
- <classpath>
- <path path="${run.classpath}"/>
- </classpath>
- <syspropertyset>
- <propertyref prefix="run-sys-prop."/>
- <mapper type="glob" from="run-sys-prop.*" to="*"/>
- </syspropertyset>
- <customize/>
- </java>
- </sequential>
- </macrodef>
- </target>
- <target name="-init-presetdef-jar">
- <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1">
- <jar jarfile="${dist.jar}" compress="${jar.compress}">
- <j2seproject1:fileset dir="${build.classes.dir}"/>
- </jar>
- </presetdef>
- </target>
- <target name="init" depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar"/>
- <!--
- ===================
- COMPILATION SECTION
- ===================
- -->
- <target name="deps-jar" depends="init" unless="no.deps"/>
- <target name="-pre-pre-compile" depends="init,deps-jar">
- <mkdir dir="${build.classes.dir}"/>
- </target>
- <target name="-pre-compile">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target name="-do-compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile" if="have.sources">
- <j2seproject3:javac/>
- <copy todir="${build.classes.dir}">
- <fileset dir="${src.dir}" excludes="${build.classes.excludes}"/>
- </copy>
- </target>
- <target name="-post-compile">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target name="compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project."/>
- <target name="-pre-compile-single">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target name="-do-compile-single" depends="init,deps-jar,-pre-pre-compile">
- <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
- <j2seproject3:javac>
- <customize>
- <patternset includes="${javac.includes}"/>
- </customize>
- </j2seproject3:javac>
- </target>
- <target name="-post-compile-single">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target name="compile-single" depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single"/>
- <!--
- ====================
- JAR BUILDING SECTION
- ====================
- -->
- <target name="-pre-pre-jar" depends="init">
- <dirname property="dist.jar.dir" file="${dist.jar}"/>
- <mkdir dir="${dist.jar.dir}"/>
- </target>
- <target name="-pre-jar">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target name="-do-jar-without-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" unless="manifest.available">
- <j2seproject1:jar/>
- </target>
- <target name="-do-jar-with-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" unless="manifest.available+main.class">
- <j2seproject1:jar manifest="${manifest.file}"/>
- </target>
- <target name="-do-jar-with-mainclass" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class" unless="manifest.available+main.class+mkdist.available">
- <j2seproject1:jar manifest="${manifest.file}">
- <j2seproject1:manifest>
- <j2seproject1:attribute name="Main-Class" value="${main.class}"/>
- </j2seproject1:manifest>
- </j2seproject1:jar>
- <echo>To run this application from the command line without Ant, try:</echo>
- <property name="build.classes.dir.resolved" location="${build.classes.dir}"/>
- <property name="dist.jar.resolved" location="${dist.jar}"/>
- <pathconvert property="run.classpath.with.dist.jar">
- <path path="${run.classpath}"/>
- <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>
- </pathconvert>
- <echo>${platform.java} -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>
- </target>
- <target name="-do-jar-with-libraries" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available">
- <property name="build.classes.dir.resolved" location="${build.classes.dir}"/>
- <pathconvert property="run.classpath.without.build.classes.dir">
- <path path="${run.classpath}"/>
- <map from="${build.classes.dir.resolved}" to=""/>
- </pathconvert>
- <pathconvert property="jar.classpath" pathsep=" ">
- <path path="${run.classpath.without.build.classes.dir}"/>
- <chainedmapper>
- <flattenmapper/>
- <globmapper from="*" to="lib/*"/>
- </chainedmapper>
- </pathconvert>
- <taskdef classname="org.netbeans.modules.java.j2seproject.copylibstask.CopyLibs" name="copylibs" classpath="${libs.CopyLibs.classpath}"/>
- <copylibs manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}" jarfile="${dist.jar}" compress="${jar.compress}">
- <fileset dir="${build.classes.dir}"/>
- <manifest>
- <attribute name="Main-Class" value="${main.class}"/>
- <attribute name="Class-Path" value="${jar.classpath}"/>
- </manifest>
- </copylibs>
- <echo>To run this application from the command line without Ant, try:</echo>
- <property name="dist.jar.resolved" location="${dist.jar}"/>
- <echo>${platform.java} -jar "${dist.jar.resolved}"</echo>
- </target>
- <target name="-post-jar">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target name="jar" depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-do-jar-with-libraries,-post-jar" description="Build JAR."/>
- <!--
- =================
- EXECUTION SECTION
- =================
- -->
- <target name="run" depends="init,compile" description="Run a main class.">
- <j2seproject1:java>
- <customize>
- <arg line="${application.args}"/>
- </customize>
- </j2seproject1:java>
- </target>
- <target name="run-single" depends="init,compile-single">
- <fail unless="run.class">Must select one file in the IDE or set run.class</fail>
- <j2seproject1:java classname="${run.class}"/>
- </target>
- <!--
- =================
- DEBUGGING SECTION
- =================
- -->
- <target name="-debug-start-debugger" if="netbeans.home" depends="init">
- <j2seproject1:nbjpdastart name="${debug.class}"/>
- </target>
- <target name="-debug-start-debuggee" depends="init,compile">
- <j2seproject3:debug>
- <customize>
- <arg line="${application.args}"/>
- </customize>
- </j2seproject3:debug>
- </target>
- <target name="debug" if="netbeans.home" depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE."/>
- <target name="-debug-start-debugger-stepinto" if="netbeans.home" depends="init">
- <j2seproject1:nbjpdastart stopclassname="${main.class}"/>
- </target>
- <target name="debug-stepinto" if="netbeans.home" depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee"/>
- <target name="-debug-start-debuggee-single" if="netbeans.home" depends="init,compile-single">
- <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail>
- <j2seproject3:debug classname="${debug.class}"/>
- </target>
- <target name="debug-single" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single"/>
- <target name="-pre-debug-fix" depends="init">
- <fail unless="fix.includes">Must set fix.includes</fail>
- <property name="javac.includes" value="${fix.includes}.java"/>
- </target>
- <target name="-do-debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,compile-single">
- <j2seproject1:nbjpdareload/>
- </target>
- <target name="debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix"/>
- <!--
- ===============
- JAVADOC SECTION
- ===============
- -->
- <target name="-javadoc-build" depends="init">
- <mkdir dir="${dist.javadoc.dir}"/>
- <javadoc destdir="${dist.javadoc.dir}" source="${javac.source}" notree="${javadoc.notree}" use="${javadoc.use}" nonavbar="${javadoc.nonavbar}" noindex="${javadoc.noindex}" splitindex="${javadoc.splitindex}" author="${javadoc.author}" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}" private="${javadoc.private}" additionalparam="${javadoc.additionalparam}" failonerror="true" useexternalfile="true" executable="${platform.javadoc}">
- <classpath>
- <path path="${javac.classpath}"/>
- </classpath>
- <sourcepath>
- <pathelement location="${src.dir}"/>
- </sourcepath>
- <packageset dir="${src.dir}" includes="*/**"/>
- <fileset dir="${src.dir}" includes="*.java"/>
- </javadoc>
- </target>
- <target name="-javadoc-browse" if="netbeans.home" unless="no.javadoc.preview" depends="init,-javadoc-build">
- <nbbrowse file="${dist.javadoc.dir}/index.html"/>
- </target>
- <target name="javadoc" depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc."/>
- <!--
- =========================
- JUNIT COMPILATION SECTION
- =========================
- -->
- <target name="-pre-pre-compile-test" if="have.tests" depends="init,compile">
- <mkdir dir="${build.test.classes.dir}"/>
- </target>
- <target name="-pre-compile-test">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target name="-do-compile-test" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test">
- <j2seproject3:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}"/>
- <copy todir="${build.test.classes.dir}">
- <fileset dir="${test.src.dir}" excludes="**/*.java"/>
- </copy>
- </target>
- <target name="-post-compile-test">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target name="compile-test" depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test"/>
- <target name="-pre-compile-test-single">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target name="-do-compile-test-single" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single">
- <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
- <j2seproject3:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}">
- <customize>
- <patternset includes="${javac.includes}"/>
- </customize>
- </j2seproject3:javac>
- <copy todir="${build.test.classes.dir}">
- <fileset dir="${test.src.dir}" excludes="**/*.java"/>
- </copy>
- </target>
- <target name="-post-compile-test-single">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target name="compile-test-single" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single"/>
- <!--
- =======================
- JUNIT EXECUTION SECTION
- =======================
- -->
- <target name="-pre-test-run" if="have.tests" depends="init">
- <mkdir dir="${build.test.results.dir}"/>
- </target>
- <target name="-do-test-run" if="have.tests" depends="init,compile-test,-pre-test-run">
- <j2seproject3:junit/>
- </target>
- <target name="-post-test-run" if="have.tests" depends="init,compile-test,-pre-test-run,-do-test-run">
- <fail if="tests.failed">Some tests failed; see details above.</fail>
- </target>
- <target name="test-report" if="have.tests" depends="init"/>
- <target name="-test-browse" if="netbeans.home+have.tests" depends="init"/>
- <target name="test" depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests."/>
- <target name="-pre-test-run-single" if="have.tests" depends="init">
- <mkdir dir="${build.test.results.dir}"/>
- </target>
- <target name="-do-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single">
- <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail>
- <j2seproject3:junit includes="${test.includes}"/>
- </target>
- <target name="-post-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single">
- <fail if="tests.failed">Some tests failed; see details above.</fail>
- </target>
- <target name="test-single" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test."/>
- <!--
- =======================
- JUNIT DEBUGGING SECTION
- =======================
- -->
- <target name="-debug-start-debuggee-test" if="have.tests" depends="init,compile-test">
- <fail unless="test.class">Must select one file in the IDE or set test.class</fail>
- <j2seproject3:debug classname="junit.textui.TestRunner" classpath="${debug.test.classpath}">
- <customize>
- <arg line="${test.class}"/>
- </customize>
- </j2seproject3:debug>
- </target>
- <target name="-debug-start-debugger-test" if="netbeans.home+have.tests" depends="init,compile-test">
- <j2seproject1:nbjpdastart name="${test.class}" classpath="${debug.test.classpath}"/>
- </target>
- <target name="debug-test" depends="init,compile-test,-debug-start-debugger-test,-debug-start-debuggee-test"/>
- <target name="-do-debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,compile-test-single">
- <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/>
- </target>
- <target name="debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix-test"/>
- <!--
- =========================
- APPLET EXECUTION SECTION
- =========================
- -->
- <target name="run-applet" depends="init,compile-single">
- <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
- <j2seproject1:java classname="sun.applet.AppletViewer">
- <customize>
- <arg value="${applet.url}"/>
- </customize>
- </j2seproject1:java>
- </target>
- <!--
- =========================
- APPLET DEBUGGING SECTION
- =========================
- -->
- <target name="-debug-start-debuggee-applet" if="netbeans.home" depends="init,compile-single">
- <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail>
- <j2seproject3:debug classname="sun.applet.AppletViewer">
- <customize>
- <arg value="${applet.url}"/>
- </customize>
- </j2seproject3:debug>
- </target>
- <target name="debug-applet" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet"/>
- <!--
- ===============
- CLEANUP SECTION
- ===============
- -->
- <target name="deps-clean" depends="init" unless="no.deps"/>
- <target name="-do-clean" depends="init">
- <delete dir="${build.dir}"/>
- <delete dir="${dist.dir}"/>
- </target>
- <target name="-post-clean">
- <!-- Empty placeholder for easier customization. -->
- <!-- You can override this target in the ../build.xml file. -->
- </target>
- <target name="clean" depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products."/>
-</project>
+++ /dev/null
-build.xml.data.CRC32=c78116b6
-build.xml.script.CRC32=8ea032a3
-build.xml.stylesheet.CRC32=d5b6853a
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=c78116b6
-nbproject/build-impl.xml.script.CRC32=2dc94bec
-nbproject/build-impl.xml.stylesheet.CRC32=99b91518
+++ /dev/null
-application.args=
-build.classes.dir=${build.dir}/classes
-build.classes.excludes=**/*.java,**/*.form
-# This directory is removed when the project is cleaned:
-build.dir=build
-build.generated.dir=${build.dir}/generated
-# Only compile against the classpath explicitly listed here:
-build.sysclasspath=ignore
-build.test.classes.dir=${build.dir}/test/classes
-build.test.results.dir=${build.dir}/test/results
-debug.classpath=\
- ${run.classpath}
-debug.test.classpath=\
- ${run.test.classpath}
-# This directory is removed when the project is cleaned:
-dist.dir=dist
-dist.jar=${dist.dir}/xalan2.jar
-dist.javadoc.dir=${dist.dir}/javadoc
-file.reference.xalan.jar=../../../../../usr/local/java/xalan-j_2_5_1/bin/xalan.jar
-jar.compress=false
-javac.classpath=\
- ${file.reference.xalan.jar}
-# Space-separated list of extra javac options
-javac.compilerargs=
-javac.deprecation=false
-javac.source=1.4
-javac.target=1.4
-javac.test.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}:\
- ${libs.junit.classpath}
-javadoc.additionalparam=
-javadoc.author=false
-javadoc.encoding=
-javadoc.noindex=false
-javadoc.nonavbar=false
-javadoc.notree=false
-javadoc.private=false
-javadoc.splitindex=true
-javadoc.use=true
-javadoc.version=false
-javadoc.windowtitle=
-meta.inf.dir=${src.dir}/META-INF
-platform.active=Java_HotSpot_TM__Client_VM_1.4.2_11-b06
-run.classpath=\
- ${javac.classpath}:\
- ${build.classes.dir}
-# Space-separated list of JVM arguments used when running the project
-# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
-# or test-sys-prop.name=value to set system properties for unit tests):
-run.jvmargs=
-run.test.classpath=\
- ${javac.test.classpath}:\
- ${build.test.classes.dir}
-src.dir=src
-test.src.dir=test
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://www.netbeans.org/ns/project/1">
- <type>org.netbeans.modules.java.j2seproject</type>
- <configuration>
- <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
- <name>xalan2</name>
- <minimum-ant-version>1.6.5</minimum-ant-version>
- <explicit-platform explicit-source-supported="true"/>
- <source-roots>
- <root id="src.dir"/>
- </source-roots>
- <test-roots>
- <root id="test.src.dir"/>
- </test-roots>
- </data>
- </configuration>
-</project>
+++ /dev/null
-package com.nwalsh.xalan;
-
-import java.io.*;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.Date;
-import java.util.Locale;
-import java.util.TimeZone;
-import java.text.DateFormat;
-import java.text.ParseException;
-
-/**
- * <p>Xalan extension to convert CVS date strings into local time</p>
- *
- * <p>$Id$</p>
- *
- * <p>Copyright (C) 2000 Norman Walsh.</p>
- *
- * <p>This class provides a
- * <a href="http://xml.apache.org/xalan-j/">Xalan</a>
- * extension to turn the CVS date strings, which are UTC:</p>
- *
- * <pre>$Date: 2000/11/09 02:34:20 $</pre>
- *
- * <p>into legibly formatted local time:</p>
- *
- * <pre>Wed Nov 08 18:34:20 PST 2000</pre>
- *
- * <p>(I happened to be in California when I wrote this documentation.)</p>
-
- * <p><b>Change Log:</b></p>
- * <dl>
- * <dt>1.0</dt>
- * <dd><p>Initial release.</p></dd>
- * </dl>
- *
- * @author Norman Walsh
- * <a href="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a>
- *
- * @version $Id$
- *
- */
-public class CVS {
- /**
- * <p>Constructor for CVS</p>
- *
- * <p>All of the methods are static, so the constructor does nothing.</p>
- */
- public CVS() {
- }
-
- /**
- * <p>Convert a CVS date string into local time.</p>
- *
- * @param cvsDate The CVS date string.
- *
- * @return The date, converted to local time and reformatted.
- */
- public String localTime (String cvsDate) {
- // A cvsDate has the following form "$Date$"
- if (!cvsDate.startsWith("$Date: ")) {
- return cvsDate;
- }
-
- String yrS = cvsDate.substring(7,11);
- String moS = cvsDate.substring(12,14);
- String daS = cvsDate.substring(15,17);
- String hrS = cvsDate.substring(18,20);
- String miS = cvsDate.substring(21,23);
- String seS = cvsDate.substring(24,26);
-
- TimeZone tz = TimeZone.getTimeZone("GMT+0");
- GregorianCalendar gmtCal = new GregorianCalendar(tz);
-
- try {
- gmtCal.set(Integer.parseInt(yrS),
- Integer.parseInt(moS)-1,
- Integer.parseInt(daS),
- Integer.parseInt(hrS),
- Integer.parseInt(miS),
- Integer.parseInt(seS));
- } catch (NumberFormatException e) {
- // nop
- }
-
- Date d = gmtCal.getTime();
-
- return d.toString();
- }
-}
+++ /dev/null
-package com.nwalsh.xalan;
-
-import org.w3c.dom.*;
-
-/**
- * <p>Utility class for the Verbatim extension (ignore this).</p>
- *
- * <p>$Id$</p>
- *
- * <p>Copyright (C) 2000 Norman Walsh.</p>
- *
- * <p>This class is just for book keeping in the Verbatim class.
- * It stores information about the location of callouts.</p>
- *
- * <p>Only line/column based callouts are supported. This class
- * implements the Comparable interface so that callouts can be sorted.
- * Callouts are sorted so that they occur in left-to-right,
- * top-to-bottom order based on line/column.</p>
- *
- * <p><b>Change Log:</b></p>
- * <dl>
- * <dt>1.0</dt>
- * <dd><p>Initial release.</p></dd>
- * </dl>
- *
- * @author Norman Walsh
- * <a href="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a>
- *
- * @see Verbatim
- *
- * @version $Id$
- * */
-public class Callout implements Comparable {
- /** The callout number. */
- private int callout = 0;
- /** The area Element item that generated this callout. */
- private Element area = null;
- /** The line on which this callout occurs. */
- private int line = 0;
- /** The column in which this callout appears. */
- private int col = 0;
- /** The type of callout. */
- private int type = 0;
- /** The other type of callout. */
- private String otherType = null;
-
- public static final int CALS_PAIR = 1;
- public static final int LINE_COLUMN = 2;
- public static final int LINE_COLUMN_PAIR = 3;
- public static final int LINE_RANGE = 4;
- public static final int OTHER = 5;
-
- /** The constructor; initialize the private data structures. */
- public Callout(int callout, Element area, int line, int col, int type) {
- this.callout = callout;
- this.area = area;
- this.line = line;
- this.col = col;
- this.type = type;
- this.otherType = null;
- }
-
- /** The constructor; initialize the private data structures. */
- public Callout(int callout, Element area, int line, int col, String otherType) {
- this.callout = callout;
- this.area = area;
- this.line = line;
- this.col = col;
- this.type = Callout.OTHER;
- this.otherType = otherType;
- }
-
- /**
- * <p>The compareTo method compares this Callout with another.</p>
- *
- * <p>Given two Callouts, A and B, A < B if:</p>
- *
- * <ol>
- * <li>A.line < B.line, or</li>
- * <li>A.line = B.line && A.col < B.col, or</li>
- * <li>A.line = B.line && A.col = B.col && A.callout < B.callout</li>
- * <li>Otherwise, they're equal.</li>
- * </ol>
- */
- public int compareTo (Object o) {
- Callout c = (Callout) o;
-
- if (line == c.getLine()) {
- if (col > c.getColumn()) {
- return 1;
- } else if (col < c.getColumn()) {
- return -1;
- } else {
- if (callout < c.getCallout()) {
- return -1;
- } else if (callout > c.getCallout()) {
- return 1;
- } else {
- return 0;
- }
- }
- } else {
- if (line > c.getLine()) {
- return 1;
- } else {
- return -1;
- }
- }
- }
-
- /** Access the Callout's area. */
- public Element getArea() {
- return area;
- }
-
- /** Access the Callout's line. */
- public int getLine() {
- return line;
- }
-
- /** Access the Callout's column. */
- public int getColumn() {
- return col;
- }
-
- /** Access the Callout's callout number. */
- public int getCallout() {
- return callout;
- }
-
- /** Access the Callout's type. */
- public int getType() {
- return type;
- }
-
- /** Access the Callout's otherType. */
- public String getOtherType() {
- return otherType;
- }
-
-
-}
-
+++ /dev/null
-package com.nwalsh.xalan;
-
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-import org.w3c.dom.*;
-import org.apache.xml.utils.DOMBuilder;
-import com.nwalsh.xalan.Callout;
-
-/**
- * <p>Utility class for the Verbatim extension (ignore this).</p>
- *
- * <p>$Id$</p>
- *
- * <p>Copyright (C) 2000, 2001 Norman Walsh.</p>
- *
- * <p><b>Change Log:</b></p>
- * <dl>
- * <dt>1.0</dt>
- * <dd><p>Initial release.</p></dd>
- * </dl>
- *
- * @author Norman Walsh
- * <a href="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a>
- *
- * @see Verbatim
- *
- * @version $Id$
- **/
-
-public abstract class FormatCallout {
- protected static final String foURI = "http://www.w3.org/1999/XSL/Format";
- protected static final String xhURI = "http://www.w3.org/1999/xhtml";
- protected boolean stylesheetFO = false;
-
- public FormatCallout() {
- //nop;
- }
-
- public String areaLabel(Element area) {
- String label = null;
-
- if (area.getAttribute("label") != null) {
- // If this area has a label, use it
- label = area.getAttribute("label");
- } else {
- // Otherwise, if its parent is an areaset and it has a label, use that
- Element parent = (Element) area.getParentNode();
- if (parent != null
- && parent.getNodeName().equals("areaset")
- && parent.getAttribute("label") != null) {
- label = parent.getAttribute("label");
- }
- }
-
- return label;
- }
-
- public void startSpan(DOMBuilder rtf)
- throws SAXException {
- // no point in doing this for FO, right?
- if (!stylesheetFO) {
- AttributesImpl spanAttr = new AttributesImpl();
- spanAttr.addAttribute("", "class", "class", "CDATA", "co");
- rtf.startElement("", "span", "span", spanAttr);
- }
- }
-
- public void endSpan(DOMBuilder rtf)
- throws SAXException {
- // no point in doing this for FO, right?
- if (!stylesheetFO) {
- rtf.endElement("", "span", "span");
- }
- }
-
- public void formatTextCallout(DOMBuilder rtf,
- Callout callout) {
- Element area = callout.getArea();
- int num = callout.getCallout();
- String userLabel = areaLabel(area);
- String label = "(" + num + ")";
-
- if (userLabel != null) {
- label = userLabel;
- }
-
- char chars[] = label.toCharArray();
-
- try {
- startSpan(rtf);
- rtf.characters(chars, 0, label.length());
- endSpan(rtf);
- } catch (SAXException e) {
- System.out.println("SAX Exception in text formatCallout");
- }
- }
-
- public abstract void formatCallout(DOMBuilder rtf,
- Callout callout);
-}
-
+++ /dev/null
-package com.nwalsh.xalan;
-
-import org.xml.sax.helpers.AttributesImpl;
-import org.xml.sax.SAXException;
-import org.w3c.dom.*;
-import org.apache.xml.utils.DOMBuilder;
-import com.nwalsh.xalan.Callout;
-import org.apache.xml.utils.AttList;
-
-/**
- * <p>Utility class for the Verbatim extension (ignore this).</p>
- *
- * <p>$Id$</p>
- *
- * <p>Copyright (C) 2000, 2001 Norman Walsh.</p>
- *
- * <p><b>Change Log:</b></p>
- * <dl>
- * <dt>1.0</dt>
- * <dd><p>Initial release.</p></dd>
- * </dl>
- *
- * @author Norman Walsh
- * <a href="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a>
- *
- * @see Verbatim
- *
- * @version $Id$
- **/
-
-public class FormatDingbatCallout extends FormatCallout {
- int graphicsMax = 0;
-
- public FormatDingbatCallout(int max, boolean fo) {
- graphicsMax = max;
- stylesheetFO = fo;
- }
-
- public void formatCallout(DOMBuilder rtf,
- Callout callout) {
- Element area = callout.getArea();
- int num = callout.getCallout();
- String label = areaLabel(area);
-
- try {
- if (label == null && num <= graphicsMax) {
- AttributesImpl imgAttr = new AttributesImpl();
- String ns = "";
- String prefix = "";
- String imgName = "";
-
- if (stylesheetFO) {
- ns = foURI;
- prefix = "fo:"; // FIXME: this could be a problem...
- imgName = "inline";
- imgAttr.addAttribute("", "font-family", "font-family", "CDATA",
- "ZapfDingbats");
- } else {
- ns = "";
- prefix = "";
- imgName = "font";
- imgAttr.addAttribute("", "face", "face", "CDATA",
- "ZapfDingbats");
- }
-
- startSpan(rtf);
- rtf.startElement(ns, imgName, prefix+imgName, imgAttr);
-
- char chars[] = new char[1];
- chars[0] = (char) (0x2775 + num);
- rtf.characters(chars, 0, 1);
-
- rtf.endElement(ns, imgName, prefix+imgName);
- endSpan(rtf);
- } else {
- formatTextCallout(rtf, callout);
- }
- } catch (SAXException e) {
- System.out.println("SAX Exception in graphics formatCallout");
- }
- }
-}
+++ /dev/null
-package com.nwalsh.xalan;
-
-import org.xml.sax.helpers.AttributesImpl;
-import org.xml.sax.SAXException;
-import org.w3c.dom.*;
-import org.apache.xml.utils.DOMBuilder;
-import com.nwalsh.xalan.Callout;
-import org.apache.xml.utils.AttList;
-
-/**
- * <p>Utility class for the Verbatim extension (ignore this).</p>
- *
- * <p>$Id$</p>
- *
- * <p>Copyright (C) 2000, 2001 Norman Walsh.</p>
- *
- * <p><b>Change Log:</b></p>
- * <dl>
- * <dt>1.0</dt>
- * <dd><p>Initial release.</p></dd>
- * </dl>
- *
- * @author Norman Walsh
- * <a href="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a>
- *
- * @see Verbatim
- *
- * @version $Id$
- **/
-
-public class FormatGraphicCallout extends FormatCallout {
- String graphicsPath = "";
- String graphicsExt = "";
- int graphicsMax = 0;
-
- public FormatGraphicCallout(String path, String ext, int max, boolean fo) {
- graphicsPath = path;
- graphicsExt = ext;
- graphicsMax = max;
- stylesheetFO = fo;
- }
-
- public void formatCallout(DOMBuilder rtf,
- Callout callout) {
- Element area = callout.getArea();
- int num = callout.getCallout();
- String label = areaLabel(area);
-
- try {
- if (label == null && num <= graphicsMax) {
- AttributesImpl imgAttr = new AttributesImpl();
- String ns = "";
- String prefix = "";
- String imgName = "";
-
- if (stylesheetFO) {
- ns = foURI;
- prefix = "fo:"; // FIXME: this could be a problem...
- imgName = "external-graphic";
- imgAttr.addAttribute("", "src", "src", "CDATA", "url(" +
- graphicsPath + num + graphicsExt + ")");
-
- } else {
- ns = "";
- prefix = "";
- imgName = "img";
- imgAttr.addAttribute("", "src", "src", "CDATA",
- graphicsPath + num + graphicsExt);
- imgAttr.addAttribute("", "alt", "alt", "CDATA", label);
- }
-
- startSpan(rtf);
- rtf.startElement(ns, imgName, prefix+imgName, imgAttr);
- rtf.endElement(ns, imgName, prefix+imgName);
- endSpan(rtf);
- } else {
- formatTextCallout(rtf, callout);
- }
- } catch (SAXException e) {
- System.out.println("SAX Exception in graphics formatCallout");
- }
- }
-}
+++ /dev/null
-package com.nwalsh.xalan;
-
-import org.w3c.dom.*;
-import org.apache.xml.utils.DOMBuilder;
-import com.nwalsh.xalan.Callout;
-import org.apache.xml.utils.AttList;
-
-/**
- * <p>Utility class for the Verbatim extension (ignore this).</p>
- *
- * <p>$Id$</p>
- *
- * <p>Copyright (C) 2000, 2001 Norman Walsh.</p>
- *
- * <p><b>Change Log:</b></p>
- * <dl>
- * <dt>1.0</dt>
- * <dd><p>Initial release.</p></dd>
- * </dl>
- *
- * @author Norman Walsh
- * <a href="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a>
- *
- * @see Verbatim
- *
- * @version $Id$
- **/
-
-public class FormatTextCallout extends FormatCallout {
- public FormatTextCallout(boolean fo) {
- stylesheetFO = fo;
- }
-
- public void formatCallout(DOMBuilder rtf,
- Callout callout) {
- formatTextCallout(rtf, callout);
- }
-}
+++ /dev/null
-package com.nwalsh.xalan;
-
-import org.xml.sax.helpers.AttributesImpl;
-import org.xml.sax.SAXException;
-import org.w3c.dom.*;
-import org.apache.xml.utils.DOMBuilder;
-import com.nwalsh.xalan.Callout;
-import org.apache.xml.utils.AttList;
-
-/**
- * <p>Utility class for the Verbatim extension (ignore this).</p>
- *
- * <p>$Id$</p>
- *
- * <p>Copyright (C) 2000, 2001 Norman Walsh.</p>
- *
- * <p><b>Change Log:</b></p>
- * <dl>
- * <dt>1.0</dt>
- * <dd><p>Initial release.</p></dd>
- * </dl>
- *
- * @author Norman Walsh
- * <a href="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a>
- *
- * @see Verbatim
- *
- * @version $Id$
- **/
-
-public class FormatUnicodeCallout extends FormatCallout {
- int unicodeMax = 0;
- int unicodeStart = 0;
- String unicodeFont = "";
-
- public FormatUnicodeCallout(String font, int start, int max, boolean fo) {
- unicodeFont = font;
- unicodeMax = max;
- unicodeStart = start;
- stylesheetFO = fo;
- }
-
- public void formatCallout(DOMBuilder rtf,
- Callout callout) {
- Element area = callout.getArea();
- int num = callout.getCallout();
- String label = areaLabel(area);
-
- try {
- if (label == null && num <= unicodeMax) {
- AttributesImpl inAttr = new AttributesImpl();
- String ns = "";
- String prefix = "";
- String inName = "";
-
- if (!unicodeFont.equals("")) {
- if (stylesheetFO) {
- ns = foURI;
- prefix = "fo:";
- inName = "inline";
- inAttr.addAttribute("", "", "font-family", "CDATA", unicodeFont);
- } else {
- inName = "font";
- inAttr.addAttribute("", "", "face", "CDATA", unicodeFont);
- }
- }
-
- char chars[] = new char[1];
- chars[0] = (char) (unicodeStart + num - 1);
-
- startSpan(rtf);
- if (!unicodeFont.equals("")) {
- rtf.startElement(ns, inName, prefix+inName, inAttr);
- }
- rtf.characters(chars, 0, 1);
- if (!unicodeFont.equals("")) {
- rtf.endElement(ns, inName, prefix+inName);
- }
- endSpan(rtf);
- } else {
- formatTextCallout(rtf, callout);
- }
- } catch (SAXException e) {
- System.out.println("SAX Exception in unicode formatCallout");
- }
- }
-}
+++ /dev/null
-// Func - Xalann extension function test
-
-package com.nwalsh.xalan;
-
-import org.xml.sax.SAXException;
-import org.xml.sax.AttributeList;
-import org.xml.sax.ContentHandler;
-
-import org.w3c.dom.*;
-import org.w3c.dom.traversal.NodeIterator;
-
-import org.apache.xpath.objects.XObject;
-import org.apache.xpath.objects.XRTreeFrag;
-import org.apache.xpath.XPath;
-import org.apache.xpath.NodeSet;
-import org.apache.xalan.extensions.XSLProcessorContext;
-import org.apache.xalan.extensions.ExpressionContext;
-import org.apache.xalan.transformer.TransformerImpl;
-import org.apache.xalan.templates.StylesheetRoot;
-import org.apache.xalan.templates.ElemExtensionCall;
-import org.apache.xalan.templates.OutputProperties;
-import org.apache.xalan.res.XSLTErrorResources;
-
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.TransformerException;
-
-public class Func {
- public Func() {
- }
-
- public DocumentFragment doSomething(NodeIterator rtf) {
- System.out.println("Got here 2: " + rtf);
-
- DocumentFragment df = (DocumentFragment) rtf.nextNode();
- Element node = (Element) df.getFirstChild();
-
- System.out.println("node=" + node);
- System.out.println("namesp uri: " + node.getNamespaceURI());
- System.out.println("local name: " + node.getLocalName());
-
- return df;
- }
-
- public DocumentFragment doSomething(DocumentFragment rtf) {
- System.out.println("Got here: " + rtf);
-
- return rtf;
- /*
- Element node = (Element) rtf.getFirstChild();
-
- System.out.println("node=" + node);
- System.out.println("namesp uri: " + node.getNamespaceURI());
- System.out.println("local name: " + node.getLocalName());
-
- return rtf;
- */
- }
-}
+++ /dev/null
-package com.nwalsh.xalan;
-
-import java.io.*;
-import java.awt.*;
-import java.awt.image.*;
-import java.lang.Thread;
-import java.util.StringTokenizer;
-
-import org.apache.xalan.extensions.ExpressionContext;
-
-/**
- * <p>Xalan extension to examine intrinsic size of images</p>
- *
- * <p>$Id$</p>
- *
- * <p>Copyright (C) 2002 Norman Walsh.</p>
- *
- * <p>This class provides a
- * <a href="http://xml.apache.org/xalan-j/">Xalan</a>
- * extension to find the intrinsic size of images.</p>
- *
- * <p><b>Change Log:</b></p>
- * <dl>
- * <dt>1.0</dt>
- * <dd><p>Initial release.</p></dd>
- * </dl>
- *
- * @author Norman Walsh
- * <a href="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a>
- *
- * @version $Id$
- *
- */
-public class ImageIntrinsics implements ImageObserver {
- boolean imageLoaded = false;
- boolean imageFailed = false;
- Image image = null;
- int width = -1;
- int depth = -1;
-
- /**
- * <p>Constructor for ImageIntrinsics</p>
- */
- public ImageIntrinsics(ExpressionContext context, String imageFn) {
- System.setProperty("java.awt.headless","true");
- image = Toolkit.getDefaultToolkit().getImage (imageFn);
- width = image.getWidth(this);
-
- while (!imageFailed && (width == -1 || depth == -1)) {
- try {
- java.lang.Thread.currentThread().sleep(50);
- } catch (Exception e) {
- // nop;
- }
- width = image.getWidth(this);
- depth = image.getHeight(this);
- }
-
- if (imageFailed) {
- // Maybe it's an EPS or PDF?
- // FIXME: this code is crude
- BufferedReader ir = null;
- String line = null;
- int lineLimit = 100;
-
- try {
- ir = new BufferedReader(new FileReader(new File(imageFn)));
- line = ir.readLine();
-
- if (line != null && line.startsWith("%PDF-")) {
- // We've got a PDF!
- while (lineLimit > 0 && line != null) {
- lineLimit--;
- if (line.startsWith("/CropBox [")) {
- line = line.substring(10);
- if (line.indexOf("]") >= 0) {
- line = line.substring(0, line.indexOf("]"));
- }
- parseBox(line);
- lineLimit = 0;
- }
- line = ir.readLine();
- }
- } else if (line != null && line.startsWith("%!") && line.indexOf(" EPSF-") > 0) {
- // We've got an EPS!
- while (lineLimit > 0 && line != null) {
- lineLimit--;
- if (line.startsWith("%%BoundingBox: ")) {
- line = line.substring(15);
- parseBox(line);
- lineLimit = 0;
- }
- line = ir.readLine();
- }
- }
- } catch (Exception e) {
- // nop;
- }
-
- if (ir != null) {
- try {
- ir.close();
- } catch (Exception e) {
- // nop;
- }
- }
- }
- }
-
- public int getWidth(ExpressionContext context, int defaultWidth) {
- if (width >= 0) {
- return width;
- } else {
- return defaultWidth;
- }
- }
-
- public int getDepth(ExpressionContext context, int defaultDepth) {
- if (depth >= 0) {
- return depth;
- } else {
- return defaultDepth;
- }
- }
-
- private void parseBox(String line) {
- int [] corners = new int [4];
- int count = 0;
-
- StringTokenizer st = new StringTokenizer(line);
- while (count < 4 && st.hasMoreTokens()) {
- try {
- corners[count++] = Integer.parseInt(st.nextToken());
- } catch (Exception e) {
- // nop;
- }
- }
-
- width = corners[2] - corners[0];
- depth = corners[3] - corners[1];
- }
-
- public boolean imageUpdate(Image img, int infoflags,
- int x, int y, int width, int height) {
- if ((infoflags & ImageObserver.ERROR) == ImageObserver.ERROR) {
- imageFailed = true;
- return false;
- }
-
- // I really only care about the width and height, but if I return false as
- // soon as those are available, the BufferedInputStream behind the loader
- // gets closed too early.
- int flags = ImageObserver.ALLBITS;
- if ((infoflags & flags) == flags) {
- return false;
- } else {
- return true;
- }
- }
-}
+++ /dev/null
-// Params.java - Read stylesheet parameters in Xalan
-
-package com.nwalsh.xalan;
-
-import org.apache.xpath.objects.XObject;
-import org.apache.xpath.XPathContext;
-import org.apache.xalan.extensions.ExpressionContext;
-import org.apache.xml.utils.QName;
-
-import javax.xml.transform.TransformerException;
-
-public class Params {
-
- public static String getString(ExpressionContext context,
- String varName) {
- try {
- XObject var = context.getVariableOrParam(new QName(varName));
- if (var != null) {
- return var.toString();
- } else {
- System.out.println("$" + varName + " is not a defined parameter.");
- return "";
- }
- } catch (TransformerException te) {
- // Nevermind the warning
- // System.out.println("Transformer exception getting value of $" + varName);
- return "";
- }
- }
-
- public static int getInt(ExpressionContext context,
- String varName) {
- String stringValue = getString(context, varName);
- if (stringValue != null) {
- try {
- int value = Integer.parseInt(stringValue);
- return value;
- } catch (NumberFormatException e) {
- System.out.println("$" + varName + " is not an integer.");
- }
- }
- return 0;
- }
-
- public static boolean getBoolean(ExpressionContext context,
- String varName) {
- String stringValue = getString(context, varName);
- if (stringValue != null) {
- if (stringValue.equals("0") || stringValue.equals("")) {
- return false;
- } else {
- return true;
- }
- } else {
- return false;
- }
- }
-}
+++ /dev/null
-// Verbatim.java - Xalan extensions supporting DocBook verbatim environments
-
-package com.nwalsh.xalan;
-
-import java.util.Hashtable;
-import org.xml.sax.*;
-import org.xml.sax.helpers.AttributesImpl;
-import org.w3c.dom.*;
-import org.w3c.dom.traversal.NodeIterator;
-
-import javax.xml.transform.TransformerException;
-
-import org.apache.xpath.objects.XObject;
-import org.apache.xpath.XPathContext;
-import org.apache.xalan.extensions.ExpressionContext;
-import org.apache.xml.utils.DOMBuilder;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import org.apache.xml.utils.QName;
-import org.apache.xml.utils.AttList;
-
-/**
- * <p>Xalan extensions supporting Tables</p>
- *
- * <p>$Id$</p>
- *
- * <p>Copyright (C) 2000 Norman Walsh.</p>
- *
- * <p>This class provides a
- * <a href="http://xml.apache.org/xalan-j/">Xalan</a>
- * implementation of some code to adjust CALS Tables to HTML
- * Tables.</p>
- *
- * <p><b>Column Widths</b></p>
- * <p>The <tt>adjustColumnWidths</tt> method takes a result tree
- * fragment (assumed to contain the colgroup of an HTML Table)
- * and returns the result tree fragment with the column widths
- * adjusted to HTML terms.</p>
- *
- * <p><b>Convert Lengths</b></p>
- * <p>The <tt>convertLength</tt> method takes a length specification
- * of the form 9999.99xx (where "xx" is a unit) and returns that length
- * as an integral number of pixels. For convenience, percentage lengths
- * are returned unchanged.</p>
- * <p>The recognized units are: inches (in), centimeters (cm),
- * millimeters (mm), picas (pc, 1pc=12pt), points (pt), and pixels (px).
- * A number with no units is assumed to be pixels.</p>
- *
- * <p><b>Change Log:</b></p>
- * <dl>
- * <dt>1.0</dt>
- * <dd><p>Initial release.</p></dd>
- * </dl>
- *
- * @author Norman Walsh
- * <a href="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a>
- *
- * @version $Id$
- *
- */
-public class Table {
- /** The number of pixels per inch */
- private static int pixelsPerInch = 96;
-
- /** The hash used to associate units with a length in pixels. */
- protected static Hashtable unitHash = null;
-
- /** The FO namespace name. */
- protected static String foURI = "http://www.w3.org/1999/XSL/Format";
-
- /**
- * <p>Constructor for Verbatim</p>
- *
- * <p>All of the methods are static, so the constructor does nothing.</p>
- */
- public Table() {
- }
-
- /** Initialize the internal hash table with proper values. */
- protected static void initializeHash() {
- unitHash = new Hashtable();
- unitHash.put("in", new Float(pixelsPerInch));
- unitHash.put("cm", new Float(pixelsPerInch / 2.54));
- unitHash.put("mm", new Float(pixelsPerInch / 25.4));
- unitHash.put("pc", new Float((pixelsPerInch / 72) * 12));
- unitHash.put("pt", new Float(pixelsPerInch / 72));
- unitHash.put("px", new Float(1));
- }
-
- /** Set the pixels-per-inch value. Only positive values are legal. */
- public static void setPixelsPerInch(int value) {
- if (value > 0) {
- pixelsPerInch = value;
- initializeHash();
- }
- }
-
- /** Return the current pixels-per-inch value. */
- public int getPixelsPerInch() {
- return pixelsPerInch;
- }
-
- /**
- * <p>Convert a length specification to a number of pixels.</p>
- *
- * <p>The specified length should be of the form [+/-]999.99xx,
- * where xx is a valid unit.</p>
- */
- public static int convertLength(String length) {
- // The format of length should be 999.999xx
- int sign = 1;
- String digits = "";
- String units = "";
- char lench[] = length.toCharArray();
- float flength = 0;
- boolean done = false;
- int pos = 0;
- float factor = 1;
- int pixels = 0;
-
- if (unitHash == null) {
- initializeHash();
- }
-
- if (lench[pos] == '+' || lench[pos] == '-') {
- if (lench[pos] == '-') {
- sign = -1;
- }
- pos++;
- }
-
- while (!done) {
- if (pos >= lench.length) {
- done = true;
- } else {
- if ((lench[pos] > '9' || lench[pos] < '0') && lench[pos] != '.') {
- done = true;
- units = length.substring(pos);
- } else {
- digits += lench[pos++];
- }
- }
- }
-
- try {
- flength = Float.parseFloat(digits);
- } catch (NumberFormatException e) {
- System.out.println(digits + " is not a number; 1 used instead.");
- flength = 1;
- }
-
- Float f = null;
-
- if (!units.equals("")) {
- f = (Float) unitHash.get(units);
- if (f == null) {
- System.out.println(units + " is not a known unit; 1 used instead.");
- factor = 1;
- } else {
- factor = f.floatValue();
- }
- } else {
- factor = 1;
- }
-
- f = new Float(flength * factor);
-
- pixels = f.intValue() * sign;
-
- return pixels;
- }
-
- /**
- * <p>Adjust column widths in an HTML table.</p>
- *
- * <p>The specification of column widths in CALS (a relative width
- * plus an optional absolute width) are incompatible with HTML column
- * widths. This method adjusts CALS column width specifiers in an
- * attempt to produce equivalent HTML specifiers.</p>
- *
- * <p>In order for this method to work, the CALS width specifications
- * should be placed in the "width" attribute of the <col>s within
- * a <colgroup>. Then the colgroup result tree fragment is passed
- * to this method.</p>
- *
- * <p>This method makes use of two parameters from the XSL stylesheet
- * that calls it: <code>nominal.table.width</code> and
- * <code>table.width</code>. The value of <code>nominal.table.width</code>
- * must be an absolute distance. The value of <code>table.width</code>
- * can be either absolute or relative.</p>
- *
- * <p>Presented with a mixture of relative and
- * absolute lengths, the table width is used to calculate
- * appropriate values. If the <code>table.width</code> is relative,
- * the nominal width is used for this calculation.</p>
- *
- * <p>There are three possible combinations of values:</p>
- *
- * <ol>
- * <li>There are no relative widths; in this case the absolute widths
- * are used in the HTML table.</li>
- * <li>There are no absolute widths; in this case the relative widths
- * are used in the HTML table.</li>
- * <li>There are a mixture of absolute and relative widths:
- * <ol>
- * <li>If the table width is absolute, all widths become absolute.</li>
- * <li>If the table width is relative, make all the widths absolute
- * relative to the nominal table width then turn them all
- * back into relative widths.</li>
- * </ol>
- * </li>
- * </ol>
- *
- * @param context The stylesheet context; supplied automatically by Xalan
- * @param xalanNI
- *
- * @return The result tree fragment containing the adjusted colgroup.
- *
- */
-
- public DocumentFragment adjustColumnWidths (ExpressionContext context,
- NodeIterator xalanNI) {
-
- int nominalWidth = convertLength(Params.getString(context,
- "nominal.table.width"));
- String tableWidth = Params.getString(context, "table.width");
- String styleType = Params.getString(context, "stylesheet.result.type");
- boolean foStylesheet = styleType.equals("fo");
-
- DocumentFragment xalanRTF = (DocumentFragment) xalanNI.nextNode();
- Element colgroup = (Element) xalanRTF.getFirstChild();
-
- // N.B. ...stree.ElementImpl doesn't implement getElementsByTagName()
-
- Node firstCol = null;
- // If this is an FO tree, there might be no colgroup...
- if (colgroup.getLocalName().equals("colgroup")) {
- firstCol = colgroup.getFirstChild();
- } else {
- firstCol = colgroup;
- }
-
- // Count the number of columns...
- Node child = firstCol;
- int numColumns = 0;
- while (child != null) {
- if (child.getNodeType() == Node.ELEMENT_NODE
- && (child.getNodeName().equals("col")
- || (child.getNamespaceURI().equals(foURI)
- && child.getLocalName().equals("table-column")))) {
- numColumns++;
- }
-
- child = child.getNextSibling();
- }
-
- String widths[] = new String[numColumns];
- Element columns[] = new Element[numColumns];
- int colnum = 0;
-
- child = firstCol;
- while (child != null) {
- if (child.getNodeType() == Node.ELEMENT_NODE
- && (child.getNodeName().equals("col")
- || (child.getNamespaceURI().equals(foURI)
- && child.getLocalName().equals("table-column")))) {
- Element col = (Element) child;
-
- columns[colnum] = col;
-
- if (foStylesheet) {
- if (col.getAttribute("column-width") == null) {
- widths[colnum] = "1*";
- } else {
- widths[colnum] = col.getAttribute("column-width");
- }
- } else {
- if (col.getAttribute("width") == null) {
- widths[colnum] = "1*";
- } else {
- widths[colnum] = col.getAttribute("width");
- }
- }
-
- colnum++;
- }
- child = child.getNextSibling();
- }
-
- float relTotal = 0;
- float relParts[] = new float[numColumns];
-
- float absTotal = 0;
- float absParts[] = new float[numColumns];
-
- for (int count = 0; count < numColumns; count++) {
- String width = widths[count];
- int pos = width.indexOf("*");
- if (pos >= 0) {
- String relPart = width.substring(0, pos);
- String absPart = width.substring(pos+1);
-
- try {
- float rel = Float.parseFloat(relPart);
- relTotal += rel;
- relParts[count] = rel;
- } catch (NumberFormatException e) {
- System.out.println(relPart + " is not a valid relative unit.");
- }
-
- int pixels = 0;
- if (absPart != null && !absPart.equals("")) {
- pixels = convertLength(absPart);
- }
-
- absTotal += pixels;
- absParts[count] = pixels;
- } else {
- relParts[count] = 0;
-
- int pixels = 0;
- if (width != null && !width.equals("")) {
- pixels = convertLength(width);
- }
-
- absTotal += pixels;
- absParts[count] = pixels;
- }
- }
-
- // Ok, now we have the relative widths and absolute widths in
- // two parallel arrays.
- //
- // - If there are no relative widths, output the absolute widths
- // - If there are no absolute widths, output the relative widths
- // - If there are a mixture of relative and absolute widths,
- // - If the table width is absolute, turn these all into absolute
- // widths.
- // - If the table width is relative, turn these all into absolute
- // widths in the nominalWidth and then turn them back into
- // percentages.
-
- if (relTotal == 0) {
- for (int count = 0; count < numColumns; count++) {
- Float f = new Float(absParts[count]);
- if (foStylesheet) {
- int pixels = f.intValue();
- float inches = (float) pixels / pixelsPerInch;
- widths[count] = inches + "in";
- } else {
- widths[count] = Integer.toString(f.intValue());
- }
- }
- } else if (absTotal == 0) {
- for (int count = 0; count < numColumns; count++) {
- float rel = relParts[count] / relTotal * 100;
- Float f = new Float(rel);
- widths[count] = Integer.toString(f.intValue());
- }
- widths = correctRoundingError(widths);
- } else {
- int pixelWidth = nominalWidth;
-
- if (tableWidth.indexOf("%") <= 0) {
- pixelWidth = convertLength(tableWidth);
- }
-
- if (pixelWidth <= absTotal) {
- System.out.println("Table is wider than table width.");
- } else {
- pixelWidth -= absTotal;
- }
-
- absTotal = 0;
- for (int count = 0; count < numColumns; count++) {
- float rel = relParts[count] / relTotal * pixelWidth;
- relParts[count] = rel + absParts[count];
- absTotal += rel + absParts[count];
- }
-
- if (tableWidth.indexOf("%") <= 0) {
- for (int count = 0; count < numColumns; count++) {
- Float f = new Float(relParts[count]);
- if (foStylesheet) {
- int pixels = f.intValue();
- float inches = (float) pixels / pixelsPerInch;
- widths[count] = inches + "in";
- } else {
- widths[count] = Integer.toString(f.intValue());
- }
- }
- } else {
- for (int count = 0; count < numColumns; count++) {
- float rel = relParts[count] / absTotal * 100;
- Float f = new Float(rel);
- widths[count] = Integer.toString(f.intValue());
- }
- widths = correctRoundingError(widths);
- }
- }
-
- // Now rebuild the colgroup with the right widths
-
- DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder docBuilder = null;
-
- try {
- docBuilder = docFactory.newDocumentBuilder();
- } catch (ParserConfigurationException e) {
- System.out.println("PCE!");
- return xalanRTF;
- }
- Document doc = docBuilder.newDocument();
- DocumentFragment df = doc.createDocumentFragment();
- DOMBuilder rtf = new DOMBuilder(doc, df);
-
- try {
- String ns = colgroup.getNamespaceURI();
- String localName = colgroup.getLocalName();
- String name = colgroup.getTagName();
-
- if (colgroup.getLocalName().equals("colgroup")) {
- rtf.startElement(ns, localName, name,
- copyAttributes(colgroup));
- }
-
- for (colnum = 0; colnum < numColumns; colnum++) {
- Element col = columns[colnum];
-
- NamedNodeMap domAttr = col.getAttributes();
-
- AttributesImpl attr = new AttributesImpl();
- for (int acount = 0; acount < domAttr.getLength(); acount++) {
- Node a = domAttr.item(acount);
- String a_ns = a.getNamespaceURI();
- String a_localName = a.getLocalName();
-
- if ((foStylesheet && !a_localName.equals("column-width"))
- || !a_localName.equalsIgnoreCase("width")) {
- attr.addAttribute(a.getNamespaceURI(),
- a.getLocalName(),
- a.getNodeName(),
- "CDATA",
- a.getNodeValue());
- }
- }
-
- if (foStylesheet) {
- attr.addAttribute("", "column-width", "column-width", "CDATA", widths[colnum]);
- } else {
- attr.addAttribute("", "width", "width", "CDATA", widths[colnum]);
- }
-
- rtf.startElement(col.getNamespaceURI(),
- col.getLocalName(),
- col.getTagName(),
- attr);
- rtf.endElement(col.getNamespaceURI(),
- col.getLocalName(),
- col.getTagName());
- }
-
- if (colgroup.getLocalName().equals("colgroup")) {
- rtf.endElement(ns, localName, name);
- }
- } catch (SAXException se) {
- System.out.println("SE!");
- return xalanRTF;
- }
-
- return df;
- }
-
- private Attributes copyAttributes(Element node) {
- AttributesImpl attrs = new AttributesImpl();
- NamedNodeMap nnm = node.getAttributes();
- for (int count = 0; count < nnm.getLength(); count++) {
- Attr attr = (Attr) nnm.item(count);
- String name = attr.getName();
- if (name.startsWith("xmlns:") || name.equals("xmlns")) {
- // Skip it; (don't ya just love it!!)
- } else {
- attrs.addAttribute(attr.getNamespaceURI(), attr.getName(),
- attr.getName(), "CDATA", attr.getValue());
- }
- }
- return attrs;
- }
-
- /**
- * Correct rounding errors introduced in calculating the width of each
- * column. Make sure they sum to 100% in the end.
- */
- protected String[] correctRoundingError(String widths[]) {
- int totalWidth = 0;
-
- for (int count = 0; count < widths.length; count++) {
- try {
- int width = Integer.parseInt(widths[count]);
- totalWidth += width;
- } catch (NumberFormatException nfe) {
- // nop; "can't happen"
- }
- }
-
- float totalError = 100 - totalWidth;
- float columnError = totalError / widths.length;
- float error = 0;
-
- for (int count = 0; count < widths.length; count++) {
- try {
- int width = Integer.parseInt(widths[count]);
- error = error + columnError;
- if (error >= 1.0) {
- int adj = (int) Math.round(Math.floor(error));
- error = error - (float) Math.floor(error);
- width = width + adj;
- widths[count] = Integer.toString(width) + "%";
- } else {
- widths[count] = Integer.toString(width) + "%";
- }
- } catch (NumberFormatException nfe) {
- // nop; "can't happen"
- }
- }
-
- return widths;
- }
-}
+++ /dev/null
-// Text - Xalan extension element for inserting text
-
-package com.nwalsh.xalan;
-
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.FileNotFoundException;
-import java.net.URL;
-import java.net.MalformedURLException;
-
-import org.xml.sax.SAXException;
-import org.xml.sax.AttributeList;
-import org.xml.sax.ContentHandler;
-
-import org.w3c.dom.*;
-
-import org.apache.xpath.objects.XObject;
-import org.apache.xpath.XPath;
-import org.apache.xpath.NodeSet;
-import org.apache.xalan.extensions.XSLProcessorContext;
-import org.apache.xalan.transformer.TransformerImpl;
-import org.apache.xalan.templates.StylesheetRoot;
-import org.apache.xalan.templates.ElemExtensionCall;
-import org.apache.xalan.templates.OutputProperties;
-import org.apache.xalan.res.XSLTErrorResources;
-
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.URIResolver;
-import javax.xml.transform.Source;
-
-/**
- * <p>Xalan extension element for inserting text
- *
- * <p>$Id$</p>
- *
- * <p>Copyright (C) 2001 Norman Walsh.</p>
- *
- * <p>This class provides a
- * <a href="http://xml.apache.org/xalan-j/">Xalan</a>
- * extension element for inserting text into a result tree.</p>
- *
- * <p><b>Change Log:</b></p>
- * <dl>
- * <dt>1.0</dt>
- * <dd><p>Initial release.</p></dd>
- * </dl>
- *
- * @author Norman Walsh
- * <a href="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a>
- *
- * @version $Id$
- *
- */
-public class Text {
- /**
- * <p>Constructor for Text</p>
- *
- * <p>Does nothing.</p>
- */
- public Text() {
- }
-
- public String insertfile(XSLProcessorContext context,
- ElemExtensionCall elem)
- throws MalformedURLException,
- FileNotFoundException,
- IOException,
- TransformerException {
- String href = getFilename(context, elem);
- String encoding = getEncoding(context, elem);
-
- String baseURI = context.getTransformer().getBaseURLOfSource();
- URIResolver resolver = context.getTransformer().getURIResolver();
-
- if (resolver != null) {
- Source source = resolver.resolve(href, baseURI);
- href = source.getSystemId();
- }
-
- URL baseURL = null;
- URL fileURL = null;
-
- try {
- baseURL = new URL(baseURI);
- } catch (MalformedURLException e1) {
- try {
- baseURL = new URL("file:" + baseURI);
- } catch (MalformedURLException e2) {
- System.out.println("Cannot find base URI for " + baseURI);
- baseURL = null;
- }
- }
-
- String text = "";
-
- try {
- try {
- fileURL = new URL(baseURL, href);
- } catch (MalformedURLException e1) {
- try {
- fileURL = new URL(baseURL, "file:" + href);
- } catch (MalformedURLException e2) {
- System.out.println("Cannot open " + href);
- return "";
- }
- }
-
- InputStreamReader isr = null;
- if (encoding.equals("") == true)
- isr = new InputStreamReader(fileURL.openStream());
- else
- isr = new InputStreamReader(fileURL.openStream(), encoding);
-
- BufferedReader is = new BufferedReader(isr);
-
- final int BUFFER_SIZE = 4096;
- char chars[] = new char[BUFFER_SIZE];
- char nchars[] = new char[BUFFER_SIZE];
- int len = 0;
- int i = 0;
- int carry = -1;
-
- while ((len = is.read(chars)) > 0) {
- // various new lines are normalized to LF to prevent blank lines
- // between lines
-
- int nlen = 0;
- for (i=0; i<len; i++) {
- // is current char CR?
- if (chars[i] == '\r') {
- if (i < (len - 1)) {
- // skip it if next char is LF
- if (chars[i+1] == '\n') continue;
- // single CR -> LF to normalize MAC line endings
- nchars[nlen] = '\n';
- nlen++;
- continue;
- } else {
- // if CR is last char of buffer we must look ahead
- carry = is.read();
- nchars[nlen] = '\n';
- nlen++;
- if (carry == '\n') {
- carry = -1;
- }
- break;
- }
- }
- nchars[nlen] = chars[i];
- nlen++;
- }
-
- text += String.valueOf(nchars, 0, nlen);
-
- // handle look aheaded character
- if (carry != -1) text += String.valueOf((char)carry);
- carry = -1;
- }
- is.close();
- } catch (Exception e) {
- System.out.println("Cannot read " + href);
- }
-
- return text;
- }
-
- private String getFilename(XSLProcessorContext context, ElemExtensionCall elem)
- throws java.net.MalformedURLException,
- java.io.FileNotFoundException,
- java.io.IOException,
- javax.xml.transform.TransformerException {
-
- String fileName;
-
- fileName = ((ElemExtensionCall)elem).getAttribute ("href",
- context.getContextNode(),
- context.getTransformer());
-
- if(fileName == null) {
- context.getTransformer().getMsgMgr().error(elem,
- "No 'href' on text, or not a filename");
- }
-
- return fileName;
- }
-
- private String getEncoding(XSLProcessorContext context, ElemExtensionCall elem)
- throws java.net.MalformedURLException,
- java.io.FileNotFoundException,
- java.io.IOException,
- javax.xml.transform.TransformerException {
-
- String encoding;
-
- encoding = ((ElemExtensionCall)elem).getAttribute ("encoding",
- context.getContextNode(),
- context.getTransformer());
-
- if (encoding == null) {
- return "";
- } else {
- return encoding;
- }
- }
-}
+++ /dev/null
-// Verbatim.java - Xalan extensions supporting DocBook verbatim environments
-
-package com.nwalsh.xalan;
-
-import java.util.Stack;
-import java.util.StringTokenizer;
-
-import org.xml.sax.*;
-import org.xml.sax.helpers.AttributesImpl;
-import org.w3c.dom.*;
-import org.w3c.dom.traversal.NodeIterator;
-
-import org.apache.xpath.objects.XObject;
-import org.apache.xpath.XPath;
-import org.apache.xpath.XPathContext;
-import org.apache.xpath.NodeSet;
-import org.apache.xalan.extensions.XSLProcessorContext;
-import org.apache.xalan.extensions.ExpressionContext;
-import org.apache.xalan.transformer.TransformerImpl;
-import org.apache.xalan.templates.StylesheetRoot;
-import org.apache.xalan.templates.ElemExtensionCall;
-import org.apache.xalan.templates.OutputProperties;
-import org.apache.xalan.res.XSLTErrorResources;
-import org.apache.xml.utils.DOMBuilder;
-import org.apache.xml.utils.AttList;
-import org.apache.xml.utils.QName;
-
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.TransformerException;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import com.nwalsh.xalan.Callout;
-import com.nwalsh.xalan.Params;
-
-/**
- * <p>Xalan extensions supporting DocBook verbatim environments</p>
- *
- * <p>$Id$</p>
- *
- * <p>Copyright (C) 2001 Norman Walsh.</p>
- *
- * <p>This class provides a
- * <a href="http://xml.apache.org/xalan-j/">Xalan</a>
- * implementation of two features that would be impractical to
- * implement directly in XSLT: line numbering and callouts.</p>
- *
- * <p><b>Line Numbering</b></p>
- * <p>The <tt>numberLines</tt> family of functions takes a result tree
- * fragment (assumed to contain the contents of a formatted verbatim
- * element in DocBook: programlisting, screen, address, literallayout,
- * or synopsis) and returns a result tree fragment decorated with
- * line numbers.</p>
- *
- * <p><b>Callouts</b></p>
- * <p>The <tt>insertCallouts</tt> family of functions takes an
- * <tt>areaspec</tt> and a result tree fragment
- * (assumed to contain the contents of a formatted verbatim
- * element in DocBook: programlisting, screen, address, literallayout,
- * or synopsis) and returns a result tree fragment decorated with
- * callouts.</p>
- *
- * <p><b>Change Log:</b></p>
- * <dl>
- * <dt>1.0</dt>
- * <dd><p>Initial release.</p></dd>
- * </dl>
- *
- * @author Norman Walsh
- * <a href="mailto:ndw@nwalsh.com">ndw@nwalsh.com</a>
- *
- * @version $Id$
- *
- */
-public class Verbatim {
- /** A stack to hold the open elements while walking through a RTF. */
- private Stack elementStack = null;
- /** A stack to hold the temporarily closed elements. */
- private Stack tempStack = null;
- /** The current line number. */
- private int lineNumber = 0;
- /** The current column number. */
- private int colNumber = 0;
- /** The modulus for line numbering (every 'modulus' line is numbered). */
- private int modulus = 0;
- /** The width (in characters) of line numbers (for padding). */
- private int width = 0;
- /** The separator between the line number and the verbatim text. */
- private String separator = "";
- /** The (sorted) array of callouts obtained from the areaspec. */
- private Callout callout[] = null;
- /** The number of callouts in the callout array. */
- private int calloutCount = 0;
- /** A pointer used to keep track of our position in the callout array. */
- private int calloutPos = 0;
- /** The path to use for graphical callout decorations. */
- private String graphicsPath = null;
- /** The extension to use for graphical callout decorations. */
- private String graphicsExt = null;
- /** The largest callout number that can be represented graphically. */
- private int graphicsMax = 10;
- /** Should graphic callouts use fo:external-graphics or imgs. */
- private boolean graphicsFO = false;
-
- private static final String foURI = "http://www.w3.org/1999/XSL/Format";
- private static final String xhURI = "http://www.w3.org/1999/xhtml";
-
- /**
- * <p>Constructor for Verbatim</p>
- *
- * <p>All of the methods are static, so the constructor does nothing.</p>
- */
- public Verbatim() {
- }
-
- /**
- * <p>Number lines in a verbatim environment.</p>
- *
- * <p>This method adds line numbers to a result tree fragment. Each
- * newline that occurs in a text node is assumed to start a new line.
- * The first line is always numbered, every subsequent xalanMod line
- * is numbered (so if xalanMod=5, lines 1, 5, 10, 15, etc. will be
- * numbered. If there are fewer than xalanMod lines in the environment,
- * every line is numbered.</p>
- *
- * <p>xalanMod is taken from the $linenumbering.everyNth parameter.</p>
- *
- * <p>Every line number will be right justified in a string xalanWidth
- * characters long. If the line number of the last line in the
- * environment is too long to fit in the specified width, the width
- * is automatically increased to the smallest value that can hold the
- * number of the last line. (In other words, if you specify the value 2
- * and attempt to enumerate the lines of an environment that is 100 lines
- * long, the value 3 will automatically be used for every line in the
- * environment.)</p>
- *
- * <p>xalanWidth is taken from the $linenumbering.width parameter.</p>
- *
- * <p>The xalanSep string is inserted between the line
- * number and the original program listing. Lines that aren't numbered
- * are preceded by a xalanWidth blank string and the separator.</p>
- *
- * <p>xalanSep is taken from the $linenumbering.separator parameter.</p>
- *
- * <p>If inline markup extends across line breaks, markup changes are
- * required. All the open elements are closed before the line break and
- * "reopened" afterwards. The reopened elements will have the same
- * attributes as the originals, except that 'name' and 'id' attributes
- * are not duplicated.</p>
- *
- * @param context
- * @param xalanNI
- *
- * @return The modified result tree fragment.
- */
- public DocumentFragment numberLines (ExpressionContext context,
- NodeIterator xalanNI) {
-
- int xalanMod = Params.getInt(context, "linenumbering.everyNth");
- int xalanWidth = Params.getInt(context, "linenumbering.width");
- String xalanSep = Params.getString(context, "linenumbering.separator");
-
- DocumentFragment xalanRTF = (DocumentFragment) xalanNI.nextNode();
- int numLines = countLineBreaks(xalanRTF) + 1;
-
- DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder docBuilder = null;
-
- try {
- docBuilder = docFactory.newDocumentBuilder();
- } catch (ParserConfigurationException e) {
- System.out.println("PCE!");
- return xalanRTF;
- }
- Document doc = docBuilder.newDocument();
- DocumentFragment df = doc.createDocumentFragment();
- DOMBuilder db = new DOMBuilder(doc, df);
-
- elementStack = new Stack();
- lineNumber = 0;
- modulus = numLines < xalanMod ? 1 : xalanMod;
- width = xalanWidth;
- separator = xalanSep;
-
- double log10numLines = Math.log(numLines) / Math.log(10);
-
- if (width < log10numLines + 1) {
- width = (int) Math.floor(log10numLines + 1);
- }
-
- lineNumberFragment(db, xalanRTF);
- return df;
- }
-
- /**
- * <p>Count the number of lines in a verbatim environment.</p>
- *
- * <p>This method walks over the nodes of a DocumentFragment and
- * returns the number of lines breaks that it contains.</p>
- *
- * @param node The root of the tree walk over.
- */
- private int countLineBreaks(Node node) {
- int numLines = 0;
-
- if (node.getNodeType() == Node.DOCUMENT_FRAGMENT_NODE
- || node.getNodeType() == Node.DOCUMENT_NODE
- || node.getNodeType() == Node.ELEMENT_NODE) {
- Node child = node.getFirstChild();
- while (child != null) {
- numLines += countLineBreaks(child);
- child = child.getNextSibling();
- }
- } else if (node.getNodeType() == Node.TEXT_NODE) {
- String text = node.getNodeValue();
-
- // Walk through the text node looking for newlines
- int pos = 0;
- for (int count = 0; count < text.length(); count++) {
- if (text.charAt(count) == '\n') {
- numLines++;
- }
- }
- } else {
- // nop
- }
-
- return numLines;
- }
-
- /**
- * <p>Build a DocumentFragment with numbered lines.</p>
- *
- * <p>This is the method that actually does the work of numbering
- * lines in a verbatim environment. It recursively walks through a
- * tree of nodes, copying the structure into the rtf. Text nodes
- * are examined for new lines and modified as requested by the
- * global line numbering parameters.</p>
- *
- * <p>When called, rtf should be an empty DocumentFragment and node
- * should be the first child of the result tree fragment that contains
- * the existing, formatted verbatim text.</p>
- *
- * @param rtf The resulting verbatim environment with numbered lines.
- * @param node The root of the tree to copy.
- */
- private void lineNumberFragment(DOMBuilder rtf,
- Node node) {
- try {
- if (node.getNodeType() == Node.DOCUMENT_FRAGMENT_NODE
- || node.getNodeType() == Node.DOCUMENT_NODE) {
- Node child = node.getFirstChild();
- while (child != null) {
- lineNumberFragment(rtf, child);
- child = child.getNextSibling();
- }
- } else if (node.getNodeType() == Node.ELEMENT_NODE) {
- String ns = node.getNamespaceURI();
- String localName = node.getLocalName();
- String name = ((Element) node).getTagName();
-
- rtf.startElement(ns, localName, name,
- copyAttributes((Element) node));
-
- elementStack.push(node);
-
- Node child = node.getFirstChild();
- while (child != null) {
- lineNumberFragment(rtf, child);
- child = child.getNextSibling();
- }
- } else if (node.getNodeType() == Node.TEXT_NODE) {
- String text = node.getNodeValue();
-
- if (lineNumber == 0) {
- // The first line is always numbered
- formatLineNumber(rtf, ++lineNumber);
- }
-
- // Walk through the text node looking for newlines
- char chars[] = text.toCharArray();
- int pos = 0;
- for (int count = 0; count < text.length(); count++) {
- if (text.charAt(count) == '\n') {
- // This is the tricky bit; if we find a newline, make sure
- // it doesn't occur inside any markup.
-
- if (pos > 0) {
- rtf.characters(chars, 0, pos);
- pos = 0;
- }
-
- closeOpenElements(rtf);
-
- // Copy the newline to the output
- chars[pos++] = text.charAt(count);
- rtf.characters(chars, 0, pos);
- pos = 0;
-
- // Add the line number
- formatLineNumber(rtf, ++lineNumber);
-
- openClosedElements(rtf);
- } else {
- chars[pos++] = text.charAt(count);
- }
- }
-
- if (pos > 0) {
- rtf.characters(chars, 0, pos);
- }
- } else if (node.getNodeType() == Node.COMMENT_NODE) {
- String text = node.getNodeValue();
- char chars[] = text.toCharArray();
- rtf.comment(chars, 0, text.length());
- } else if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
- rtf.processingInstruction(node.getNodeName(), node.getNodeValue());
- } else {
- System.out.println("Warning: unexpected node type in lineNumberFragment");
- }
-
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- String ns = node.getNamespaceURI();
- String localName = node.getLocalName();
- String name = ((Element) node).getTagName();
- rtf.endElement(ns, localName, name);
- elementStack.pop();
- }
- } catch (SAXException e) {
- System.out.println("SAX Exception in lineNumberFragment");
- }
- }
-
- /**
- * <p>Add a formatted line number to the result tree fragment.</p>
- *
- * <p>This method examines the global parameters that control line
- * number presentation (modulus, width, and separator) and adds
- * the appropriate text to the result tree fragment.</p>
- *
- * @param rtf The resulting verbatim environment with numbered lines.
- * @param lineNumber The number of the current line.
- */
- private void formatLineNumber(DOMBuilder rtf,
- int lineNumber) {
- char ch = 160;
- String lno = "";
- if (lineNumber == 1
- || (modulus >= 1 && (lineNumber % modulus == 0))) {
- lno = "" + lineNumber;
- }
-
- while (lno.length() < width) {
- lno = ch + lno;
- }
-
- lno += separator;
-
- char chars[] = lno.toCharArray();
- try {
- rtf.characters(chars, 0, lno.length());
- } catch (SAXException e) {
- System.out.println("SAX Exception in formatLineNumber");
- }
- }
-
- /**
- * <p>Insert text callouts into a verbatim environment.</p>
- *
- * <p>This method examines the <tt>areaset</tt> and <tt>area</tt> elements
- * in the supplied <tt>areaspec</tt> and decorates the supplied
- * result tree fragment with appropriate callout markers.</p>
- *
- * <p>If a <tt>label</tt> attribute is supplied on an <tt>area</tt>,
- * its content will be used for the label, otherwise the callout
- * number will be used, surrounded by parenthesis. Callouts are
- * numbered in document order. All of the <tt>area</tt>s in an
- * <tt>areaset</tt> get the same number.</p>
- *
- * <p>Only the <tt>linecolumn</tt> and <tt>linerange</tt> units are
- * supported. If no unit is specifed, <tt>linecolumn</tt> is assumed.
- * If only a line is specified, the callout decoration appears in
- * the defaultColumn. Lines will be padded with blanks to reach the
- * necessary column, but callouts that are located beyond the last
- * line of the verbatim environment will be ignored.</p>
- *
- * <p>Callouts are inserted before the character at the line/column
- * where they are to occur.</p>
- *
- * @param areaspecNodeSet The source node set that contains the areaspec.
- * @param xalanRTF The result tree fragment of the verbatim environment.
- * @param defaultColumn The column for callouts that specify only a line.
- *
- * @return The modified result tree fragment. */
-
- /**
- * <p>Insert graphical callouts into a verbatim environment.</p>
- *
- * <p>This method examines the <tt>areaset</tt> and <tt>area</tt> elements
- * in the supplied <tt>areaspec</tt> and decorates the supplied
- * result tree fragment with appropriate callout markers.</p>
- *
- * <p>If a <tt>label</tt> attribute is supplied on an <tt>area</tt>,
- * its content will be used for the label, otherwise the callout
- * number will be used. Callouts are
- * numbered in document order. All of the <tt>area</tt>s in an
- * <tt>areaset</tt> get the same number.</p>
- *
- * <p>If the callout number is not greater than <tt>gMax</tt>, the
- * callout generated will be:</p>
- *
- * <pre>
- * <img src="$gPath/conumber$gExt" alt="conumber">
- * </pre>
- *
- * <p>Otherwise, it will be the callout number surrounded by
- * parenthesis.</p>
- *
- * <p>Only the <tt>linecolumn</tt> and <tt>linerange</tt> units are
- * supported. If no unit is specifed, <tt>linecolumn</tt> is assumed.
- * If only a line is specified, the callout decoration appears in
- * the defaultColumn. Lines will be padded with blanks to reach the
- * necessary column, but callouts that are located beyond the last
- * line of the verbatim environment will be ignored.</p>
- *
- * <p>Callouts are inserted before the character at the line/column
- * where they are to occur.</p>
- *
- * @param context
- * @param areaspecNodeSet The source node set that contains the areaspec.
- * @param xalanNI
- *
- * @return The modified result tree fragment.
- */
- public DocumentFragment insertCallouts (ExpressionContext context,
- NodeIterator areaspecNodeSet,
- NodeIterator xalanNI) {
- String type = Params.getString(context, "stylesheet.result.type");
- boolean useFO = type.equals("fo");
- int defaultColumn = Params.getInt(context, "callout.defaultcolumn");
-
- if (Params.getBoolean(context, "callout.graphics")) {
- String gPath = Params.getString(context, "callout.graphics.path");
- String gExt = Params.getString(context, "callout.graphics.extension");
- int gMax = Params.getInt(context, "callout.graphics.number.limit");
- return insertGraphicCallouts(areaspecNodeSet, xalanNI, defaultColumn,
- gPath, gExt, gMax, useFO);
- } else if (Params.getBoolean(context, "callout.unicode")) {
- int uStart = Params.getInt(context, "callout.unicode.start.character");
- int uMax = Params.getInt(context, "callout.unicode.number.limit");
- String uFont = Params.getString(context, "callout.unicode.font");
- return insertUnicodeCallouts(areaspecNodeSet, xalanNI, defaultColumn,
- uFont, uStart, uMax, useFO);
- } else if (Params.getBoolean(context, "callout.dingbats")) {
- int dMax = 10;
- return insertDingbatCallouts(areaspecNodeSet, xalanNI, defaultColumn,
- dMax, useFO);
- } else {
- return insertTextCallouts(areaspecNodeSet, xalanNI, defaultColumn, useFO);
- }
- }
-
- public DocumentFragment insertGraphicCallouts (NodeIterator areaspecNodeSet,
- NodeIterator xalanNI,
- int defaultColumn,
- String gPath,
- String gExt,
- int gMax,
- boolean useFO) {
- FormatGraphicCallout fgc = new FormatGraphicCallout(gPath,gExt,gMax,useFO);
- return insertCallouts(areaspecNodeSet, xalanNI, defaultColumn, fgc);
- }
-
- public DocumentFragment insertUnicodeCallouts (NodeIterator areaspecNodeSet,
- NodeIterator xalanNI,
- int defaultColumn,
- String uFont,
- int uStart,
- int uMax,
- boolean useFO) {
- FormatUnicodeCallout fuc = new FormatUnicodeCallout(uFont, uStart, uMax, useFO);
- return insertCallouts(areaspecNodeSet, xalanNI, defaultColumn, fuc);
- }
-
- public DocumentFragment insertDingbatCallouts (NodeIterator areaspecNodeSet,
- NodeIterator xalanNI,
- int defaultColumn,
- int gMax,
- boolean useFO) {
- FormatDingbatCallout fdc = new FormatDingbatCallout(gMax,useFO);
- return insertCallouts(areaspecNodeSet, xalanNI, defaultColumn, fdc);
- }
-
- public DocumentFragment insertTextCallouts (NodeIterator areaspecNodeSet,
- NodeIterator xalanNI,
- int defaultColumn,
- boolean useFO) {
- FormatTextCallout ftc = new FormatTextCallout(useFO);
- return insertCallouts(areaspecNodeSet, xalanNI, defaultColumn, ftc);
- }
-
- public DocumentFragment insertCallouts (NodeIterator areaspecNodeSet,
- NodeIterator xalanNI,
- int defaultColumn,
- FormatCallout fCallout) {
-
- DocumentFragment xalanRTF = (DocumentFragment) xalanNI.nextNode();
-
- callout = new Callout[10];
- calloutCount = 0;
- calloutPos = 0;
- lineNumber = 1;
- colNumber = 1;
-
- // First we walk through the areaspec to calculate the position
- // of the callouts
- // <areaspec>
- // <areaset id="ex.plco.const" coords="">
- // <area id="ex.plco.c1" coords="4"/>
- // <area id="ex.plco.c2" coords="8"/>
- // </areaset>
- // <area id="ex.plco.ret" coords="12"/>
- // <area id="ex.plco.dest" coords="12"/>
- // </areaspec>
- int pos = 0;
- int coNum = 0;
- boolean inAreaSet = false;
- Node node = areaspecNodeSet.nextNode();
- node = node.getFirstChild();
- while (node != null) {
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- if (node.getNodeName().equals("areaset")) {
- coNum++;
- Node area = node.getFirstChild();
- while (area != null) {
- if (area.getNodeType() == Node.ELEMENT_NODE) {
- if (area.getNodeName().equals("area")) {
- addCallout(coNum, area, defaultColumn);
- } else {
- System.out.println("Unexpected element in areaset: "
- + area.getNodeName());
- }
- }
- area = area.getNextSibling();
- }
- } else if (node.getNodeName().equalsIgnoreCase("area")) {
- coNum++;
- addCallout(coNum, node, defaultColumn);
- } else {
- System.out.println("Unexpected element in areaspec: "
- + node.getNodeName());
- }
- }
-
- node = node.getNextSibling();
- }
-
- // Now sort them
- java.util.Arrays.sort(callout, 0, calloutCount);
-
- DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder docBuilder = null;
-
- try {
- docBuilder = docFactory.newDocumentBuilder();
- } catch (ParserConfigurationException e) {
- System.out.println("PCE 2!");
- return xalanRTF;
- }
- Document doc = docBuilder.newDocument();
- DocumentFragment df = doc.createDocumentFragment();
- DOMBuilder db = new DOMBuilder(doc, df);
-
- elementStack = new Stack();
- calloutFragment(db, xalanRTF, fCallout);
- return df;
- }
-
- /**
- * <p>Build a FragmentValue with callout decorations.</p>
- *
- * <p>This is the method that actually does the work of adding
- * callouts to a verbatim environment. It recursively walks through a
- * tree of nodes, copying the structure into the rtf. Text nodes
- * are examined for the position of callouts as described by the
- * global callout parameters.</p>
- *
- * <p>When called, rtf should be an empty FragmentValue and node
- * should be the first child of the result tree fragment that contains
- * the existing, formatted verbatim text.</p>
- *
- * @param rtf The resulting verbatim environment with numbered lines.
- * @param node The root of the tree to copy.
- */
- private void calloutFragment(DOMBuilder rtf,
- Node node,
- FormatCallout fCallout) {
- try {
- if (node.getNodeType() == Node.DOCUMENT_FRAGMENT_NODE
- || node.getNodeType() == Node.DOCUMENT_NODE) {
- Node child = node.getFirstChild();
- while (child != null) {
- calloutFragment(rtf, child, fCallout);
- child = child.getNextSibling();
- }
- } else if (node.getNodeType() == Node.ELEMENT_NODE) {
- String ns = node.getNamespaceURI();
- String localName = node.getLocalName();
- String name = ((Element) node).getTagName();
-
- rtf.startElement(ns, localName, name,
- copyAttributes((Element) node));
-
- elementStack.push(node);
-
- Node child = node.getFirstChild();
- while (child != null) {
- calloutFragment(rtf, child, fCallout);
- child = child.getNextSibling();
- }
- } else if (node.getNodeType() == Node.TEXT_NODE) {
- String text = node.getNodeValue();
-
- char chars[] = text.toCharArray();
- int pos = 0;
- for (int count = 0; count < text.length(); count++) {
- if (calloutPos < calloutCount
- && callout[calloutPos].getLine() == lineNumber
- && callout[calloutPos].getColumn() == colNumber) {
- if (pos > 0) {
- rtf.characters(chars, 0, pos);
- pos = 0;
- }
-
- closeOpenElements(rtf);
-
- while (calloutPos < calloutCount
- && callout[calloutPos].getLine() == lineNumber
- && callout[calloutPos].getColumn() == colNumber) {
- fCallout.formatCallout(rtf, callout[calloutPos]);
- calloutPos++;
- }
-
- openClosedElements(rtf);
- }
-
- if (text.charAt(count) == '\n') {
- // What if we need to pad this line?
- if (calloutPos < calloutCount
- && callout[calloutPos].getLine() == lineNumber
- && callout[calloutPos].getColumn() > colNumber) {
-
- if (pos > 0) {
- rtf.characters(chars, 0, pos);
- pos = 0;
- }
-
- closeOpenElements(rtf);
-
- while (calloutPos < calloutCount
- && callout[calloutPos].getLine() == lineNumber
- && callout[calloutPos].getColumn() > colNumber) {
- formatPad(rtf, callout[calloutPos].getColumn() - colNumber);
- colNumber = callout[calloutPos].getColumn();
- while (calloutPos < calloutCount
- && callout[calloutPos].getLine() == lineNumber
- && callout[calloutPos].getColumn() == colNumber) {
- fCallout.formatCallout(rtf, callout[calloutPos]);
- calloutPos++;
- }
- }
-
- openClosedElements(rtf);
- }
-
- lineNumber++;
- colNumber = 1;
- } else {
- colNumber++;
- }
- chars[pos++] = text.charAt(count);
- }
-
- if (pos > 0) {
- rtf.characters(chars, 0, pos);
- }
- } else if (node.getNodeType() == Node.COMMENT_NODE) {
- String text = node.getNodeValue();
- char chars[] = text.toCharArray();
- rtf.comment(chars, 0, text.length());
- } else if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
- rtf.processingInstruction(node.getNodeName(), node.getNodeValue());
- } else {
- System.out.println("Warning: unexpected node type in calloutFragment: " + node.getNodeType() + ": " + node.getNodeName());
- }
-
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- String ns = node.getNamespaceURI();
- String localName = node.getLocalName();
- String name = ((Element) node).getTagName();
- rtf.endElement(ns, localName, name);
- elementStack.pop();
- } else {
- // nop
- }
- } catch (SAXException e) {
- System.out.println("SAX Exception in calloutFragment");
- }
- }
-
- /**
- * <p>Add a callout to the global callout array</p>
- *
- * <p>This method examines a callout <tt>area</tt> and adds it to
- * the global callout array if it can be interpreted.</p>
- *
- * <p>Only the <tt>linecolumn</tt> and <tt>linerange</tt> units are
- * supported. If no unit is specifed, <tt>linecolumn</tt> is assumed.
- * If only a line is specified, the callout decoration appears in
- * the <tt>defaultColumn</tt>.</p>
- *
- * @param coNum The callout number.
- * @param node The <tt>area</tt>.
- * @param defaultColumn The default column for callouts.
- */
- private void addCallout (int coNum,
- Node node,
- int defaultColumn) {
- Element area = (Element) node;
-
- String units = area.getAttribute("units");
- String otherUnits = area.getAttribute("otherunits");
- String coords = area.getAttribute("coords");
- int type = 0;
- String otherType = null;
-
- if (units == null || units.equals("linecolumn")) {
- type = Callout.LINE_COLUMN; // the default
- } else if (units.equals("linerange")) {
- type = Callout.LINE_RANGE;
- } else if (units.equals("linecolumnpair")) {
- type = Callout.LINE_COLUMN_PAIR;
- } else if (units.equals("calspair")) {
- type = Callout.CALS_PAIR;
- } else {
- type = Callout.OTHER;
- otherType = otherUnits;
- }
-
- if (type != Callout.LINE_COLUMN
- && type != Callout.LINE_RANGE) {
- System.out.println("Only linecolumn and linerange units are supported");
- return;
- }
-
- if (coords == null) {
- System.out.println("Coords must be specified");
- return;
- }
-
- // Now let's see if we can interpret the coordinates...
- StringTokenizer st = new StringTokenizer(coords);
- int tokenCount = 0;
- int c1 = 0;
- int c2 = 0;
- while (st.hasMoreTokens()) {
- tokenCount++;
- if (tokenCount > 2) {
- System.out.println("Unparseable coordinates");
- return;
- }
- try {
- String token = st.nextToken();
- int coord = Integer.parseInt(token);
- c2 = coord;
- if (tokenCount == 1) {
- c1 = coord;
- }
- } catch (NumberFormatException e) {
- System.out.println("Unparseable coordinate");
- return;
- }
- }
-
- // Make sure we aren't going to blow past the end of our array
- if (calloutCount == callout.length) {
- Callout bigger[] = new Callout[calloutCount+10];
- for (int count = 0; count < callout.length; count++) {
- bigger[count] = callout[count];
- }
- callout = bigger;
- }
-
- // Ok, add the callout
- if (tokenCount == 2) {
- if (type == Callout.LINE_RANGE) {
- for (int count = c1; count <= c2; count++) {
- callout[calloutCount++] = new Callout(coNum, area,
- count, defaultColumn,
- type);
- }
- } else {
- // assume linecolumn
- callout[calloutCount++] = new Callout(coNum, area, c1, c2, type);
- }
- } else {
- // if there's only one number, assume it's the line
- callout[calloutCount++] = new Callout(coNum, area, c1, defaultColumn, type);
- }
- }
-
- /**
- * <p>Add blanks to the result tree fragment.</p>
- *
- * <p>This method adds <tt>numBlanks</tt> to the result tree fragment.
- * It's used to pad lines when callouts occur after the last existing
- * characater in a line.</p>
- *
- * @param rtf The resulting verbatim environment with numbered lines.
- * @param numBlanks The number of blanks to add.
- */
- private void formatPad(DOMBuilder rtf,
- int numBlanks) {
- char chars[] = new char[numBlanks];
- for (int count = 0; count < numBlanks; count++) {
- chars[count] = ' ';
- }
-
- try {
- rtf.characters(chars, 0, numBlanks);
- } catch (SAXException e) {
- System.out.println("SAX Exception in formatCallout");
- }
- }
-
- private void closeOpenElements(DOMBuilder rtf)
- throws SAXException {
- // Close all the open elements...
- tempStack = new Stack();
- while (!elementStack.empty()) {
- Node elem = (Node) elementStack.pop();
-
- String ns = elem.getNamespaceURI();
- String localName = elem.getLocalName();
- String name = ((Element) elem).getTagName();
-
- // If this is the bottom of the stack and it's an fo:block
- // or an HTML pre or div, don't duplicate it...
- if (elementStack.empty()
- && (((ns != null)
- && ns.equals(foURI)
- && localName.equals("block"))
- || (((ns == null)
- && localName.equalsIgnoreCase("pre"))
- || ((ns != null)
- && ns.equals(xhURI)
- && localName.equals("pre")))
- || (((ns == null)
- && localName.equalsIgnoreCase("div"))
- || ((ns != null)
- && ns.equals(xhURI)
- && localName.equals("div"))))) {
- elementStack.push(elem);
- break;
- } else {
- rtf.endElement(ns, localName, name);
- tempStack.push(elem);
- }
- }
- }
-
- private void openClosedElements(DOMBuilder rtf)
- throws SAXException {
- // Now "reopen" the elements that we closed...
- while (!tempStack.empty()) {
- Node elem = (Node) tempStack.pop();
-
- String ns = elem.getNamespaceURI();
- String localName = elem.getLocalName();
- String name = ((Element) elem).getTagName();
- NamedNodeMap domAttr = elem.getAttributes();
-
- AttributesImpl attr = new AttributesImpl();
- for (int acount = 0; acount < domAttr.getLength(); acount++) {
- Node a = domAttr.item(acount);
-
- if (((ns == null || ns == "http://www.w3.org/1999/xhtml")
- && localName.equalsIgnoreCase("a"))
- || (a.getLocalName().equalsIgnoreCase("id"))) {
- // skip this attribute
- } else {
- attr.addAttribute(a.getNamespaceURI(),
- a.getLocalName(),
- a.getNodeName(),
- "CDATA",
- a.getNodeValue());
- }
- }
-
- rtf.startElement(ns, localName, name, attr);
- elementStack.push(elem);
- }
-
- tempStack = null;
- }
-
- private Attributes copyAttributes(Element node) {
- AttributesImpl attrs = new AttributesImpl();
- NamedNodeMap nnm = node.getAttributes();
- for (int count = 0; count < nnm.getLength(); count++) {
- Attr attr = (Attr) nnm.item(count);
- String name = attr.getName();
- if (name.startsWith("xmlns:") || name.equals("xmlns")) {
- // Skip it; (don't ya just love it!!)
- } else {
- attrs.addAttribute(attr.getNamespaceURI(), attr.getName(),
- attr.getName(), "CDATA", attr.getValue());
- }
- }
- return attrs;
- }
-}
+++ /dev/null
-<html>
-<head>
-<title>Norman Walsh's Xalan Extensions Package</title>
-</head>
-<body>
-<p>Norman Walsh's Xalan Extensions Package for Xalan2</p>
-
-<p>This package implements Xalan extensions for XSLT.</p>
-
-<p><b>Copyright (C) 2000 Norman Walsh</b></p>
-<p>Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use, copy,
-modify, merge, publish, distribute, sublicense, and/or sell copies
-of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:</p>
-
-<p>The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.</p>
-
-<p>Except as contained in this notice, the names of individuals
-credited with contribution to this software shall not be used in
-advertising or otherwise to promote the sale, use or other dealings
-in this Software without prior written authorization from the
-individuals in question.</p>
-
-<p>Anything derived from this Software that is publically
-distributed will be identified with a different name and the
-version strings in any derived Software will be changed so that no
-possibility of confusion between the derived package and this
-Software will exist.</p>
-</blockquote>
-
-<blockquote>
-<p><b>Warranty</b></p>
-<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL NORMAN WALSH OR ANY OTHER
-CONTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.</p>
-</blockquote>
-
-</body>
-</html>